// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movb $0x0, %al
callq 0xcfc0
leaq -0x18(%rbp), %rdi
leaq 0x17a07(%rip), %rsi     # 0x1b004
addq $0x2, %rsi
callq 0x3380
movq $0x11c98, -0x20(%rbp)   # imm = 0x11C98
leaq -0x70(%rbp), %rdi
leaq 0x1aac7(%rip), %rsi     # 0x1e0e0
movl $0x24, %edx
callq 0x30c0
movq $0x24, -0x40(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
leaq -0xb0(%rbp), %rdi
leaq -0x18(%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
movb $0x0, %al
callq 0xd4d0
leaq -0xb0(%rbp), %rdi
addq $0x10, %rdi
callq 0x13f00
testb $0x1, %al
jne 0x3687
jmp 0x3689
jmp 0x36a8
leaq 0x17b0c(%rip), %rdi     # 0x1b19c
leaq 0x179b9(%rip), %rsi     # 0x1b050
movl $0x69, %edx
leaq 0x17b11(%rip), %rcx     # 0x1b1b4
callq 0x3040
cmpq $0x60, -0xb0(%rbp)
jne 0x36b4
jmp 0x36d3
leaq 0x17b0a(%rip), %rdi     # 0x1b1c5
leaq 0x1798e(%rip), %rsi     # 0x1b050
movl $0x6a, %edx
leaq 0x17ae6(%rip), %rcx     # 0x1b1b4
callq 0x3040
movl $0x0, -0xb4(%rbp)
cmpl $0x1f, -0xb4(%rbp)
jge 0x3733
movq -0xa8(%rbp), %rax
movslq -0xb4(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x3701
jmp 0x3720
leaq 0x17ada(%rip), %rdi     # 0x1b1e2
leaq 0x17941(%rip), %rsi     # 0x1b050
movl $0x6c, %edx
leaq 0x17a99(%rip), %rcx     # 0x1b1b4
callq 0x3040
jmp 0x3722
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x36dd
movq -0xa8(%rbp), %rax
movzbl 0x1f(%rax), %eax
cmpl $0xe9, %eax
jne 0x3747
jmp 0x3766
leaq 0x17ab9(%rip), %rdi     # 0x1b207
leaq 0x178fb(%rip), %rsi     # 0x1b050
movl $0x6e, %edx
leaq 0x17a53(%rip), %rcx     # 0x1b1b4
callq 0x3040
movl $0x20, -0xb8(%rbp)
cmpl $0x3d, -0xb8(%rbp)
jge 0x37c4
movq -0xa8(%rbp), %rax
movslq -0xb8(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x3792
jmp 0x37b1
leaq 0x17a94(%rip), %rdi     # 0x1b22d
leaq 0x178b0(%rip), %rsi     # 0x1b050
movl $0x70, %edx
leaq 0x17a08(%rip), %rcx     # 0x1b1b4
callq 0x3040
jmp 0x37b3
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x3770
movq -0xa8(%rbp), %rax
movzbl 0x3d(%rax), %eax
cmpl $0x33, %eax
jne 0x37d6
jmp 0x37f5
leaq 0x17a75(%rip), %rdi     # 0x1b252
leaq 0x1786c(%rip), %rsi     # 0x1b050
movl $0x73, %edx
leaq 0x179c4(%rip), %rcx     # 0x1b1b4
callq 0x3040
movq -0xa8(%rbp), %rax
movzbl 0x3e(%rax), %eax
cmpl $0x8d, %eax
jne 0x3809
jmp 0x3828
leaq 0x17a68(%rip), %rdi     # 0x1b278
leaq 0x17839(%rip), %rsi     # 0x1b050
movl $0x74, %edx
leaq 0x17991(%rip), %rcx     # 0x1b1b4
callq 0x3040
movq -0xa8(%rbp), %rax
movzbl 0x3f(%rax), %eax
cmpl $0xe0, %eax
jne 0x383c
jmp 0x385b
leaq 0x17a5b(%rip), %rdi     # 0x1b29e
leaq 0x17806(%rip), %rsi     # 0x1b050
movl $0x75, %edx
leaq 0x1795e(%rip), %rcx     # 0x1b1b4
callq 0x3040
movl $0x40, -0xbc(%rbp)
cmpl $0x5f, -0xbc(%rbp)
jge 0x38b9
movq -0xa8(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x3887
jmp 0x38a6
leaq 0x1799f(%rip), %rdi     # 0x1b22d
leaq 0x177bb(%rip), %rsi     # 0x1b050
movl $0x77, %edx
leaq 0x17913(%rip), %rcx     # 0x1b1b4
callq 0x3040
jmp 0x38a8
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x3865
movq -0xa8(%rbp), %rax
movzbl 0x5f(%rax), %eax
cmpl $0xcd, %eax
jne 0x38cd
jmp 0x38ec
leaq 0x179f0(%rip), %rdi     # 0x1b2c4
leaq 0x17775(%rip), %rsi     # 0x1b050
movl $0x79, %edx
leaq 0x178cd(%rip), %rcx     # 0x1b1b4
callq 0x3040
movq -0x80(%rbp), %rax
imulq $0xc8, -0xb0(%rbp), %rcx
cmpq %rcx, %rax
jne 0x3902
jmp 0x3921
leaq 0x179e1(%rip), %rdi     # 0x1b2ea
leaq 0x17740(%rip), %rsi     # 0x1b050
movl $0x7b, %edx
leaq 0x17898(%rip), %rcx     # 0x1b1b4
callq 0x3040
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)