// File: /workspace/github_c_makefile_star2_O0/wjmelements[P]evm/tst/evm.c
// Function: test_spaghetti
void test_spaghetti() {
    evmInit();

    address_t from = AddressFromHex42("0x4a6f6B9fF1fc974096f9063a45Fd12bD5B928AD1");
    uint64_t gas = 53690;
    val_t value;
    data_t input;

    // 5f5b80156019575859525936fd5b6001565b80600d576001015b8060021160115700
    op_t program[] = {
        PUSH0,
        JUMPDEST,
        DUP1, ISZERO, PUSH1, 0x19, JUMPI,
        PC, MSIZE, MSTORE,
        MSIZE, CALLDATASIZE, REVERT,
        JUMPDEST,
        PUSH1, 0x01, JUMP,
        JUMPDEST,
        DUP1, PUSH1, 0x0d, JUMPI,
        PUSH1, 0x01, ADD,
        JUMPDEST,
        DUP1, PUSH1, 0x02, GT,
        PUSH1, 0x11, JUMPI,
        STOP,
    };

    input.size = sizeof(program);
    input.content = program;

    result_t result = txCreate(from, gas, value, input);
    evmFinalize();
    assert(UPPER(UPPER(result.status)) == 0);
    assert(UPPER(LOWER(result.status)) == 0);
    assert(LOWER(UPPER(result.status)) == 0);
    assert(LOWER(LOWER(result.status)) == 0);
    assert(result.returnData.size == 32);
    for (int i = 0; i < 31; i++) {
        assert(result.returnData.content[i] == 0);
    }
    assert(result.returnData.content[31] == 7);
    assert(result.gasRemaining == 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb $0x0, %al
callq 0xcfc0
leaq -0x18(%rbp), %rdi
leaq 0x163d7(%rip), %rsi     # 0x1b004
addq $0x2, %rsi
callq 0x3380
movq $0xd1ba, -0x20(%rbp)    # imm = 0xD1BA
leaq -0x70(%rbp), %rdi
leaq 0x1ab87(%rip), %rsi     # 0x1f7d0
movl $0x22, %edx
callq 0x30c0
movq $0x22, -0x40(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
leaq -0xb0(%rbp), %rdi
leaq -0x18(%rbp), %rax
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movl 0x10(%rax), %eax
movl %eax, 0x10(%rsp)
callq 0xe270
movb $0x0, %al
callq 0xd4d0
cmpq $0x0, -0xa0(%rbp)
jne 0x4cad
jmp 0x4ccc
leaq 0x1637b(%rip), %rdi     # 0x1b02f
leaq 0x16395(%rip), %rsi     # 0x1b050
movl $0x2fa, %edx            # imm = 0x2FA
leaq 0x16890(%rip), %rcx     # 0x1b557
callq 0x3040
cmpq $0x0, -0x90(%rbp)
jne 0x4cd8
jmp 0x4cf7
leaq 0x1688e(%rip), %rdi     # 0x1b56d
leaq 0x1636a(%rip), %rsi     # 0x1b050
movl $0x2fb, %edx            # imm = 0x2FB
leaq 0x16865(%rip), %rcx     # 0x1b557
callq 0x3040
cmpq $0x0, -0x98(%rbp)
jne 0x4d03
jmp 0x4d22
leaq 0x16884(%rip), %rdi     # 0x1b58e
leaq 0x1633f(%rip), %rsi     # 0x1b050
movl $0x2fc, %edx            # imm = 0x2FC
leaq 0x1683a(%rip), %rcx     # 0x1b557
callq 0x3040
cmpq $0x0, -0x88(%rbp)
jne 0x4d2e
jmp 0x4d4d
leaq 0x1687a(%rip), %rdi     # 0x1b5af
leaq 0x16314(%rip), %rsi     # 0x1b050
movl $0x2fd, %edx            # imm = 0x2FD
leaq 0x1680f(%rip), %rcx     # 0x1b557
callq 0x3040
cmpq $0x20, -0xb0(%rbp)
jne 0x4d59
jmp 0x4d78
leaq 0x163e7(%rip), %rdi     # 0x1b147
leaq 0x162e9(%rip), %rsi     # 0x1b050
movl $0x2fe, %edx            # imm = 0x2FE
leaq 0x167e4(%rip), %rcx     # 0x1b557
callq 0x3040
movl $0x0, -0xb4(%rbp)
cmpl $0x1f, -0xb4(%rbp)
jge 0x4dd6
movq -0xa8(%rbp), %rax
movslq -0xb4(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x4da4
jmp 0x4dc3
leaq 0x16825(%rip), %rdi     # 0x1b5d0
leaq 0x1629e(%rip), %rsi     # 0x1b050
movl $0x300, %edx            # imm = 0x300
leaq 0x16799(%rip), %rcx     # 0x1b557
callq 0x3040
jmp 0x4dc5
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x4d82
movq -0xa8(%rbp), %rax
movzbl 0x1f(%rax), %eax
cmpl $0x7, %eax
jne 0x4de8
jmp 0x4e07
leaq 0x16803(%rip), %rdi     # 0x1b5f2
leaq 0x1625a(%rip), %rsi     # 0x1b050
movl $0x302, %edx            # imm = 0x302
leaq 0x16755(%rip), %rcx     # 0x1b557
callq 0x3040
cmpq $0x0, -0x80(%rbp)
jne 0x4e10
jmp 0x4e2f
leaq 0x162fe(%rip), %rdi     # 0x1b115
leaq 0x16232(%rip), %rsi     # 0x1b050
movl $0x303, %edx            # imm = 0x303
leaq 0x1672d(%rip), %rcx     # 0x1b557
callq 0x3040
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax,%rax)