// File: /workspace/github_c_makefile_star2_O2/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 %rbx
subq $0x130, %rsp            # imm = 0x130
xorl %eax, %eax
callq 0xaa8d
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x332c
leaq 0x34(%rsp), %rdx
andq $0x0, (%rdx)
andl $0x0, 0x8(%rdx)
movaps 0xec59(%rip), %xmm0     # 0x155a0
leaq 0xf0(%rsp), %r8
movaps %xmm0, 0x20(%r8)
movaps 0xec35(%rip), %xmm0     # 0x15590
movaps %xmm0, 0x10(%r8)
movaps 0xec19(%rip), %xmm0     # 0x15580
movaps %xmm0, (%r8)
movl $0xf35f5952, 0x30(%r8)  # imm = 0xF35F5952
movl 0x10(%rbx), %eax
movl %eax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %rbx
pushq $0x34
popq %rcx
movl $0xf400, %esi           # imm = 0xF400
movq %rbx, %rdi
callq 0xb68f
cmpq $0x0, 0x10(%rbx)
jne 0x6b16
movl $0x80d9b122, %eax       # imm = 0x80D9B122
cmpq %rax, 0x70(%rsp)
jne 0x6b35
movabsq $-0x23c5e9023be06931, %rax # imm = 0xDC3A16FDC41F96CF
cmpq %rax, 0x78(%rsp)
jne 0x6b54
movabsq $0x10ffe7e38d227c3, %rax # imm = 0x10FFE7E38D227C3
cmpq %rax, 0x80(%rsp)
jne 0x6b73
cmpq $0x2b, 0x58(%rsp)
jne 0x6b92
movq 0x60(%rsp), %rdi
leaq 0xeb5a(%rip), %rsi      # 0x15550
pushq $0x2b
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x6bb1
cmpq $0x0, 0x88(%rsp)
jne 0x6bd0
leaq 0x68(%rsp), %rsi
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0x5fbc
movl 0x10(%rbx), %eax
movl %eax, 0x28(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x18(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x98(%rsp), %rbx
leaq 0x34(%rsp), %rdx
leaq 0xf0(%rsp), %r8
movl $0x6c07, %esi           # imm = 0x6C07
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0xb135
cmpq $0x0, 0x10(%rbx)
jne 0x6bef
cmpq $0x0, 0xb0(%rsp)
jne 0x6c0e
cmpq $0x0, 0xb8(%rsp)
jne 0x6c2d
cmpq $0x1, 0xc0(%rsp)
jne 0x6c4c
cmpq $0xa0, 0x98(%rsp)
jne 0x6c6b
movq 0xa0(%rsp), %rax
xorl %ecx, %ecx
cmpq $0xa0, %rcx
je 0x6af7
cmpb $0x0, (%rax,%rcx)
leaq 0x1(%rcx), %rcx
je 0x6ac5
leaq 0xba66(%rip), %rdi      # 0x12545
leaq 0xa56a(%rip), %rsi      # 0x11050
leaq 0xb967(%rip), %rcx      # 0x12454
movl $0x556, %edx            # imm = 0x556
callq 0x3040
cmpq $0x0, 0xc8(%rsp)
jne 0x6c8a
xorl %eax, %eax
callq 0xada8
addq $0x130, %rsp            # imm = 0x130
popq %rbx
retq
leaq 0xadba(%rip), %rdi      # 0x118d7
leaq 0xa52c(%rip), %rsi      # 0x11050
leaq 0xb929(%rip), %rcx      # 0x12454
movl $0x542, %edx            # imm = 0x542
callq 0x3040
leaq 0xadda(%rip), %rdi      # 0x11916
leaq 0xa50d(%rip), %rsi      # 0x11050
leaq 0xb90a(%rip), %rcx      # 0x12454
movl $0x543, %edx            # imm = 0x543
callq 0x3040
leaq 0xadeb(%rip), %rdi      # 0x11946
leaq 0xa4ee(%rip), %rsi      # 0x11050
leaq 0xb8eb(%rip), %rcx      # 0x12454
movl $0x544, %edx            # imm = 0x544
callq 0x3040
leaq 0xae04(%rip), %rdi      # 0x1197e
leaq 0xa4cf(%rip), %rsi      # 0x11050
leaq 0xb8cc(%rip), %rcx      # 0x12454
movl $0x545, %edx            # imm = 0x545
callq 0x3040
leaq 0xb5f0(%rip), %rdi      # 0x12189
leaq 0xa4b0(%rip), %rsi      # 0x11050
leaq 0xb8ad(%rip), %rcx      # 0x12454
movl $0x546, %edx            # imm = 0x546
callq 0x3040
leaq 0xb604(%rip), %rdi      # 0x121bc
leaq 0xa491(%rip), %rsi      # 0x11050
leaq 0xb88e(%rip), %rcx      # 0x12454
movl $0x547, %edx            # imm = 0x547
callq 0x3040
leaq 0xae4d(%rip), %rdi      # 0x11a24
leaq 0xa472(%rip), %rsi      # 0x11050
leaq 0xb86f(%rip), %rcx      # 0x12454
movl $0x548, %edx            # imm = 0x548
callq 0x3040
leaq 0xb876(%rip), %rdi      # 0x1246c
leaq 0xa453(%rip), %rsi      # 0x11050
leaq 0xb850(%rip), %rcx      # 0x12454
movl $0x550, %edx            # imm = 0x550
callq 0x3040
leaq 0xb883(%rip), %rdi      # 0x12498
leaq 0xa434(%rip), %rsi      # 0x11050
leaq 0xb831(%rip), %rcx      # 0x12454
movl $0x551, %edx            # imm = 0x551
callq 0x3040
leaq 0xb890(%rip), %rdi      # 0x124c4
leaq 0xa415(%rip), %rsi      # 0x11050
leaq 0xb812(%rip), %rcx      # 0x12454
movl $0x552, %edx            # imm = 0x552
callq 0x3040
leaq 0xb89d(%rip), %rdi      # 0x124f0
leaq 0xa3f6(%rip), %rsi      # 0x11050
leaq 0xb7f3(%rip), %rcx      # 0x12454
movl $0x553, %edx            # imm = 0x553
callq 0x3040
leaq 0xb8aa(%rip), %rdi      # 0x1251c
leaq 0xa3d7(%rip), %rsi      # 0x11050
leaq 0xb7d4(%rip), %rcx      # 0x12454
movl $0x554, %edx            # imm = 0x554
callq 0x3040
leaq 0xb8e1(%rip), %rdi      # 0x12572
leaq 0xa3b8(%rip), %rsi      # 0x11050
leaq 0xb7b5(%rip), %rcx      # 0x12454
movl $0x558, %edx            # imm = 0x558
callq 0x3040