// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
xorl %eax, %eax
callq 0xca4d
movq $-0x2, %r14
leaq 0x38(%rsp), %r15
leaq 0xbbc4(%rip), %r12      # 0x14070
movq 0x15b45(%rip), %r13     # 0x1dff8
leaq 0xec23(%rip), %rbx      # 0x170dd
movzbl 0x4(%r14,%r12), %ecx
leal -0x30(%rcx), %ebp
cmpb $0xa, %bpl
jb 0x84e1
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x84d5
addb $-0x57, %cl
jmp 0x84df
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x851f
addb $-0x37, %cl
movl %ecx, %ebp
movzbl 0x5(%r14,%r12), %ecx
leal -0x30(%rcx), %eax
cmpb $0xa, %al
jb 0x8506
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x84fa
addb $-0x57, %cl
jmp 0x8504
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x8534
addb $-0x37, %cl
movl %ecx, %eax
shlb $0x4, %bpl
addb %al, %bpl
movb %bpl, (%r15)
addq $0x2, %r14
incq %r15
cmpq $0x26, %r14
jb 0x84ba
jmp 0x8548
movq (%r13), %rdi
movq %rbx, %rsi
movl %ecx, %edx
xorl %eax, %eax
callq 0x30a0
movb $-0x1, %bpl
jmp 0x84e1
movq (%r13), %rdi
movq %rbx, %rsi
movl %ecx, %edx
xorl %eax, %eax
callq 0x30a0
movb $-0x1, %al
jmp 0x8506
leaq 0x64(%rsp), %rdx
movq $0x0, (%rdx)
movl $0x0, 0x8(%rdx)
movaps 0x1009e(%rip), %xmm0    # 0x18600
leaq 0xf0(%rsp), %r8
movaps %xmm0, 0x20(%r8)
movaps 0x1007a(%rip), %xmm0    # 0x185f0
movaps %xmm0, 0x10(%r8)
movaps 0x1005e(%rip), %xmm0    # 0x185e0
movaps %xmm0, (%r8)
movl $0xf35f5952, 0x30(%r8)  # imm = 0xF35F5952
movl 0x48(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xb0(%rsp), %rbx
movl $0xf400, %esi           # imm = 0xF400
movl $0x34, %ecx
movq %rbx, %rdi
callq 0xd683
cmpq $0x0, 0x10(%rbx)
jne 0x8748
movl $0x80d9b122, %eax       # imm = 0x80D9B122
cmpq %rax, 0xc8(%rsp)
jne 0x8767
movabsq $-0x23c5e9023be06931, %rax # imm = 0xDC3A16FDC41F96CF
cmpq %rax, 0xd0(%rsp)
jne 0x8786
movabsq $0x10ffe7e38d227c3, %rax # imm = 0x10FFE7E38D227C3
cmpq %rax, 0xd8(%rsp)
jne 0x87a5
cmpq $0x2b, 0xb0(%rsp)
jne 0x87c4
movq 0xb8(%rsp), %rdi
leaq 0xff8b(%rip), %rsi      # 0x185b0
movl $0x2b, %edx
callq 0x30d0
testl %eax, %eax
jne 0x87e3
cmpq $0x0, 0xe0(%rsp)
jne 0x8802
movaps 0xb9e3(%rip), %xmm0     # 0x14030
movaps %xmm0, 0x50(%rsp)
movl $0xc327d238, 0x60(%rsp) # imm = 0xC327D238
movl 0x60(%rsp), %eax
movl %eax, 0x28(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movl 0x48(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x70(%rsp), %rbx
leaq 0x64(%rsp), %rdx
leaq 0xf0(%rsp), %r8
movl $0x6c07, %esi           # imm = 0x6C07
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0xd126
cmpq $0x0, 0x10(%rbx)
jne 0x8821
cmpq $0x0, 0x88(%rsp)
jne 0x8840
cmpq $0x0, 0x90(%rsp)
jne 0x885f
cmpq $0x1, 0x98(%rsp)
jne 0x887e
cmpq $0xa0, 0x70(%rsp)
jne 0x889d
movq 0x78(%rsp), %rax
xorl %ecx, %ecx
cmpb $0x0, (%rax,%rcx)
jne 0x8729
incq %rcx
cmpq $0xa0, %rcx
jne 0x86ef
cmpq $0x0, 0xa0(%rsp)
jne 0x88bc
xorl %eax, %eax
callq 0xcd49
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xce81(%rip), %rdi      # 0x155b1
leaq 0xb985(%rip), %rsi      # 0x140bc
leaq 0xcd82(%rip), %rcx      # 0x154c0
movl $0x556, %edx            # imm = 0x556
callq 0x3040
leaq 0xc1f4(%rip), %rdi      # 0x14943
leaq 0xb966(%rip), %rsi      # 0x140bc
leaq 0xcd63(%rip), %rcx      # 0x154c0
movl $0x542, %edx            # imm = 0x542
callq 0x3040
leaq 0xc214(%rip), %rdi      # 0x14982
leaq 0xb947(%rip), %rsi      # 0x140bc
leaq 0xcd44(%rip), %rcx      # 0x154c0
movl $0x543, %edx            # imm = 0x543
callq 0x3040
leaq 0xc225(%rip), %rdi      # 0x149b2
leaq 0xb928(%rip), %rsi      # 0x140bc
leaq 0xcd25(%rip), %rcx      # 0x154c0
movl $0x544, %edx            # imm = 0x544
callq 0x3040
leaq 0xc23e(%rip), %rdi      # 0x149ea
leaq 0xb909(%rip), %rsi      # 0x140bc
leaq 0xcd06(%rip), %rcx      # 0x154c0
movl $0x545, %edx            # imm = 0x545
callq 0x3040
leaq 0xca2a(%rip), %rdi      # 0x151f5
leaq 0xb8ea(%rip), %rsi      # 0x140bc
leaq 0xcce7(%rip), %rcx      # 0x154c0
movl $0x546, %edx            # imm = 0x546
callq 0x3040
leaq 0xca3e(%rip), %rdi      # 0x15228
leaq 0xb8cb(%rip), %rsi      # 0x140bc
leaq 0xccc8(%rip), %rcx      # 0x154c0
movl $0x547, %edx            # imm = 0x547
callq 0x3040
leaq 0xc287(%rip), %rdi      # 0x14a90
leaq 0xb8ac(%rip), %rsi      # 0x140bc
leaq 0xcca9(%rip), %rcx      # 0x154c0
movl $0x548, %edx            # imm = 0x548
callq 0x3040
leaq 0xccb0(%rip), %rdi      # 0x154d8
leaq 0xb88d(%rip), %rsi      # 0x140bc
leaq 0xcc8a(%rip), %rcx      # 0x154c0
movl $0x550, %edx            # imm = 0x550
callq 0x3040
leaq 0xccbd(%rip), %rdi      # 0x15504
leaq 0xb86e(%rip), %rsi      # 0x140bc
leaq 0xcc6b(%rip), %rcx      # 0x154c0
movl $0x551, %edx            # imm = 0x551
callq 0x3040
leaq 0xccca(%rip), %rdi      # 0x15530
leaq 0xb84f(%rip), %rsi      # 0x140bc
leaq 0xcc4c(%rip), %rcx      # 0x154c0
movl $0x552, %edx            # imm = 0x552
callq 0x3040
leaq 0xccd7(%rip), %rdi      # 0x1555c
leaq 0xb830(%rip), %rsi      # 0x140bc
leaq 0xcc2d(%rip), %rcx      # 0x154c0
movl $0x553, %edx            # imm = 0x553
callq 0x3040
leaq 0xcce4(%rip), %rdi      # 0x15588
leaq 0xb811(%rip), %rsi      # 0x140bc
leaq 0xcc0e(%rip), %rcx      # 0x154c0
movl $0x554, %edx            # imm = 0x554
callq 0x3040
leaq 0xcd1b(%rip), %rdi      # 0x155de
leaq 0xb7f2(%rip), %rsi      # 0x140bc
leaq 0xcbef(%rip), %rcx      # 0x154c0
movl $0x558, %edx            # imm = 0x558
callq 0x3040