// File: /workspace/github_c_makefile_star2_O1/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 0xca7b
movq $-0x2, %r14
leaq 0x18(%rsp), %r15
leaq 0x1014d(%rip), %r12     # 0x14050
movq 0x1a0ee(%rip), %r13     # 0x1dff8
leaq 0x131ac(%rip), %rbx     # 0x170bd
movzbl 0x4(%r14,%r12), %ecx
leal -0x30(%rcx), %ebp
cmpb $0xa, %bpl
jb 0x3f38
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x3f2c
addb $-0x57, %cl
jmp 0x3f36
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x3f76
addb $-0x37, %cl
movl %ecx, %ebp
movzbl 0x5(%r14,%r12), %ecx
leal -0x30(%rcx), %eax
cmpb $0xa, %al
jb 0x3f5d
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x3f51
addb $-0x57, %cl
jmp 0x3f5b
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x3f8b
addb $-0x37, %cl
movl %ecx, %eax
shlb $0x4, %bpl
addb %al, %bpl
movb %bpl, (%r15)
addq $0x2, %r14
incq %r15
cmpq $0x26, %r14
jb 0x3f11
jmp 0x3f9f
movq (%r13), %rdi
movq %rbx, %rsi
movl %ecx, %edx
xorl %eax, %eax
callq 0x30a0
movb $-0x1, %bpl
jmp 0x3f38
movq (%r13), %rdi
movq %rbx, %rsi
movl %ecx, %edx
xorl %eax, %eax
callq 0x30a0
movb $-0x1, %al
jmp 0x3f5d
movaps 0x1318a(%rip), %xmm0    # 0x17130
leaq 0x80(%rsp), %r8
movaps %xmm0, 0x10(%r8)
movaps 0x13166(%rip), %xmm0    # 0x17120
movaps %xmm0, (%r8)
movl $0xfd5f5952, 0x20(%r8)  # imm = 0xFD5F5952
movl 0x28(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x74(%rsp), %rdx
movl $0x11c98, %esi          # imm = 0x11C98
movl $0x24, %ecx
callq 0xd845
xorl %eax, %eax
callq 0xcf29
leaq 0x40(%rsp), %rdi
callq 0x11302
testb %al, %al
je 0x4112
movq 0x30(%rsp), %rax
cmpq $0x60, %rax
jne 0x4131
movq 0x38(%rsp), %rcx
xorl %edx, %edx
cmpb $-0x1, (%rcx,%rdx)
jne 0x40b5
incq %rdx
cmpq $0x1f, %rdx
jne 0x401f
movq 0x38(%rsp), %rcx
cmpb $-0x17, 0x1f(%rcx)
jne 0x4150
xorl %edx, %edx
cmpb $0x0, 0x20(%rcx,%rdx)
jne 0x40d4
incq %rdx
cmpq $0x1d, %rdx
jne 0x4043
cmpb $0x33, 0x3d(%rcx)
jne 0x416f
cmpb $-0x73, 0x3e(%rcx)
jne 0x418e
cmpb $-0x20, 0x3f(%rcx)
jne 0x41ad
xorl %edx, %edx
cmpb $0x0, 0x40(%rcx,%rdx)
jne 0x40f3
incq %rdx
cmpq $0x1f, %rdx
jne 0x4077
cmpb $-0x33, 0x5f(%rcx)
jne 0x41cc
imulq $0xc8, %rax, %rax
cmpq %rax, 0x60(%rsp)
jne 0x41eb
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10172(%rip), %rdi     # 0x1422e
leaq 0xffd9(%rip), %rsi      # 0x1409c
leaq 0x10136(%rip), %rcx     # 0x14200
movl $0x6c, %edx
callq 0x3040
leaq 0x1019e(%rip), %rdi     # 0x14279
leaq 0xffba(%rip), %rsi      # 0x1409c
leaq 0x10117(%rip), %rcx     # 0x14200
movl $0x70, %edx
callq 0x3040
leaq 0x1017f(%rip), %rdi     # 0x14279
leaq 0xff9b(%rip), %rsi      # 0x1409c
leaq 0x100f8(%rip), %rcx     # 0x14200
movl $0x77, %edx
callq 0x3040
leaq 0x100cf(%rip), %rdi     # 0x141e8
leaq 0xff7c(%rip), %rsi      # 0x1409c
leaq 0x100d9(%rip), %rcx     # 0x14200
movl $0x69, %edx
callq 0x3040
leaq 0x100d9(%rip), %rdi     # 0x14211
leaq 0xff5d(%rip), %rsi      # 0x1409c
leaq 0x100ba(%rip), %rcx     # 0x14200
movl $0x6a, %edx
callq 0x3040
leaq 0x100fc(%rip), %rdi     # 0x14253
leaq 0xff3e(%rip), %rsi      # 0x1409c
leaq 0x1009b(%rip), %rcx     # 0x14200
movl $0x6e, %edx
callq 0x3040
leaq 0x10128(%rip), %rdi     # 0x1429e
leaq 0xff1f(%rip), %rsi      # 0x1409c
leaq 0x1007c(%rip), %rcx     # 0x14200
movl $0x73, %edx
callq 0x3040
leaq 0x1012f(%rip), %rdi     # 0x142c4
leaq 0xff00(%rip), %rsi      # 0x1409c
leaq 0x1005d(%rip), %rcx     # 0x14200
movl $0x74, %edx
callq 0x3040
leaq 0x10136(%rip), %rdi     # 0x142ea
leaq 0xfee1(%rip), %rsi      # 0x1409c
leaq 0x1003e(%rip), %rcx     # 0x14200
movl $0x75, %edx
callq 0x3040
leaq 0x1013d(%rip), %rdi     # 0x14310
leaq 0xfec2(%rip), %rsi      # 0x1409c
leaq 0x1001f(%rip), %rcx     # 0x14200
movl $0x79, %edx
callq 0x3040
leaq 0x10144(%rip), %rdi     # 0x14336
leaq 0xfea3(%rip), %rsi      # 0x1409c
leaq 0x10000(%rip), %rcx     # 0x14200
movl $0x7b, %edx
callq 0x3040