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

    address_t from = AddressFromHex42("0x4a6f6B9fF1fc974096f9063a45Fd12bD5B928AD1");
    uint64_t gas = 62464;
    val_t value;
    value[0] = 0;
    value[1] = 0;
    value[2] = 0;

#define PROGRAM_REVERTSLOAD \
        CALLER, ADDRESS, XOR, PUSH1, 13, JUMPI, \
        PUSH0, SLOAD, MSIZE, MSTORE, \
        MSIZE, PUSH0, REVERT, \
        JUMPDEST, \
        PUSH1, 32, MSIZE, PUSH0, PUSH0, PUSH0, ADDRESS, GAS, CALL, MSIZE, MSTORE, \
        PUSH1, 32, MSIZE, PUSH0, PUSH0, PUSH0, ADDRESS, GAS, CALL, MSIZE, MSTORE, \
        PUSH0, SLOAD, MSIZE, MSTORE, \
        MSIZE, PUSH0, RETURN
    // 333018600d575f545952595ffd5b6020595f5f5f305af159526020595f5f5f305af159525f545952595ff3
    op_t revertTest[] = {
        PROGRAM_REVERTSLOAD
    };
    // 602b8060093d393df3333018600d575f545952595ffd5b6020595f5f5f305af159526020595f5f5f305af159525f545952595ff3
    op_t createRevertTest[] = {
        PUSH1, 43, DUP1, PUSH1, 0x09, RETURNDATASIZE, CODECOPY, RETURNDATASIZE, RETURN,
        PROGRAM_REVERTSLOAD
    };
#undef PROGRAM_REVERTSLOAD
    data_t input;
    input.content = createRevertTest;
    input.size = sizeof(createRevertTest);
    result_t createResult = txCreate(from, gas, value, input);
    assert(UPPER(UPPER(createResult.status)) == 0);
    assert(LOWER(UPPER(createResult.status)) == 0x80d9b122);
    assert(UPPER(LOWER(createResult.status)) == 0xdc3a16fdc41f96cf);
    assert(LOWER(LOWER(createResult.status)) == 0x010ffe7e38d227c3);
    assert(createResult.returnData.size == sizeof(revertTest));
    assert(memcmp(createResult.returnData.content, revertTest, sizeof(revertTest)) == 0);
    assert(createResult.gasRemaining == 0);

    input.size = 0;

    gas = 27655;
    address_t to = AddressFromUint256(&createResult.status);

    result_t sloadRevertResult = txCall(from, gas, to, value, input, NULL);
    assert(UPPER(UPPER(sloadRevertResult.status)) == 0);
    assert(LOWER(UPPER(sloadRevertResult.status)) == 0);
    assert(UPPER(LOWER(sloadRevertResult.status)) == 0);
    assert(LOWER(LOWER(sloadRevertResult.status)) == 1);
    assert(sloadRevertResult.returnData.size == 160);
    for (int i = 0; i < 160; i++) {
        assert(sloadRevertResult.returnData.content[i] == 0);
    }
    assert(sloadRevertResult.gasRemaining == 0);

    evmFinalize();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movb $0x0, %al
callq 0xcfc0
leaq -0x18(%rbp), %rdi
leaq 0x137d7(%rip), %rsi     # 0x1b004
addq $0x2, %rsi
callq 0x3380
movq $0xf400, -0x20(%rbp)    # imm = 0xF400
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x17cf2(%rip), %rsi     # 0x1f550
movl $0x2b, %edx
callq 0x30c0
leaq -0xa0(%rbp), %rdi
leaq 0x17d0a(%rip), %rsi     # 0x1f580
movl $0x34, %edx
callq 0x30c0
leaq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq $0x34, -0xb0(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq -0xb0(%rbp), %rcx
movq -0xa8(%rbp), %r8
leaq -0xf0(%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
cmpq $0x0, -0xe0(%rbp)
jne 0x78e2
jmp 0x7901
leaq 0x13fee(%rip), %rdi     # 0x1b8d7
leaq 0x13760(%rip), %rsi     # 0x1b050
movl $0x542, %edx            # imm = 0x542
leaq 0x14b58(%rip), %rcx     # 0x1c454
callq 0x3040
movl $0x80d9b122, %eax       # imm = 0x80D9B122
cmpq %rax, -0xd8(%rbp)
jne 0x7911
jmp 0x7930
leaq 0x13ffe(%rip), %rdi     # 0x1b916
leaq 0x13731(%rip), %rsi     # 0x1b050
movl $0x543, %edx            # imm = 0x543
leaq 0x14b29(%rip), %rcx     # 0x1c454
callq 0x3040
movabsq $-0x23c5e9023be06931, %rax # imm = 0xDC3A16FDC41F96CF
cmpq %rax, -0xd0(%rbp)
jne 0x7945
jmp 0x7964
leaq 0x13ffa(%rip), %rdi     # 0x1b946
leaq 0x136fd(%rip), %rsi     # 0x1b050
movl $0x544, %edx            # imm = 0x544
leaq 0x14af5(%rip), %rcx     # 0x1c454
callq 0x3040
movabsq $0x10ffe7e38d227c3, %rax # imm = 0x10FFE7E38D227C3
cmpq %rax, -0xc8(%rbp)
jne 0x7979
jmp 0x7998
leaq 0x13ffe(%rip), %rdi     # 0x1b97e
leaq 0x136c9(%rip), %rsi     # 0x1b050
movl $0x545, %edx            # imm = 0x545
leaq 0x14ac1(%rip), %rcx     # 0x1c454
callq 0x3040
cmpq $0x2b, -0xf0(%rbp)
jne 0x79a4
jmp 0x79c3
leaq 0x147de(%rip), %rdi     # 0x1c189
leaq 0x1369e(%rip), %rsi     # 0x1b050
movl $0x546, %edx            # imm = 0x546
leaq 0x14a96(%rip), %rcx     # 0x1c454
callq 0x3040
movq -0xe8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x2b, %edx
callq 0x3090
cmpl $0x0, %eax
jne 0x79df
jmp 0x79fe
leaq 0x147d6(%rip), %rdi     # 0x1c1bc
leaq 0x13663(%rip), %rsi     # 0x1b050
movl $0x547, %edx            # imm = 0x547
leaq 0x14a5b(%rip), %rcx     # 0x1c454
callq 0x3040
cmpq $0x0, -0xc0(%rbp)
jne 0x7a0a
jmp 0x7a29
leaq 0x14013(%rip), %rdi     # 0x1ba24
leaq 0x13638(%rip), %rsi     # 0x1b050
movl $0x548, %edx            # imm = 0x548
leaq 0x14a30(%rip), %rcx     # 0x1c454
callq 0x3040
movq $0x0, -0xb0(%rbp)
movq $0x6c07, -0x20(%rbp)    # imm = 0x6C07
leaq -0xf0(%rbp), %rsi
addq $0x10, %rsi
leaq -0x108(%rbp), %rdi
callq 0x6b50
movq -0x20(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq -0xb0(%rbp), %rcx
movq -0xa8(%rbp), %r8
leaq -0x148(%rbp), %rdi
leaq -0x18(%rbp), %r10
leaq -0x108(%rbp), %rax
xorl %r9d, %r9d
movq (%r10), %r11
movq %r11, (%rsp)
movq 0x8(%r10), %r11
movq %r11, 0x8(%rsp)
movl 0x10(%r10), %r10d
movl %r10d, 0x10(%rsp)
movq (%rax), %r10
movq %r10, 0x18(%rsp)
movq 0x8(%rax), %r10
movq %r10, 0x20(%rsp)
movl 0x10(%rax), %eax
movl %eax, 0x28(%rsp)
callq 0xdaa0
cmpq $0x0, -0x138(%rbp)
jne 0x7ac0
jmp 0x7adf
leaq 0x149a5(%rip), %rdi     # 0x1c46c
leaq 0x13582(%rip), %rsi     # 0x1b050
movl $0x550, %edx            # imm = 0x550
leaq 0x1497a(%rip), %rcx     # 0x1c454
callq 0x3040
cmpq $0x0, -0x130(%rbp)
jne 0x7aeb
jmp 0x7b0a
leaq 0x149a6(%rip), %rdi     # 0x1c498
leaq 0x13557(%rip), %rsi     # 0x1b050
movl $0x551, %edx            # imm = 0x551
leaq 0x1494f(%rip), %rcx     # 0x1c454
callq 0x3040
cmpq $0x0, -0x128(%rbp)
jne 0x7b16
jmp 0x7b35
leaq 0x149a7(%rip), %rdi     # 0x1c4c4
leaq 0x1352c(%rip), %rsi     # 0x1b050
movl $0x552, %edx            # imm = 0x552
leaq 0x14924(%rip), %rcx     # 0x1c454
callq 0x3040
cmpq $0x1, -0x120(%rbp)
jne 0x7b41
jmp 0x7b60
leaq 0x149a8(%rip), %rdi     # 0x1c4f0
leaq 0x13501(%rip), %rsi     # 0x1b050
movl $0x553, %edx            # imm = 0x553
leaq 0x148f9(%rip), %rcx     # 0x1c454
callq 0x3040
cmpq $0xa0, -0x148(%rbp)
jne 0x7b6f
jmp 0x7b8e
leaq 0x149a6(%rip), %rdi     # 0x1c51c
leaq 0x134d3(%rip), %rsi     # 0x1b050
movl $0x554, %edx            # imm = 0x554
leaq 0x148cb(%rip), %rcx     # 0x1c454
callq 0x3040
movl $0x0, -0x14c(%rbp)
cmpl $0xa0, -0x14c(%rbp)
jge 0x7bef
movq -0x140(%rbp), %rax
movslq -0x14c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7bbd
jmp 0x7bdc
leaq 0x14981(%rip), %rdi     # 0x1c545
leaq 0x13485(%rip), %rsi     # 0x1b050
movl $0x556, %edx            # imm = 0x556
leaq 0x1487d(%rip), %rcx     # 0x1c454
callq 0x3040
jmp 0x7bde
movl -0x14c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14c(%rbp)
jmp 0x7b98
cmpq $0x0, -0x118(%rbp)
jne 0x7bfb
jmp 0x7c1a
leaq 0x14970(%rip), %rdi     # 0x1c572
leaq 0x13447(%rip), %rsi     # 0x1b050
movl $0x558, %edx            # imm = 0x558
leaq 0x1483f(%rip), %rcx     # 0x1c454
callq 0x3040
movb $0x0, %al
callq 0xd4d0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw (%rax,%rax)