// File: /workspace/github_c_makefile_star2_O0/wjmelements[P]evm/tst/uint256.c
// Function: test_math
void test_math() {
    uint256_t a, b, c, d, e;

    LOWER(LOWER(a)) = 2ull;
    UPPER(LOWER(a)) = 3ull;
    LOWER(UPPER(a)) = 5ull;
    UPPER(UPPER(a)) = 7ull;

    LOWER(LOWER(b)) = 11ull;
    UPPER(LOWER(b)) = 13ull;
    LOWER(UPPER(b)) = 17ull;
    UPPER(UPPER(b)) = 19ull;

    add256(&a, &b, &d);
    assert(LOWER(LOWER(d)) == 13ull);
    assert(UPPER(LOWER(d)) == 16ull);
    assert(LOWER(UPPER(d)) == 22ull);
    assert(UPPER(UPPER(d)) == 26ull);

    minus256(&d, &b, &c);
    assert(equal256(&a, &c));

    clear128(&UPPER(a));
    clear128(&UPPER(b));
    mul256(&a, &b, &d);
    assert(!zero256(&d));
    divmod256(&d, &b, &c, &e);
    assert(zero256(&e));
    assert(equal256(&c, &a));

    // 10e425c56daffabc35c1
    clear128(&UPPER(a));
    assert(UPPER(UPPER(a)) == 0);
    assert(LOWER(UPPER(a)) == 0);
    UPPER(LOWER(a)) = 0x10e4;
    LOWER(LOWER(a)) = 0x25c56daffabc35c1;
    mul256(&a, &a, &a);
    // 11d500bfaf40ac5044981798db5fb39f2c17b81
    assert(UPPER(UPPER(a)) == 0);
    assert(LOWER(UPPER(a)) == 0x11d500b);
    assert(UPPER(LOWER(a)) == 0xfaf40ac504498179);
    assert(LOWER(LOWER(a)) == 0x8db5fb39f2c17b81);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq $0x2, -0x8(%rbp)
movq $0x3, -0x10(%rbp)
movq $0x5, -0x18(%rbp)
movq $0x7, -0x20(%rbp)
movq $0xb, -0x28(%rbp)
movq $0xd, -0x30(%rbp)
movq $0x11, -0x38(%rbp)
movq $0x13, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x3c70
cmpq $0xd, -0x68(%rbp)
jne 0x1be5
jmp 0x1c04
leaq 0x5b92(%rip), %rdi      # 0x777e
leaq 0x5448(%rip), %rsi      # 0x703b
movl $0x78, %edx
leaq 0x5b98(%rip), %rcx      # 0x7797
callq 0x1030
cmpq $0x10, -0x70(%rbp)
jne 0x1c0d
jmp 0x1c2c
leaq 0x5b94(%rip), %rdi      # 0x77a8
leaq 0x5420(%rip), %rsi      # 0x703b
movl $0x79, %edx
leaq 0x5b70(%rip), %rcx      # 0x7797
callq 0x1030
cmpq $0x16, -0x78(%rbp)
jne 0x1c35
jmp 0x1c54
leaq 0x5b85(%rip), %rdi      # 0x77c1
leaq 0x53f8(%rip), %rsi      # 0x703b
movl $0x7a, %edx
leaq 0x5b48(%rip), %rcx      # 0x7797
callq 0x1030
cmpq $0x1a, -0x80(%rbp)
jne 0x1c5d
jmp 0x1c7c
leaq 0x5b76(%rip), %rdi      # 0x77da
leaq 0x53d0(%rip), %rsi      # 0x703b
movl $0x7b, %edx
leaq 0x5b20(%rip), %rcx      # 0x7797
callq 0x1030
leaq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x4580
leaq -0x20(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4130
testb $0x1, %al
jne 0x1ca0
jmp 0x1ca2
jmp 0x1cc1
leaq 0x5b4a(%rip), %rdi      # 0x77f3
leaq 0x538b(%rip), %rsi      # 0x703b
movl $0x7e, %edx
leaq 0x5adb(%rip), %rcx      # 0x7797
callq 0x1030
leaq -0x20(%rbp), %rdi
callq 0x35c0
leaq -0x40(%rbp), %rdi
callq 0x35c0
leaq -0x20(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4cb0
leaq -0x80(%rbp), %rdi
callq 0x34d0
testb $0x1, %al
jne 0x1cf3
jmp 0x1d12
leaq 0x5b0a(%rip), %rdi      # 0x7804
leaq 0x533a(%rip), %rsi      # 0x703b
movl $0x83, %edx
leaq 0x5a8a(%rip), %rcx      # 0x7797
callq 0x1030
leaq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
callq 0x5b50
leaq -0xa0(%rbp), %rdi
callq 0x34d0
testb $0x1, %al
jne 0x1d3c
jmp 0x1d3e
jmp 0x1d5d
leaq 0x5acc(%rip), %rdi      # 0x7811
leaq 0x52ef(%rip), %rsi      # 0x703b
movl $0x85, %edx
leaq 0x5a3f(%rip), %rcx      # 0x7797
callq 0x1030
leaq -0x60(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x4130
testb $0x1, %al
jne 0x1d70
jmp 0x1d72
jmp 0x1d91
leaq 0x5aa4(%rip), %rdi      # 0x781d
leaq 0x52bb(%rip), %rsi      # 0x703b
movl $0x86, %edx
leaq 0x5a0b(%rip), %rcx      # 0x7797
callq 0x1030
leaq -0x20(%rbp), %rdi
callq 0x35c0
cmpq $0x0, -0x20(%rbp)
jne 0x1da3
jmp 0x1dc2
leaq 0x5a84(%rip), %rdi      # 0x782e
leaq 0x528a(%rip), %rsi      # 0x703b
movl $0x8a, %edx
leaq 0x59da(%rip), %rcx      # 0x7797
callq 0x1030
cmpq $0x0, -0x18(%rbp)
jne 0x1dcb
jmp 0x1dea
leaq 0x5a71(%rip), %rdi      # 0x7843
leaq 0x5262(%rip), %rsi      # 0x703b
movl $0x8b, %edx
leaq 0x59b2(%rip), %rcx      # 0x7797
callq 0x1030
movq $0x10e4, -0x10(%rbp)    # imm = 0x10E4
movabsq $0x25c56daffabc35c1, %rax # imm = 0x25C56DAFFABC35C1
movq %rax, -0x8(%rbp)
leaq -0x20(%rbp), %rdx
movq %rdx, %rdi
movq %rdx, %rsi
callq 0x4cb0
cmpq $0x0, -0x20(%rbp)
jne 0x1e18
jmp 0x1e37
leaq 0x5a0f(%rip), %rdi      # 0x782e
leaq 0x5215(%rip), %rsi      # 0x703b
movl $0x90, %edx
leaq 0x5965(%rip), %rcx      # 0x7797
callq 0x1030
cmpq $0x11d500b, -0x18(%rbp) # imm = 0x11D500B
jne 0x1e43
jmp 0x1e62
leaq 0x5a0e(%rip), %rdi      # 0x7858
leaq 0x51ea(%rip), %rsi      # 0x703b
movl $0x91, %edx
leaq 0x593a(%rip), %rcx      # 0x7797
callq 0x1030
movabsq $-0x50bf53afbb67e87, %rax # imm = 0xFAF40AC504498179
cmpq %rax, -0x10(%rbp)
jne 0x1e74
jmp 0x1e93
leaq 0x59fa(%rip), %rdi      # 0x7875
leaq 0x51b9(%rip), %rsi      # 0x703b
movl $0x92, %edx
leaq 0x5909(%rip), %rcx      # 0x7797
callq 0x1030
movabsq $-0x724a04c60d3e847f, %rax # imm = 0x8DB5FB39F2C17B81
cmpq %rax, -0x8(%rbp)
jne 0x1ea5
jmp 0x1ec4
leaq 0x59ef(%rip), %rdi      # 0x789b
leaq 0x5188(%rip), %rsi      # 0x703b
movl $0x93, %edx
leaq 0x58d8(%rip), %rcx      # 0x7797
callq 0x1030
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)