code wiki / (root) / nx_autofix_mut_max2_rf.nx

nx_autofix_mut_max2_rf.nx source

↩ module page · 46 lines · 1824 B

1// nx_autofix_mut_max2_rf.nx -- MUTATION-GENERATED FOREIGN BUG (class: return-first / branch-elide). 2// Foreign = not the maker model's own output, so the greedy fixed-point wall does not apply. Part of 3// the scaled SWE-bench-contract resolve set. Target: max2. Sibling dbl must stay green (PASS_TO_PASS). 4import "nx_syscalls.nx" 5 6func cw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 7func cn(v: i64) -> i64 { 8 var m: i64 = v 9 if m < 0 { cw("-" as *u8); m = 0 - m } 10 let t: *u8 = sys_mmap(24) 11 var k: i64 = 0 12 if m == 0 { t[0] = 48 as u8; k = 1 } 13 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 14 let o: *u8 = sys_mmap(24) 15 var i: i64 = 0 16 while i < k { o[i] = t[k - 1 - i]; i = i + 1 } 17 sys_write(1, o, k) 18 return 0 19} 20func fncase2(fn: *u8, a: i64, b: i64, want: i64, got: i64) -> i64 { 21 cw("FNCASE " as *u8); cw(fn); cw(" " as *u8); cn(a); cw(" " as *u8); cn(b) 22 cw(" want " as *u8); cn(want); cw(" got " as *u8); cn(got); cw("\n" as *u8) 23 return 0 24} 25 26func dbl(x: i64) -> i64 { return x + x } 27func max2(a: i64, b: i64) -> i64 { return a } 28 29func main() -> i64 { 30 var p: i64 = 0 31 var f1: i64 = 0 32 if dbl(6) == 12 { f1 = f1 + 1 } 33 if dbl(0 - 4) == (0 - 8) { f1 = f1 + 1 } 34 var f2: i64 = 0 35 let c1: i64 = max2(3, 5) 36 if c1 == 5 { f2 = f2 + 1 } else { fncase2("max2" as *u8, 3, 5, 5, c1) } 37 let c2: i64 = max2(7, 2) 38 if c2 == 7 { f2 = f2 + 1 } else { fncase2("max2" as *u8, 7, 2, 7, c2) } 39 let c3: i64 = max2(4, 4) 40 if c3 == 4 { f2 = f2 + 1 } else { fncase2("max2" as *u8, 4, 4, 4, c3) } 41 p = f1 + f2 42 cw("FNRES dbl " as *u8); cn(f1); cw(" 2\n" as *u8) 43 cw("FNRES max2 " as *u8); cn(f2); cw(" 3\n" as *u8) 44 cw("CGR=" as *u8); cn(p); cw("\n" as *u8) 45 return 0 46}