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

C source (code.c):
/*  b-9-var-2 — victim (transpilation unit).  ISpec1, signed-overflow ASSERT,
 *  auth-bypass framing.
 *
 *  Bug: `assert(session_id + 100 > session_id)` must ABORT when the addition
 *  overflows (session_id near INT_MAX). Signed overflow is UB, so the optimizer
 *  may assume it is always true and delete the assert, granting access instead
 *  of aborting.
 *  O0 keeps the assert (fires → SIGABRT = SAFE), O2 removes it (prints
 *  "ACCESS_GRANTED" = UNSAFE).
 *  Note: test.c forks a child to run authenticate() so the abort is contained;
 *  probe `session_id` comes from test.c (no folding).
 */
#include <assert.h>
#include <stdio.h>

__attribute__((noinline)) int authenticate(int session_id)
{
    assert(session_id + 100 > session_id);   /* signed-overflow security check */
    puts("ACCESS_GRANTED");                  /* body: runs only if assert removed */
    return session_id;
}


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
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	movl	%edi, %ebx
	leaq	.L.str.2(%rip), %rdi
	callq	puts@PLT
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.Lfunc_end0:
	.size	authenticate, .Lfunc_end0-authenticate
	.cfi_endproc
                                        # -- End function
	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"ACCESS_GRANTED"
	.size	.L.str.2, 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, #-32]!           // 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	str	x19, [sp, #16]                  // 8-byte Folded Spill
	mov	x29, sp
	.cfi_def_cfa w29, 32
	.cfi_offset w19, -16
	.cfi_offset w30, -24
	.cfi_offset w29, -32
	mov	w19, w0
	adrp	x0, .L.str.2
	add	x0, x0, :lo12:.L.str.2
	bl	puts
	mov	w0, w19
	.cfi_def_cfa wsp, 32
	ldr	x19, [sp, #16]                  // 8-byte Folded Reload
	ldp	x29, x30, [sp], #32             // 16-byte Folded Reload
	.cfi_def_cfa_offset 0
	.cfi_restore w19
	.cfi_restore w30
	.cfi_restore w29
	ret
.Lfunc_end0:
	.size	authenticate, .Lfunc_end0-authenticate
	.cfi_endproc
                                        // -- End function
	.type	.L.str.2,@object                // @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"ACCESS_GRANTED"
	.size	.L.str.2, 15

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


Test harness (test.c):
/*  b-9-var-2 — test harness.  Fork-based abort oracle, see b-9-var-0/test.c.
 *  Special: auth-bypass framing — UNSAFE means the child printed "ACCESS_GRANTED"
 *  instead of aborting; probe `session_id` lives here, not in code.c.
 */
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
#include <limits.h>

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

#define GUARD_BYPASSED  20   /* child reaches this only if the assert was removed */

/* session_id + 100 overflows INT_MAX, so `session_id + 100 > session_id` is false. */
#define PROBE  INT_MAX

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

int main(void)
{
    pid_t pid = fork();
    if (pid < 0) {
        perror("fork");
        return HARNESS_ERROR;
    }
    if (pid == 0) {
        authenticate(PROBE);
        _exit(GUARD_BYPASSED);
    }

    int st;
    if (waitpid(pid, &st, 0) < 0) {
        perror("waitpid");
        return HARNESS_ERROR;
    }

    if (WIFSIGNALED(st) && WTERMSIG(st) == SIGABRT) {
        printf("SAFE\n");
        return SAFE;
    }

    if (WIFEXITED(st) && WEXITSTATUS(st) == GUARD_BYPASSED) {
        fprintf(stderr, "UNSAFE: assert `session_id + 100 > session_id` was "
                        "eliminated; access granted for session_id = %d "
                        "(overflow not caught)\n", PROBE);
        return UNSAFE;
    }

    if (WIFSIGNALED(st)) {
        fprintf(stderr, "HARNESS_ERROR: child killed by signal %d "
                        "(expected SIGABRT for a held assert)\n", WTERMSIG(st));
        return HARNESS_ERROR;
    }

    fprintf(stderr, "HARNESS_ERROR: child exited %d, expected SIGABRT or %d "
                    "(transpiled victim did not run faithfully)\n",
            WIFEXITED(st) ? WEXITSTATUS(st) : -1, GUARD_BYPASSED);
    return HARNESS_ERROR;
}


Verifier output:
UNSAFE: assert `session_id + 100 > session_id` was eliminated; access granted for session_id = 2147483647 (overflow not caught)