// File: /workspace/github_cpp_makefile_star2_O2/Mariotti94[P]BigFloat/BigFloat.cc
// Function: operator%(BigFloat const&, BigFloat const&)
BigFloat operator%(const BigFloat& left, const BigFloat& right)
{
    BigFloat tmp;

    if((left.error) || (right.error)) {
        return tmp;
    }

    if((left.decimals != 0) || (right.decimals != 0)) {
        tmp.error_code = "Modulus Between Non Integers";
        return tmp;
    }

    BigFloat Q, R, D, N, zero, ret;
    zero = 0;

    if(right == zero) {
        tmp.error_code = "Modulus For 0";
        return tmp;
    }

    N = (left > zero) ? (left) : (left * (-1));
    D = (right > zero) ? (right) : (right * (-1));
    R.sign = '+';
    R.error = 0;

    int check = BigFloat::CompareNum(N, D);

    if(check == 0) {
        return zero;
    }
    if(check == 2) {
        return left;
    }
    else {
        while(!N.number.empty()) {
            R.number.push_front(*(N.number.rbegin()));
            N.number.pop_back();

            bool is_zero = true;
            std::deque<char>::const_iterator zero_iter = R.number.begin();
            for(; zero_iter != R.number.end(); ++zero_iter)
                if(*zero_iter != '0')
                    is_zero = false;

            if((R >= D) && (!is_zero)) {
                int Q_sub = 0;
                int min = 0;
                int max = 9;

                while(R >= D) {
                    int avg = max - min;
                    int mod_avg = avg / 2;
                    avg = (avg - mod_avg * 2) ? (mod_avg + 1) : (mod_avg);

                    int div_check = BigFloat::CompareNum(R, D * avg);

                    if(div_check == 2) {
                        max = avg;
                    }
                    else {
                        Q_sub = Q_sub + avg;
                        R = R - D * avg;

                        max = 9;
                    }
                }

                Q.number.push_front(BigFloat::IntToChar(Q_sub));
                ret = R;

                bool is_zero = true;
                std::deque<char>::const_iterator zero_iter = R.number.begin();
                for(; zero_iter != R.number.end(); ++zero_iter)
                    if(*zero_iter != '0')
                        is_zero = false;
                if(is_zero)
                    R.number.clear();
            }
            else {
                ret = R;
                Q.number.push_front('0');
            }
        }

        Q.LeadTrim();
        ret.LeadTrim();
        tmp = ret;
    }

    if(((left.sign == '-') && (right.sign == '-')) || ((left.sign == '+') && (right.sign == '+')))
        tmp.sign = '+';
    else
        tmp.sign = '-';

    if(!BigFloat::CompareNum(tmp, zero))
        tmp.sign = '+';

    tmp.error = 0;
    return tmp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x2610
cmpb $0x0, 0x5c(%r15)
jne 0x5768
cmpb $0x0, 0x5c(%r12)
jne 0x5768
movl 0x58(%r12), %eax
orl 0x58(%r15), %eax
jne 0x5754
leaq 0x3a8(%rsp), %rdi
callq 0x2610
leaq 0x28(%rsp), %rdi
callq 0x2610
leaq 0x328(%rsp), %rdi
callq 0x2610
leaq 0x128(%rsp), %rdi
callq 0x2610
leaq 0x228(%rsp), %rdi
callq 0x2610
leaq 0x2a8(%rsp), %rdi
callq 0x2610
leaq 0x228(%rsp), %rdi
xorl %esi, %esi
callq 0x3b82
leaq 0x228(%rsp), %rsi
movq %r12, %rdi
callq 0x4d92
testb %al, %al
je 0x579a
leaq 0x208(%rsp), %rdi
leaq 0x393a(%rip), %rsi      # 0x9074
callq 0x2220
leaq 0x1a8(%rsp), %rsi
movq %rbx, %rdi
callq 0x6d18
jmp 0x5b71
leaq 0x208(%rsp), %rdi
leaq 0x38f4(%rip), %rsi      # 0x9057
callq 0x2220
leaq 0x1a8(%rsp), %rsi
movq %rbx, %rdi
callq 0x6d18
leaq 0x1a8(%rsp), %rdi
callq 0x253c
movq %rbx, %rax
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x228(%rsp), %rsi
movq %r15, %rdi
callq 0x4dca
testb %al, %al
je 0x57c0
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x25b4
jmp 0x57db
leaq 0x428(%rsp), %rdx
orl $-0x1, (%rdx)
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x4588
leaq 0x128(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x6c40
leaq 0xa8(%rsp), %rdi
callq 0x253c
leaq 0x228(%rsp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x4dca
testb %al, %al
je 0x5826
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x25b4
jmp 0x5841
leaq 0x428(%rsp), %rdx
orl $-0x1, (%rdx)
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x4588
leaq 0x328(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x6c40
leaq 0xa8(%rsp), %rdi
callq 0x253c
movb $0x2b, 0x28(%rsp)
movb $0x0, 0x84(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0x2edc
testl %eax, %eax
je 0x5b66
cmpl $0x2, %eax
jne 0x58a2
movq %rbx, %rdi
movq %r15, %rsi
callq 0x25b4
jmp 0x5b71
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
leaq 0x130(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x328(%rsp), %rbp
leaq 0xa8(%rsp), %r13
movq 0x160(%rsp), %rsi
cmpq 0x140(%rsp), %rsi
je 0x5ad4
cmpq 0x168(%rsp), %rsi
jne 0x5907
movq 0x178(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
decq %rsi
movq %r15, %rdi
callq 0x6c84
movq %r14, %rdi
callq 0x6d5c
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
movb $0x1, %bl
movq 0x60(%rsp), %rdx
cmpq %rdx, %rax
je 0x5958
cmpb $0x30, (%rax)
sete %dil
andb %dil, %bl
incq %rax
cmpq %rsi, %rax
jne 0x5930
movq 0x8(%rcx), %rax
addq $0x8, %rcx
leaq 0x200(%rax), %rsi
jmp 0x5930
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4e14
notb %al
orb %bl, %al
testb $0x1, %al
je 0x5998
leaq 0x2a8(%rsp), %rdi
movq %r12, %rsi
callq 0x6c40
movb $0x30, 0xa8(%rsp)
leaq 0x3b0(%rsp), %rdi
movq %r13, %rsi
callq 0x88c4
jmp 0x58d3
xorl %r15d, %r15d
pushq $0x9
popq %r14
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4e14
testb %al, %al
je 0x5a47
movl %r14d, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
leal (%rax,%rax), %ecx
xorl %ebx, %ebx
cmpl %ecx, %r14d
setne %bl
addl %eax, %ebx
movl %ebx, 0xc(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
leaq 0xc(%rsp), %rdx
callq 0x4588
movq %r12, %rdi
movq %r13, %rsi
callq 0x2edc
movl %eax, %r14d
movq %r13, %rdi
callq 0x253c
cmpl $0x2, %r14d
je 0x5a3f
leaq 0x428(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
leaq 0xc(%rsp), %rdx
callq 0x4588
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x40de
addl %ebx, %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x2678
movq %r13, %rdi
callq 0x253c
movq %r14, %rdi
callq 0x253c
pushq $0x9
popq %rbx
movl %ebx, %r14d
jmp 0x599f
addb $0x30, %r15b
movb %r15b, 0xa8(%rsp)
leaq 0x3b0(%rsp), %rdi
movq %r13, %rsi
callq 0x88c4
leaq 0x2a8(%rsp), %rdi
movq %r12, %rsi
callq 0x6c40
leaq 0x130(%rsp), %r14
leaq 0x30(%rsp), %r15
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rdx
movb $0x1, %cl
movq 0x60(%rsp), %rsi
cmpq %rsi, %rax
je 0x5abe
cmpb $0x30, (%rax)
sete %r8b
andb %r8b, %cl
incq %rax
cmpq %rdi, %rax
jne 0x5a96
movq 0x8(%rdx), %rax
addq $0x8, %rdx
leaq 0x200(%rax), %rdi
jmp 0x5a96
testb $0x1, %cl
je 0x58d3
movq %r15, %rdi
callq 0x2df6
jmp 0x58d3
leaq 0x3a8(%rsp), %rdi
callq 0x3b2c
leaq 0x2a8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3b2c
leaq 0x1a8(%rsp), %rdi
movq %rbx, %rsi
callq 0x6c40
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rdx
movb (%rax), %al
movl %eax, %ecx
xorb $0x2d, %cl
movb (%rdx), %dl
movl %edx, %esi
xorb $0x2d, %sil
orb %cl, %sil
sete %cl
xorb $0x2b, %al
xorb $0x2b, %dl
orb %al, %dl
sete %al
orb %cl, %al
xorb $0x1, %al
addb %al, %al
addb $0x2b, %al
leaq 0x1a8(%rsp), %r14
movb %al, (%r14)
leaq 0x228(%rsp), %rsi
movq %r14, %rdi
callq 0x2edc
testl %eax, %eax
jne 0x5b5e
movb $0x2b, 0x1a8(%rsp)
movb $0x0, 0x204(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6d18
leaq 0x2a8(%rsp), %rdi
callq 0x253c
leaq 0x228(%rsp), %rdi
callq 0x253c
leaq 0x128(%rsp), %rdi
callq 0x253c
leaq 0x328(%rsp), %rdi
callq 0x253c
leaq 0x28(%rsp), %rdi
callq 0x253c
leaq 0x3a8(%rsp), %rdi
callq 0x253c
jmp 0x5778
jmp 0x5c1e
jmp 0x5c1e
jmp 0x5c0c
jmp 0x5c0c
jmp 0x5c1e
jmp 0x5c1e
movq %rax, %rbx
jmp 0x5c2e
movq %rax, %rbx
jmp 0x5c3b
movq %rax, %rbx
jmp 0x5c48
movq %rax, %rbx
jmp 0x5c55
movq %rax, %rbx
jmp 0x5c5f
jmp 0x5bf6
jmp 0x5c1e
jmp 0x5c1e
jmp 0x5c1e
jmp 0x5c1e
jmp 0x5c1e
jmp 0x5c1e
jmp 0x5c1e
movq %rax, %rbx
jmp 0x5c6c
movq %rax, %rbx
leaq 0x428(%rsp), %rdi
jmp 0x5c17
jmp 0x5c1e
jmp 0x5c1e
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x253c
jmp 0x5c21
movq %rax, %rbx
leaq 0x2a8(%rsp), %rdi
callq 0x253c
leaq 0x228(%rsp), %rdi
callq 0x253c
leaq 0x128(%rsp), %rdi
callq 0x253c
leaq 0x328(%rsp), %rdi
callq 0x253c
leaq 0x28(%rsp), %rdi
callq 0x253c
leaq 0x3a8(%rsp), %rdi
callq 0x253c
leaq 0x1a8(%rsp), %rdi
callq 0x253c
movq %rbx, %rdi
callq 0x2200
nop