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

    address_t from = AddressFromHex42("0x4a6f6B9fF1fc974096f9063a45Fd12bD5B928AD1");
    uint64_t gas = 72856;
    val_t value;
    data_t input;

    // 60026004046007600302015f035f5262ce378160021c595262abcdef601e1a5952595ffd
    op_t program[] = {
        // 0 - (3 * 7 + 4 / 2)
        PUSH1, 0x02,
        PUSH1, 0x04,
        DIV,
        PUSH1, 0x07,
        PUSH1, 0x03,
        MUL,
        ADD,
        PUSH0,
        SUB,
        PUSH0,
        MSTORE,
        // 0xce3781 >> 2
        PUSH3, 0xce, 0x37, 0x81, PUSH1, 0x02, SHR, MSIZE, MSTORE,
        PUSH3, 0xab, 0xcd, 0xef, PUSH1, 0x1e, BYTE, MSIZE, MSTORE,
        MSIZE,
        PUSH0,
        REVERT,
    };

    input.size = sizeof(program);
    input.content = program;

    result_t result = txCreate(from, gas, value, input);
    evmFinalize();

    assert(zero256(&result.status));
    assert(result.returnData.size == 96);
    for (int i = 0; i < 31; i++) {
        assert(result.returnData.content[i] == 0xff);
    }
    assert(result.returnData.content[31] == 0xe9);
    for (int i = 32; i < 61; i++) {
        assert(result.returnData.content[i] == 0x00);
    }
    // 0x338de0
    assert(result.returnData.content[61] == 0x33);
    assert(result.returnData.content[62] == 0x8d);
    assert(result.returnData.content[63] == 0xe0);
    for (int i = 64; i < 95; i++) {
        assert(result.returnData.content[i] == 0x00);
    }
    assert(result.returnData.content[95] == 0xcd);

    assert(result.gasRemaining == G_PER_CODEBYTE * result.returnData.size);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
xorl %eax, %eax
callq 0xca4d
movq $-0x2, %r14
leaq 0x20(%rsp), %r15
leaq 0x100fd(%rip), %r12     # 0x14070
movq 0x1a07e(%rip), %r13     # 0x1dff8
leaq 0x1315c(%rip), %rbx     # 0x170dd
movzbl 0x4(%r14,%r12), %ecx
leal -0x30(%rcx), %ebp
cmpb $0xa, %bpl
jb 0x3fa8
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x3f9c
addb $-0x57, %cl
jmp 0x3fa6
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x3fe6
addb $-0x37, %cl
movl %ecx, %ebp
movzbl 0x5(%r14,%r12), %ecx
leal -0x30(%rcx), %eax
cmpb $0xa, %al
jb 0x3fcd
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x3fc1
addb $-0x57, %cl
jmp 0x3fcb
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x3ffb
addb $-0x37, %cl
movl %ecx, %eax
shlb $0x4, %bpl
addb %al, %bpl
movb %bpl, (%r15)
addq $0x2, %r14
incq %r15
cmpq $0x26, %r14
jb 0x3f81
jmp 0x400f
movq (%r13), %rdi
movq %rbx, %rsi
movl %ecx, %edx
xorl %eax, %eax
callq 0x30a0
movb $-0x1, %bpl
jmp 0x3fa8
movq (%r13), %rdi
movq %rbx, %rsi
movl %ecx, %edx
xorl %eax, %eax
callq 0x30a0
movb $-0x1, %al
jmp 0x3fcd
movaps 0x1313a(%rip), %xmm0    # 0x17150
leaq 0x80(%rsp), %r8
movaps %xmm0, 0x10(%r8)
movaps 0x13116(%rip), %xmm0    # 0x17140
movaps %xmm0, (%r8)
movl $0xfd5f5952, 0x20(%r8)  # imm = 0xFD5F5952
movl 0x30(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x34(%rsp), %rdx
movl $0x11c98, %esi          # imm = 0x11C98
movl $0x24, %ecx
callq 0xd683
xorl %eax, %eax
callq 0xcd49
leaq 0x50(%rsp), %rdi
callq 0x10f7a
testb %al, %al
je 0x4177
cmpq $0x60, 0x40(%rsp)
jne 0x4196
movq 0x48(%rsp), %rax
xorl %ecx, %ecx
cmpb $-0x1, (%rax,%rcx)
jne 0x411a
incq %rcx
cmpq $0x1f, %rcx
jne 0x408c
cmpb $-0x17, 0x1f(%rax)
jne 0x41b5
xorl %ecx, %ecx
cmpb $0x0, 0x20(%rax,%rcx)
jne 0x4139
incq %rcx
cmpq $0x1d, %rcx
jne 0x40ab
cmpb $0x33, 0x3d(%rax)
jne 0x41d4
cmpb $-0x73, 0x3e(%rax)
jne 0x41f3
cmpb $-0x20, 0x3f(%rax)
jne 0x4212
xorl %ecx, %ecx
cmpb $0x0, 0x40(%rax,%rcx)
jne 0x4158
incq %rcx
cmpq $0x1f, %rcx
jne 0x40df
cmpb $-0x33, 0x5f(%rax)
jne 0x4231
cmpq $0x4b00, 0x70(%rsp)     # imm = 0x4B00
jne 0x4250
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1012d(%rip), %rdi     # 0x1424e
leaq 0xff94(%rip), %rsi      # 0x140bc
leaq 0x100f1(%rip), %rcx     # 0x14220
movl $0x6c, %edx
callq 0x3040
leaq 0x10159(%rip), %rdi     # 0x14299
leaq 0xff75(%rip), %rsi      # 0x140bc
leaq 0x100d2(%rip), %rcx     # 0x14220
movl $0x70, %edx
callq 0x3040
leaq 0x1013a(%rip), %rdi     # 0x14299
leaq 0xff56(%rip), %rsi      # 0x140bc
leaq 0x100b3(%rip), %rcx     # 0x14220
movl $0x77, %edx
callq 0x3040
leaq 0x1008a(%rip), %rdi     # 0x14208
leaq 0xff37(%rip), %rsi      # 0x140bc
leaq 0x10094(%rip), %rcx     # 0x14220
movl $0x69, %edx
callq 0x3040
leaq 0x10094(%rip), %rdi     # 0x14231
leaq 0xff18(%rip), %rsi      # 0x140bc
leaq 0x10075(%rip), %rcx     # 0x14220
movl $0x6a, %edx
callq 0x3040
leaq 0x100b7(%rip), %rdi     # 0x14273
leaq 0xfef9(%rip), %rsi      # 0x140bc
leaq 0x10056(%rip), %rcx     # 0x14220
movl $0x6e, %edx
callq 0x3040
leaq 0x100e3(%rip), %rdi     # 0x142be
leaq 0xfeda(%rip), %rsi      # 0x140bc
leaq 0x10037(%rip), %rcx     # 0x14220
movl $0x73, %edx
callq 0x3040
leaq 0x100ea(%rip), %rdi     # 0x142e4
leaq 0xfebb(%rip), %rsi      # 0x140bc
leaq 0x10018(%rip), %rcx     # 0x14220
movl $0x74, %edx
callq 0x3040
leaq 0x100f1(%rip), %rdi     # 0x1430a
leaq 0xfe9c(%rip), %rsi      # 0x140bc
leaq 0xfff9(%rip), %rcx      # 0x14220
movl $0x75, %edx
callq 0x3040
leaq 0x100f8(%rip), %rdi     # 0x14330
leaq 0xfe7d(%rip), %rsi      # 0x140bc
leaq 0xffda(%rip), %rcx      # 0x14220
movl $0x79, %edx
callq 0x3040
leaq 0x100ff(%rip), %rdi     # 0x14356
leaq 0xfe5e(%rip), %rsi      # 0x140bc
leaq 0xffbb(%rip), %rcx      # 0x14220
movl $0x7b, %edx
callq 0x3040