// File: /workspace/github_c_makefile_star2_O3/mbitsnbites[P]SoftFP/softfloat.c
// Function: float64_rem
float64 float64_rem(float64 a, float64 b, float_status *status)
{
    flag aSign, zSign;
    int_fast16_t aExp, bExp, expDiff;
    uint64_t aSig, bSig;
    uint64_t q, alternateASig;
    int64_t sigMean;

    a = float64_squash_input_denormal(a, status);
    b = float64_squash_input_denormal(b, status);
    aSig = extractFloat64Frac( a );
    aExp = extractFloat64Exp( a );
    aSign = extractFloat64Sign( a );
    bSig = extractFloat64Frac( b );
    bExp = extractFloat64Exp( b );
    if ( aExp == 0x7FF ) {
        if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) {
            return propagateFloat64NaN(a, b, status);
        }
        float_raise(float_flag_invalid, status);
        return float64_default_nan;
    }
    if ( bExp == 0x7FF ) {
        if (bSig) {
            return propagateFloat64NaN(a, b, status);
        }
        return a;
    }
    if ( bExp == 0 ) {
        if ( bSig == 0 ) {
            float_raise(float_flag_invalid, status);
            return float64_default_nan;
        }
        normalizeFloat64Subnormal( bSig, &bExp, &bSig );
    }
    if ( aExp == 0 ) {
        if ( aSig == 0 ) return a;
        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
    }
    expDiff = aExp - bExp;
    aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<11;
    bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
    if ( expDiff < 0 ) {
        if ( expDiff < -1 ) return a;
        aSig >>= 1;
    }
    q = ( bSig <= aSig );
    if ( q ) aSig -= bSig;
    expDiff -= 64;
    while ( 0 < expDiff ) {
        q = estimateDiv128To64( aSig, 0, bSig );
        q = ( 2 < q ) ? q - 2 : 0;
        aSig = - ( ( bSig>>2 ) * q );
        expDiff -= 62;
    }
    expDiff += 64;
    if ( 0 < expDiff ) {
        q = estimateDiv128To64( aSig, 0, bSig );
        q = ( 2 < q ) ? q - 2 : 0;
        q >>= 64 - expDiff;
        bSig >>= 2;
        aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q;
    }
    else {
        aSig >>= 2;
        bSig >>= 2;
    }
    do {
        alternateASig = aSig;
        ++q;
        aSig -= bSig;
    } while ( 0 <= (int64_t) aSig );
    sigMean = aSig + alternateASig;
    if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) {
        aSig = alternateASig;
    }
    zSign = ( (int64_t) aSig < 0 );
    if ( zSign ) aSig = - aSig;
    return normalizeRoundAndPackFloat64(aSign ^ zSign, bExp, aSig, status);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movabsq $0xfffffffffffff, %rbx  # imm = 0xFFFFFFFFFFFFF
cmpb $0x0, 0x5(%rdx)
je 0xe3b8
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
testq %rcx, %rdi
setne %al
testq %rbx, %rdi
sete %dl
orb %al, %dl
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
jne 0xe3a0
orb $0x40, 0x2(%r15)
andq %rax, %rdi
testq %rcx, %rsi
setne %cl
testq %rbx, %rsi
sete %dl
orb %cl, %dl
jne 0xe3b8
orb $0x40, 0x2(%r15)
andq %rax, %rsi
movq %rdi, %rax
andq %rbx, %rax
movq %rdi, %rdx
shrq $0x34, %rdx
movl $0x7ff, %ecx            # imm = 0x7FF
andq %rcx, %rdx
andq %rsi, %rbx
movq %rsi, %r12
shrq $0x34, %r12
andq %rcx, %r12
cmpq %rcx, %rdx
jne 0xe3fd
testq %rax, %rax
jne 0xe414
cmpl $0x7ff, %r12d           # imm = 0x7FF
setne %al
testq %rbx, %rbx
sete %cl
orb %al, %cl
je 0xe414
jmp 0xe4f6
testq %r12, %r12
je 0xe42a
cmpl $0x7ff, %r12d           # imm = 0x7FF
jne 0xe450
testq %rbx, %rbx
je 0xe50d
movq %r15, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdbdb
testq %rbx, %rbx
je 0xe4f6
bsrq %rbx, %rcx
xorl $0x3f, %ecx
addl $0xf5, %ecx
movzbl %cl, %ecx
shlq %cl, %rbx
movl $0x1, %esi
subl %ecx, %esi
movslq %esi, %r12
testq %rdx, %rdx
jne 0xe47b
testq %rax, %rax
je 0xe50d
bsrq %rax, %rcx
xorl $0x3f, %ecx
addl $0xf5, %ecx
movzbl %cl, %ecx
shlq %cl, %rax
movl $0x1, %edx
subl %ecx, %edx
movslq %edx, %rdx
shlq $0xb, %rax
btsq $0x3f, %rax
shlq $0xb, %rbx
btsq $0x3f, %rbx
movq %rdx, %rbp
subq %r12, %rbp
js 0xe507
xorl %ecx, %ecx
cmpq %rax, %rbx
cmovbeq %rbx, %rcx
movq %rax, %r13
subq %rcx, %r13
cmpq $0x41, %rbp
jb 0xe51f
movq %rdi, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq %rbx, %r15
shrq $0x2, %r15
addq $-0x2, %rbp
xorl %r14d, %r14d
movq %r13, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0xba2b
movq %rax, %r13
subq $0x2, %r13
cmovbq %r14, %r13
imulq %r15, %r13
negq %r13
addq $-0x3e, %rbp
cmpq $0x3e, %rbp
ja 0xe4c2
addq $-0x3e, %rbp
movq 0x10(%rsp), %r15
jmp 0xe53a
movabsq $0x7ff8000000000000, %rdi # imm = 0x7FF8000000000000
orb $0x1, 0x2(%r15)
jmp 0xe50d
cmpq $-0x1, %rbp
je 0xe57d
movq %rdi, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
cmpq %rax, %rbx
setbe %al
cmpq %r12, %rdx
jne 0xe531
movb %al, %sil
jmp 0xe585
movq %rdi, 0x8(%rsp)
addq $-0x40, %rbp
xorl %r14d, %r14d
movq %r13, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0xba2b
movq %rax, %rsi
subq $0x2, %rsi
cmovbq %r14, %rsi
movl %ebp, %ecx
negb %cl
shrq %cl, %rsi
shrq %r13
addb $0x3f, %bpl
movl %ebp, %ecx
shlq %cl, %r13
shrq $0x2, %rbx
movq %rsi, %rax
imulq %rbx, %rax
subq %rax, %r13
movq 0x8(%rsp), %rdi
jmp 0xe58d
shrq %rax
xorl %esi, %esi
movq %rax, %r13
shrq $0x2, %r13
shrq $0x2, %rbx
shrq $0x3f, %rdi
movq %r13, %rcx
subq %rbx, %rcx
cmpq $-0x1, %rcx
movq $-0x1, %rax
cmovlq %rcx, %rax
notq %rax
addq %r13, %rax
xorl %edx, %edx
divq %rbx
movq %rbx, %rcx
imulq %rax, %rcx
movq %r13, %rdx
subq %rcx, %rdx
movq %rax, %rcx
notq %rcx
imulq %rbx, %rcx
addq %r13, %rcx
movq %rcx, %r8
addq %rdx, %r8
js 0xe5df
addl %eax, %esi
andl $0x1, %esi
movb $0x1, %al
orq %rsi, %r8
jne 0xe5ee
movq %rdx, %rax
shrq $0x3f, %rax
movq %rdx, %rcx
testq %rdx, %rdx
jns 0xe5f4
negq %rcx
movq %rcx, %rdx
xorb %dil, %al
testq %rdx, %rdx
je 0xe606
bsrq %rdx, %rcx
xorq $0x3f, %rcx
jmp 0xe60b
movl $0x40, %ecx
decq %rcx
subq %rcx, %r12
shlq %cl, %rdx
movzbl %al, %edi
movq %r12, %rsi
movq %r15, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa25f