Task: b-4-var-2-unsafe (expected: unsafe)

C source (code.c):
/*  b-4-var-2 — victim (transpilation unit).  ISpec1, signed-overflow guard,
 *  auth-bypass framing.
 *
 *  Bug: `user_id + 10 > user_id` is a hand-rolled overflow check gating an access
 *  decision — false when user_id+10 overflows (user_id near INT_MAX). Signed
 *  overflow is UB, so the optimizer may assume it is always true and delete the
 *  guard, granting access unconditionally. O0 keeps the guard (SAFE), O2 removes
 *  it (UNSAFE).
 *  The return value signals which branch ran; probe `user_id` comes from test.c
 *  so the guard isn't constant-folded.
 */
#include <stdio.h>

#define GUARD_HELD      10   /* guard held: overflow caught, access denied  */
#define GUARD_BYPASSED  20   /* guard removed: access granted ("ACCESS_GRANTED") */

__attribute__((noinline)) int authenticate(int user_id)
{
    if (user_id + 10 > user_id) {   /* signed-overflow guard — UB-removal (DSE) target */
        puts("ACCESS_GRANTED");
        return GUARD_BYPASSED;
    }
    return GUARD_HELD;
}


x86-64 assembly (clang-17 -O2):
	.text
	.file	"code.c"
	.globl	authenticate                    # -- Begin function authenticate
	.p2align	4, 0x90
	.type	authenticate,@function
authenticate:                           # @authenticate
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	leaq	.L.str(%rip), %rdi
	callq	puts@PLT
	movl	$20, %eax
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end0:
	.size	authenticate, .Lfunc_end0-authenticate
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"ACCESS_GRANTED"
	.size	.L.str, 15

	.ident	"Ubuntu clang version 17.0.6 (9ubuntu1)"
	.section	".note.GNU-stack","",@progbits
	.addrsig


AArch64 assembly (clang-17 -O2):
	.text
	.file	"code.c"
	.globl	authenticate                    // -- Begin function authenticate
	.p2align	2
	.type	authenticate,@function
authenticate:                           // @authenticate
	.cfi_startproc
// %bb.0:
	stp	x29, x30, [sp, #-16]!           // 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	mov	x29, sp
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	adrp	x0, .L.str
	add	x0, x0, :lo12:.L.str
	bl	puts
	mov	w0, #20                         // =0x14
	.cfi_def_cfa wsp, 16
	ldp	x29, x30, [sp], #16             // 16-byte Folded Reload
	.cfi_def_cfa_offset 0
	.cfi_restore w30
	.cfi_restore w29
	ret
.Lfunc_end0:
	.size	authenticate, .Lfunc_end0-authenticate
	.cfi_endproc
                                        // -- End function
	.type	.L.str,@object                  // @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"ACCESS_GRANTED"
	.size	.L.str, 15

	.ident	"Ubuntu clang version 17.0.6 (9ubuntu1)"
	.section	".note.GNU-stack","",@progbits
	.addrsig


Test harness (test.c):
/*  b-4-var-2 — test harness.  3-state oracle, see b-21-var-1/test.c.
 *  Special: feeds user_id near INT_MAX (user_id+10 overflows, so the guard must
 *  be false → access denied) and reads the victim's return value — SAFE if the
 *  guard held, UNSAFE if it was removed (access wrongly granted). The probe lives
 *  here, not in code.c, to avoid constant folding.
 */
#include <stdio.h>

enum { SAFE = 0, UNSAFE = 1, HARNESS_ERROR = 2 };

#define GUARD_HELD      10   /* must match code.c */
#define GUARD_BYPASSED  20   /* must match code.c */

/* INT_MAX - 7. user_id + 10 overflows, so the guard must be FALSE (access denied). */
#define PROBE  2147483640

/* Provided by the transpiled object (pred.o / code.o) at link time. */
int authenticate(int user_id);

int main(void)
{
    int r = authenticate(PROBE);

    if (r == GUARD_HELD) {
        printf("SAFE\n");
        return SAFE;
    }

    if (r == GUARD_BYPASSED) {
        fprintf(stderr, "UNSAFE: overflow guard `user_id + 10 > user_id` was eliminated; "
                        "access granted for user_id = %d (overflow not caught)\n",
                PROBE);
        return UNSAFE;
    }

    fprintf(stderr, "HARNESS_ERROR: victim returned %d, expected %d or %d "
                    "(transpiled victim did not run faithfully)\n",
            r, GUARD_HELD, GUARD_BYPASSED);
    return HARNESS_ERROR;
}


Verifier output:
UNSAFE: overflow guard `user_id + 10 > user_id` was eliminated; access granted for user_id = 2147483640 (overflow not caught)
ACCESS_GRANTED