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


    // 363d3d37363df3
#define PROGRAM_ECHO \
        CALLDATASIZE, RETURNDATASIZE, RETURNDATASIZE, CALLDATACOPY, \
        CALLDATASIZE, RETURNDATASIZE, RETURN
    op_t echo[] = {
        PROGRAM_ECHO
    };
    // 66363d3d37363df33d5260076019f3
    op_t createEcho[] = {
        PUSH7, PROGRAM_ECHO, RETURNDATASIZE, MSTORE,
        PUSH1, 7, PUSH1, 25, RETURN
    };
#undef PROGRAM_ECHO
    address_t from = AddressFromHex42("0x4a6f6B9fF1fc974096f9063a45Fd12bD5B928AD1");
    uint64_t gas = 54659;
    val_t value;
    value[0] = 0;
    value[1] = 0;
    value[2] = 0;

    data_t input;
    input.content = createEcho;
    input.size = sizeof(createEcho);

    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(echo));
    assert(memcmp(createResult.returnData.content, echo, sizeof(echo)) == 0);
    assert(createResult.gasRemaining == 0);

    gas = 57035;
    // 385952385f59395f353b5f595f353c595ff3
#define PROGRAM_EXTCODECOPY \
    CODESIZE, MSIZE, MSTORE, \
    CODESIZE, PUSH0, MSIZE, CODECOPY, \
    PUSH0, CALLDATALOAD, EXTCODESIZE, PUSH0, MSIZE, PUSH0, CALLDATALOAD, EXTCODECOPY, \
    MSIZE, PUSH0, RETURN
    op_t extcodecopy[] = {
        PROGRAM_EXTCODECOPY
    };
    // 71385952385f59395f353b5f595f353c595ff33d526012600ef3
    op_t createExtCodeCopy[] = {
        PUSH18, PROGRAM_EXTCODECOPY,
        RETURNDATASIZE, MSTORE,
        PUSH1, 18, PUSH1, 14, RETURN
    };
#undef PROGRAM_EXTCODECOPY
    input.size = sizeof(createExtCodeCopy);
    input.content = createExtCodeCopy;
    result_t secondCreateResult = txCreate(from, gas, value, input);
    assert(memcmp(secondCreateResult.returnData.content, extcodecopy, sizeof(extcodecopy)) == 0);
    assert(UPPER(UPPER(secondCreateResult.status)) == 0);
    assert(LOWER(UPPER(secondCreateResult.status)) == 0x47784b21);
    assert(UPPER(LOWER(secondCreateResult.status)) == 0x780d1e1d5efcd005);
    assert(LOWER(LOWER(secondCreateResult.status)) == 0xc5fe542813b6d71e);
    assert(secondCreateResult.gasRemaining == 0);

    // ensure upper bytes of upcoming calldata are zero
    address_t locations[4];
    bzero(locations, sizeof(locations));
    address_t echoAddress = locations[1] = AddressFromUint256(&createResult.status);
    address_t extcodecopyAddress = locations[3] = AddressFromUint256(&secondCreateResult.status);

    address_t to = extcodecopyAddress;

    input.size = 32;

    gas = 24117;
    input.content = locations[1].address - 12;
    result_t examineFirstAccount = txCall(from, gas, to, value, input, NULL);
    assert(UPPER(UPPER(examineFirstAccount.status)) == 0);
    assert(LOWER(UPPER(examineFirstAccount.status)) == 0);
    assert(UPPER(LOWER(examineFirstAccount.status)) == 0);
    assert(LOWER(LOWER(examineFirstAccount.status)) == 1);
    assert(examineFirstAccount.returnData.size == 96);
    for (int i = 0; i < 31; i++) {
        assert(examineFirstAccount.returnData.content[i] == 0);
    }
    assert(examineFirstAccount.returnData.content[31] == sizeof(extcodecopy));
    assert(memcmp(examineFirstAccount.returnData.content+32, extcodecopy, sizeof(extcodecopy)) == 0);
    for (int i = 32 + sizeof(extcodecopy); i < 64; i++) {
        assert(examineFirstAccount.returnData.content[i] == 0);
    }
    assert(memcmp(examineFirstAccount.returnData.content+64, echo, sizeof(echo)) == 0);
    for (int i = 64 + sizeof(echo); i < 96; i++) {
        assert(examineFirstAccount.returnData.content[i] == 0);
    }
    assert(examineFirstAccount.gasRemaining == 0);

    gas = 21617;
    input.content = locations[3].address - 12;
    result_t examineSecondAccount = txCall(from, gas, to, value, input, NULL);
    assert(UPPER(UPPER(examineSecondAccount.status)) == 0);
    assert(LOWER(UPPER(examineSecondAccount.status)) == 0);
    assert(UPPER(LOWER(examineSecondAccount.status)) == 0);
    assert(LOWER(LOWER(examineSecondAccount.status)) == 1);
    assert(examineSecondAccount.returnData.size == 96);
    for (int i = 0; i < 31; i++) {
        assert(examineSecondAccount.returnData.content[i] == 0);
    }
    assert(examineSecondAccount.returnData.content[31] == sizeof(extcodecopy));
    assert(memcmp(examineSecondAccount.returnData.content+32, extcodecopy, sizeof(extcodecopy)) == 0);
    for (int i = 32 + sizeof(extcodecopy); i < 64; i++) {
        assert(examineSecondAccount.returnData.content[i] == 0);
    }
    assert(memcmp(examineSecondAccount.returnData.content+64, extcodecopy, sizeof(extcodecopy)) == 0);
    for (int i = 64 + sizeof(extcodecopy); i < 96; i++) {
        assert(examineSecondAccount.returnData.content[i] == 0);
    }
    assert(examineSecondAccount.gasRemaining == 0);

    evmFinalize();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
xorl %eax, %eax
callq 0xaa8d
movabsq $-0xce69ff89fadc20d, %rax # imm = 0xF319600760523DF3
leaq 0x170(%rsp), %rbx
movq %rax, 0x7(%rbx)
movabsq $-0xcc2c9c8c2c2c99a, %rax # imm = 0xF33D36373D3D3666
movq %rax, (%rbx)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x332c
leaq 0x44(%rsp), %rdx
andq $0x0, (%rdx)
andl $0x0, 0x8(%rdx)
movl 0x10(%r14), %eax
movl %eax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
leaq 0x70(%rsp), %r14
pushq $0xf
popq %rcx
movl $0xd583, %esi           # imm = 0xD583
movq %r14, %rdi
movq %rbx, %r8
callq 0xb68f
cmpq $0x0, 0x10(%r14)
jne 0x5bfb
movl $0x80d9b122, %eax       # imm = 0x80D9B122
cmpq %rax, 0x88(%rsp)
jne 0x5c1a
movabsq $-0x23c5e9023be06931, %rax # imm = 0xDC3A16FDC41F96CF
cmpq %rax, 0x90(%rsp)
jne 0x5c39
movabsq $0x10ffe7e38d227c3, %rax # imm = 0x10FFE7E38D227C3
cmpq %rax, 0x98(%rsp)
jne 0x5c58
cmpq $0x7, 0x70(%rsp)
jne 0x5c77
movq 0x78(%rsp), %rdi
leaq 0xfc0e(%rip), %rsi      # 0x153bc
pushq $0x7
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x5c96
cmpq $0x0, 0xa0(%rsp)
jne 0x5cb5
movups 0xfc36(%rip), %xmm0     # 0x1540a
leaq 0x1d0(%rsp), %r8
movups %xmm0, 0xa(%r8)
movaps 0xfc18(%rip), %xmm0     # 0x15400
movaps %xmm0, (%r8)
movl 0x40(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x130(%rsp), %rbx
leaq 0x44(%rsp), %rdx
pushq $0x1a
popq %rcx
movl $0xdecb, %esi           # imm = 0xDECB
movq %rbx, %rdi
callq 0xb68f
movq 0x8(%rbx), %rdi
leaq 0xfbbb(%rip), %rsi      # 0x153e0
pushq $0x12
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x5cd4
cmpq $0x0, 0x140(%rsp)
jne 0x5cf3
cmpq $0x47784b21, 0x148(%rsp) # imm = 0x47784B21
jne 0x5d12
movabsq $0x780d1e1d5efcd005, %rax # imm = 0x780D1E1D5EFCD005
cmpq %rax, 0x150(%rsp)
jne 0x5d31
movabsq $-0x3a01abd7ec4928e2, %rax # imm = 0xC5FE542813B6D71E
cmpq %rax, 0x158(%rsp)
jne 0x5d50
cmpq $0x0, 0x160(%rsp)
jne 0x5d6f
leaq 0x80(%rsp), %rsi
leaq 0x140(%rsp), %rbx
xorps %xmm0, %xmm0
leaq 0x194(%rsp), %rdi
movaps %xmm0, 0x2c(%rdi)
movaps %xmm0, 0x1c(%rdi)
movaps %xmm0, 0xc(%rdi)
movaps %xmm0, -0x4(%rdi)
movaps %xmm0, -0x14(%rdi)
callq 0x5fbc
leaq 0x1bc(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5fbc
movl 0x10(%r14), %eax
movl %eax, 0x60(%rsp)
movups (%r14), %xmm0
movaps %xmm0, 0x50(%rsp)
leaq 0x188(%rsp), %r8
movl 0x60(%rsp), %eax
movl %eax, 0x28(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movl 0x40(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xf0(%rsp), %rbx
leaq 0x44(%rsp), %rdx
pushq $0x20
popq %rcx
movl $0x5e35, %esi           # imm = 0x5E35
movq %rbx, %rdi
xorl %r9d, %r9d
callq 0xb135
cmpq $0x0, 0x10(%rbx)
jne 0x5d8e
cmpq $0x0, 0x108(%rsp)
jne 0x5dad
cmpq $0x0, 0x110(%rsp)
jne 0x5dcc
cmpq $0x1, 0x118(%rsp)
jne 0x5deb
cmpq $0x60, 0xf0(%rsp)
jne 0x5e0a
movq 0xf8(%rsp), %rbx
xorl %eax, %eax
cmpq $0x1f, %rax
je 0x59b8
cmpb $0x0, (%rbx,%rax)
leaq 0x1(%rax), %rax
je 0x5989
leaq 0xc2de(%rip), %rdi      # 0x11c7e
leaq 0xb6a9(%rip), %rsi      # 0x11050
leaq 0xbf50(%rip), %rcx      # 0x118fe
movl $0x454, %edx            # imm = 0x454
callq 0x3040
cmpb $0x12, 0x1f(%rbx)
jne 0x5e29
leaq 0x20(%rbx), %rdi
leaq 0xfa13(%rip), %rsi      # 0x153e0
pushq $0x12
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x5e48
pushq $-0xe
popq %rax
testq %rax, %rax
je 0x5a0f
cmpb $0x0, 0x40(%rbx,%rax)
leaq 0x1(%rax), %rax
je 0x59e0
leaq 0xc287(%rip), %rdi      # 0x11c7e
leaq 0xb652(%rip), %rsi      # 0x11050
leaq 0xbef9(%rip), %rcx      # 0x118fe
movl $0x459, %edx            # imm = 0x459
callq 0x3040
leaq 0x40(%rbx), %rdi
leaq 0xf9a2(%rip), %rsi      # 0x153bc
pushq $0x7
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x5e67
pushq $-0x19
popq %rax
testq %rax, %rax
je 0x5a5c
cmpb $0x0, 0x60(%rbx,%rax)
leaq 0x1(%rax), %rax
je 0x5a2d
leaq 0xc23a(%rip), %rdi      # 0x11c7e
leaq 0xb605(%rip), %rsi      # 0x11050
leaq 0xbeac(%rip), %rcx      # 0x118fe
movl $0x45d, %edx            # imm = 0x45D
callq 0x3040
cmpq $0x0, 0x120(%rsp)
jne 0x5e86
leaq 0x1b0(%rsp), %r8
movl 0x60(%rsp), %eax
movl %eax, 0x28(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movl 0x40(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xb0(%rsp), %rbx
leaq 0x44(%rsp), %rdx
pushq $0x20
popq %rcx
movl $0x5471, %esi           # imm = 0x5471
movq %rbx, %rdi
xorl %r9d, %r9d
callq 0xb135
cmpq $0x0, 0x10(%rbx)
jne 0x5ea5
cmpq $0x0, 0xc8(%rsp)
jne 0x5ec4
cmpq $0x0, 0xd0(%rsp)
jne 0x5ee3
cmpq $0x1, 0xd8(%rsp)
jne 0x5f02
cmpq $0x60, 0xb0(%rsp)
jne 0x5f21
movq 0xb8(%rsp), %rbx
xorl %eax, %eax
cmpq $0x1f, %rax
je 0x5b36
cmpb $0x0, (%rbx,%rax)
leaq 0x1(%rax), %rax
je 0x5b07
leaq 0xc382(%rip), %rdi      # 0x11ea0
leaq 0xb52b(%rip), %rsi      # 0x11050
leaq 0xbdd2(%rip), %rcx      # 0x118fe
movl $0x46a, %edx            # imm = 0x46A
callq 0x3040
cmpb $0x12, 0x1f(%rbx)
jne 0x5f40
leaq 0x20(%rbx), %rdi
leaq 0xf895(%rip), %rsi      # 0x153e0
pushq $0x12
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x5f5f
pushq $-0xe
popq %rax
testq %rax, %rax
je 0x5b8d
cmpb $0x0, 0x40(%rbx,%rax)
leaq 0x1(%rax), %rax
je 0x5b5e
leaq 0xc32b(%rip), %rdi      # 0x11ea0
leaq 0xb4d4(%rip), %rsi      # 0x11050
leaq 0xbd7b(%rip), %rcx      # 0x118fe
movl $0x46f, %edx            # imm = 0x46F
callq 0x3040
leaq 0x40(%rbx), %rdi
leaq 0xf848(%rip), %rsi      # 0x153e0
pushq $0x12
popq %rdx
callq 0x30d0
testl %eax, %eax
jne 0x5f7e
pushq $-0xe
popq %rax
testq %rax, %rax
je 0x5bda
cmpb $0x0, 0x60(%rbx,%rax)
leaq 0x1(%rax), %rax
je 0x5bab
leaq 0xc2de(%rip), %rdi      # 0x11ea0
leaq 0xb487(%rip), %rsi      # 0x11050
leaq 0xbd2e(%rip), %rcx      # 0x118fe
movl $0x473, %edx            # imm = 0x473
callq 0x3040
cmpq $0x0, 0xe0(%rsp)
jne 0x5f9d
xorl %eax, %eax
callq 0xada8
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r14
retq
leaq 0xbcd5(%rip), %rdi      # 0x118d7
leaq 0xb447(%rip), %rsi      # 0x11050
leaq 0xbcee(%rip), %rcx      # 0x118fe
movl $0x41e, %edx            # imm = 0x41E
callq 0x3040
leaq 0xbcf5(%rip), %rdi      # 0x11916
leaq 0xb428(%rip), %rsi      # 0x11050
leaq 0xbccf(%rip), %rcx      # 0x118fe
movl $0x41f, %edx            # imm = 0x41F
callq 0x3040
leaq 0xbd06(%rip), %rdi      # 0x11946
leaq 0xb409(%rip), %rsi      # 0x11050
leaq 0xbcb0(%rip), %rcx      # 0x118fe
movl $0x420, %edx            # imm = 0x420
callq 0x3040
leaq 0xbd1f(%rip), %rdi      # 0x1197e
leaq 0xb3ea(%rip), %rsi      # 0x11050
leaq 0xbc91(%rip), %rcx      # 0x118fe
movl $0x421, %edx            # imm = 0x421
callq 0x3040
leaq 0xbd38(%rip), %rdi      # 0x119b6
leaq 0xb3cb(%rip), %rsi      # 0x11050
leaq 0xbc72(%rip), %rcx      # 0x118fe
movl $0x422, %edx            # imm = 0x422
callq 0x3040
leaq 0xbd46(%rip), %rdi      # 0x119e3
leaq 0xb3ac(%rip), %rsi      # 0x11050
leaq 0xbc53(%rip), %rcx      # 0x118fe
movl $0x423, %edx            # imm = 0x423
callq 0x3040
leaq 0xbd68(%rip), %rdi      # 0x11a24
leaq 0xb38d(%rip), %rsi      # 0x11050
leaq 0xbc34(%rip), %rcx      # 0x118fe
movl $0x424, %edx            # imm = 0x424
callq 0x3040
leaq 0xbd68(%rip), %rdi      # 0x11a43
leaq 0xb36e(%rip), %rsi      # 0x11050
leaq 0xbc15(%rip), %rcx      # 0x118fe
movl $0x43a, %edx            # imm = 0x43A
callq 0x3040
leaq 0xbd9e(%rip), %rdi      # 0x11a98
leaq 0xb34f(%rip), %rsi      # 0x11050
leaq 0xbbf6(%rip), %rcx      # 0x118fe
movl $0x43b, %edx            # imm = 0x43B
callq 0x3040
leaq 0xbdac(%rip), %rdi      # 0x11ac5
leaq 0xb330(%rip), %rsi      # 0x11050
leaq 0xbbd7(%rip), %rcx      # 0x118fe
movl $0x43c, %edx            # imm = 0x43C
callq 0x3040
leaq 0xbdc3(%rip), %rdi      # 0x11afb
leaq 0xb311(%rip), %rsi      # 0x11050
leaq 0xbbb8(%rip), %rcx      # 0x118fe
movl $0x43d, %edx            # imm = 0x43D
callq 0x3040
leaq 0xbde2(%rip), %rdi      # 0x11b39
leaq 0xb2f2(%rip), %rsi      # 0x11050
leaq 0xbb99(%rip), %rcx      # 0x118fe
movl $0x43e, %edx            # imm = 0x43E
callq 0x3040
leaq 0xbe01(%rip), %rdi      # 0x11b77
leaq 0xb2d3(%rip), %rsi      # 0x11050
leaq 0xbb7a(%rip), %rcx      # 0x118fe
movl $0x43f, %edx            # imm = 0x43F
callq 0x3040
leaq 0xbe07(%rip), %rdi      # 0x11b9c
leaq 0xb2b4(%rip), %rsi      # 0x11050
leaq 0xbb5b(%rip), %rcx      # 0x118fe
movl $0x44e, %edx            # imm = 0x44E
callq 0x3040
leaq 0xbe16(%rip), %rdi      # 0x11bca
leaq 0xb295(%rip), %rsi      # 0x11050
leaq 0xbb3c(%rip), %rcx      # 0x118fe
movl $0x44f, %edx            # imm = 0x44F
callq 0x3040
leaq 0xbe25(%rip), %rdi      # 0x11bf8
leaq 0xb276(%rip), %rsi      # 0x11050
leaq 0xbb1d(%rip), %rcx      # 0x118fe
movl $0x450, %edx            # imm = 0x450
callq 0x3040
leaq 0xbe34(%rip), %rdi      # 0x11c26
leaq 0xb257(%rip), %rsi      # 0x11050
leaq 0xbafe(%rip), %rcx      # 0x118fe
movl $0x451, %edx            # imm = 0x451
callq 0x3040
leaq 0xbe43(%rip), %rdi      # 0x11c54
leaq 0xb238(%rip), %rsi      # 0x11050
leaq 0xbadf(%rip), %rcx      # 0x118fe
movl $0x452, %edx            # imm = 0x452
callq 0x3040
leaq 0xbe7d(%rip), %rdi      # 0x11cad
leaq 0xb219(%rip), %rsi      # 0x11050
leaq 0xbac0(%rip), %rcx      # 0x118fe
movl $0x456, %edx            # imm = 0x456
callq 0x3040
leaq 0xbea0(%rip), %rdi      # 0x11cef
leaq 0xb1fa(%rip), %rsi      # 0x11050
leaq 0xbaa1(%rip), %rcx      # 0x118fe
movl $0x457, %edx            # imm = 0x457
callq 0x3040
leaq 0xbeda(%rip), %rdi      # 0x11d48
leaq 0xb1db(%rip), %rsi      # 0x11050
leaq 0xba82(%rip), %rcx      # 0x118fe
movl $0x45b, %edx            # imm = 0x45B
callq 0x3040
leaq 0xbf06(%rip), %rdi      # 0x11d93
leaq 0xb1bc(%rip), %rsi      # 0x11050
leaq 0xba63(%rip), %rcx      # 0x118fe
movl $0x45f, %edx            # imm = 0x45F
callq 0x3040
leaq 0xbf0d(%rip), %rdi      # 0x11db9
leaq 0xb19d(%rip), %rsi      # 0x11050
leaq 0xba44(%rip), %rcx      # 0x118fe
movl $0x464, %edx            # imm = 0x464
callq 0x3040
leaq 0xbf1d(%rip), %rdi      # 0x11de8
leaq 0xb17e(%rip), %rsi      # 0x11050
leaq 0xba25(%rip), %rcx      # 0x118fe
movl $0x465, %edx            # imm = 0x465
callq 0x3040
leaq 0xbf2d(%rip), %rdi      # 0x11e17
leaq 0xb15f(%rip), %rsi      # 0x11050
leaq 0xba06(%rip), %rcx      # 0x118fe
movl $0x466, %edx            # imm = 0x466
callq 0x3040
leaq 0xbf3d(%rip), %rdi      # 0x11e46
leaq 0xb140(%rip), %rsi      # 0x11050
leaq 0xb9e7(%rip), %rcx      # 0x118fe
movl $0x467, %edx            # imm = 0x467
callq 0x3040
leaq 0xbf4d(%rip), %rdi      # 0x11e75
leaq 0xb121(%rip), %rsi      # 0x11050
leaq 0xb9c8(%rip), %rcx      # 0x118fe
movl $0x468, %edx            # imm = 0x468
callq 0x3040
leaq 0xbf89(%rip), %rdi      # 0x11ed0
leaq 0xb102(%rip), %rsi      # 0x11050
leaq 0xb9a9(%rip), %rcx      # 0x118fe
movl $0x46c, %edx            # imm = 0x46C
callq 0x3040
leaq 0xbfad(%rip), %rdi      # 0x11f13
leaq 0xb0e3(%rip), %rsi      # 0x11050
leaq 0xb98a(%rip), %rcx      # 0x118fe
movl $0x46d, %edx            # imm = 0x46D
callq 0x3040
leaq 0xbfe8(%rip), %rdi      # 0x11f6d
leaq 0xb0c4(%rip), %rsi      # 0x11050
leaq 0xb96b(%rip), %rcx      # 0x118fe
movl $0x471, %edx            # imm = 0x471
callq 0x3040
leaq 0xc023(%rip), %rdi      # 0x11fc7
leaq 0xb0a5(%rip), %rsi      # 0x11050
leaq 0xb94c(%rip), %rcx      # 0x118fe
movl $0x475, %edx            # imm = 0x475
callq 0x3040