// File: /workspace/github_c_makefile_star2_O0/wjmelements[P]evm/tst/evm.c
// Function: test_deepCall
void test_deepCall() {
    evmInit();
    // 3d3580600757005b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01805952590259595f34305af1603c57595ffd5b595ff3
#define PROGRAM_DIVE \
    RETURNDATASIZE, CALLDATALOAD, \
    DUP1, PUSH1, 0x07, JUMPI, STOP, JUMPDEST, \
    PUSH32, \
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
    ADD, \
    DUP1, MSIZE, MSTORE, \
    MSIZE, MUL, MSIZE, MSIZE, PUSH0, CALLVALUE, ADDRESS, GAS, CALL, \
    PUSH1, 60, JUMPI, \
    MSIZE, PUSH0, REVERT, \
    JUMPDEST, \
    MSIZE, PUSH0, RETURN

    op_t dive[] = {
        PROGRAM_DIVE
    };
    // 60408060093d393df33d3580600757005b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01805952590259595f34305af1603c57595ffd5b595ff3
    op_t createDive[] = {
        PUSH1, 0x40, DUP1, PUSH1, 0x09, RETURNDATASIZE, CODECOPY, RETURNDATASIZE, RETURN,
        PROGRAM_DIVE
    };

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

    data_t input;
    input.content = createDive;
    input.size = sizeof(createDive);
    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(dive));
    assert(memcmp(createResult.returnData.content, dive, sizeof(dive)) == 0);
    assert(createResult.gasRemaining == 0);

    uint8_t param[32];
    bzero(param, 32);
    param[30] = 0x01;
    param[31] = 0xc8;
    address_t to = AddressFromUint256(&createResult.status);
    gas = 29968466;

    input.content = param;
    input.size = sizeof(param);
    result_t diveResult = txCall(from, gas, to, value, input, NULL);

    assert(UPPER(UPPER(diveResult.status)) == 0);
    assert(LOWER(UPPER(diveResult.status)) == 0);
    assert(UPPER(LOWER(diveResult.status)) == 0);
    assert(LOWER(LOWER(diveResult.status)) == 1);
    assert(diveResult.gasRemaining == 29494085);
    assert(diveResult.returnData.size == 32 * 0x1c8);

    uint256_t expected;
    readu256BE(param, &expected);
    uint256_t one;
    clear256(&one);
    LOWER(LOWER(one)) = 1;
    uint256_t actual;
    uint8_t *current = diveResult.returnData.content;
    while (!zero256(&expected)) {
        minus256(&expected, &one, &expected);
        readu256BE(current, &actual);
        assert(equal256(&expected, &actual));
        current += 32;
    }

    evmFinalize();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movb $0x0, %al
callq 0xcfc0
leaq -0x40(%rbp), %rdi
leaq 0x187b3(%rip), %rsi     # 0x1f420
movl $0x40, %edx
callq 0x30c0
leaq -0x90(%rbp), %rdi
leaq 0x187db(%rip), %rsi     # 0x1f460
movl $0x49, %edx
callq 0x30c0
leaq -0xa8(%rbp), %rdi
leaq 0x14367(%rip), %rsi     # 0x1b004
addq $0x2, %rsi
callq 0x3380
movq $0x105ae, -0xb0(%rbp) # imm = 0x105AE
movl $0x0, -0xbc(%rbp)
movl $0x0, -0xb8(%rbp)
movl $0x0, -0xb4(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq $0x49, -0xd0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0xbc(%rbp), %rdx
movq -0xd0(%rbp), %rcx
movq -0xc8(%rbp), %r8
leaq -0x110(%rbp), %rdi
leaq -0xa8(%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, -0x100(%rbp)
jne 0x6d3a
jmp 0x6d59
leaq 0x14b96(%rip), %rdi     # 0x1b8d7
leaq 0x14308(%rip), %rsi     # 0x1b050
movl $0x4a1, %edx            # imm = 0x4A1
leaq 0x1529a(%rip), %rcx     # 0x1bfee
callq 0x3040
movl $0x80d9b122, %eax       # imm = 0x80D9B122
cmpq %rax, -0xf8(%rbp)
jne 0x6d69
jmp 0x6d88
leaq 0x14ba6(%rip), %rdi     # 0x1b916
leaq 0x142d9(%rip), %rsi     # 0x1b050
movl $0x4a2, %edx            # imm = 0x4A2
leaq 0x1526b(%rip), %rcx     # 0x1bfee
callq 0x3040
movabsq $-0x23c5e9023be06931, %rax # imm = 0xDC3A16FDC41F96CF
cmpq %rax, -0xf0(%rbp)
jne 0x6d9d
jmp 0x6dbc
leaq 0x14ba2(%rip), %rdi     # 0x1b946
leaq 0x142a5(%rip), %rsi     # 0x1b050
movl $0x4a3, %edx            # imm = 0x4A3
leaq 0x15237(%rip), %rcx     # 0x1bfee
callq 0x3040
movabsq $0x10ffe7e38d227c3, %rax # imm = 0x10FFE7E38D227C3
cmpq %rax, -0xe8(%rbp)
jne 0x6dd1
jmp 0x6df0
leaq 0x14ba6(%rip), %rdi     # 0x1b97e
leaq 0x14271(%rip), %rsi     # 0x1b050
movl $0x4a4, %edx            # imm = 0x4A4
leaq 0x15203(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x40, -0x110(%rbp)
jne 0x6dfc
jmp 0x6e1b
leaq 0x15200(%rip), %rdi     # 0x1c003
leaq 0x14246(%rip), %rsi     # 0x1b050
movl $0x4a5, %edx            # imm = 0x4A5
leaq 0x151d8(%rip), %rcx     # 0x1bfee
callq 0x3040
movq -0x108(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0x40, %edx
callq 0x3090
cmpl $0x0, %eax
jne 0x6e37
jmp 0x6e56
leaq 0x151f2(%rip), %rdi     # 0x1c030
leaq 0x1420b(%rip), %rsi     # 0x1b050
movl $0x4a6, %edx            # imm = 0x4A6
leaq 0x1519d(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x0, -0xe0(%rbp)
jne 0x6e62
jmp 0x6e81
leaq 0x14bbb(%rip), %rdi     # 0x1ba24
leaq 0x141e0(%rip), %rsi     # 0x1b050
movl $0x4a7, %edx            # imm = 0x4A7
leaq 0x15172(%rip), %rcx     # 0x1bfee
callq 0x3040
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3060
movb $0x1, -0x112(%rbp)
movb $-0x38, -0x111(%rbp)
leaq -0x110(%rbp), %rsi
addq $0x10, %rsi
leaq -0x148(%rbp), %rdi
callq 0x6b50
movq $0x1c94852, -0xb0(%rbp) # imm = 0x1C94852
leaq -0x130(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq $0x20, -0xd0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0xbc(%rbp), %rdx
movq -0xd0(%rbp), %rcx
movq -0xc8(%rbp), %r8
leaq -0x188(%rbp), %rdi
leaq -0xa8(%rbp), %r10
leaq -0x148(%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, -0x178(%rbp)
jne 0x6f53
jmp 0x6f72
leaq 0x15117(%rip), %rdi     # 0x1c071
leaq 0x140ef(%rip), %rsi     # 0x1b050
movl $0x4b4, %edx            # imm = 0x4B4
leaq 0x15081(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x0, -0x170(%rbp)
jne 0x6f7e
jmp 0x6f9d
leaq 0x15111(%rip), %rdi     # 0x1c096
leaq 0x140c4(%rip), %rsi     # 0x1b050
movl $0x4b5, %edx            # imm = 0x4B5
leaq 0x15056(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x0, -0x168(%rbp)
jne 0x6fa9
jmp 0x6fc8
leaq 0x1510b(%rip), %rdi     # 0x1c0bb
leaq 0x14099(%rip), %rsi     # 0x1b050
movl $0x4b6, %edx            # imm = 0x4B6
leaq 0x1502b(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x1, -0x160(%rbp)
jne 0x6fd4
jmp 0x6ff3
leaq 0x15105(%rip), %rdi     # 0x1c0e0
leaq 0x1406e(%rip), %rsi     # 0x1b050
movl $0x4b7, %edx            # imm = 0x4B7
leaq 0x15000(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x1c20b45, -0x158(%rbp) # imm = 0x1C20B45
jne 0x7002
jmp 0x7021
leaq 0x150fc(%rip), %rdi     # 0x1c105
leaq 0x14040(%rip), %rsi     # 0x1b050
movl $0x4b8, %edx            # imm = 0x4B8
leaq 0x14fd2(%rip), %rcx     # 0x1bfee
callq 0x3040
cmpq $0x3900, -0x188(%rbp) # imm = 0x3900
jne 0x7030
jmp 0x704f
leaq 0x150f2(%rip), %rdi     # 0x1c129
leaq 0x14012(%rip), %rsi     # 0x1b050
movl $0x4b9, %edx            # imm = 0x4B9
leaq 0x14fa4(%rip), %rcx     # 0x1bfee
callq 0x3040
leaq -0x130(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x13ca0
leaq -0x1c8(%rbp), %rdi
callq 0x14020
movq $0x1, -0x1b0(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x13f00
xorb $-0x1, %al
testb $0x1, %al
jne 0x709b
jmp 0x7115
leaq -0x1a8(%rbp), %rdx
leaq -0x1c8(%rbp), %rsi
movq %rdx, %rdi
callq 0x14fb0
movq -0x1f0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x13ca0
leaq -0x1a8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x14b60
testb $0x1, %al
jne 0x70dd
jmp 0x70df
jmp 0x70fe
leaq 0x1506c(%rip), %rdi     # 0x1c152
leaq 0x13f63(%rip), %rsi     # 0x1b050
movl $0x4c5, %edx            # imm = 0x4C5
leaq 0x14ef5(%rip), %rcx     # 0x1bfee
callq 0x3040
movq -0x1f0(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x1f0(%rbp)
jmp 0x7087
movb $0x0, %al
callq 0xd4d0
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopw %cs:(%rax,%rax)