// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rsi, %r15
movq %rdx, %rsi
callq 0x920d
movq %rax, %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x920d
movabsq $0xfffffffffffff, %r13  # imm = 0xFFFFFFFFFFFFF
movq %r14, %r12
andq %r13, %r12
movq %r14, %rbp
shrq $0x34, %rbp
movl $0x7ff, %ecx            # imm = 0x7FF
andq %rcx, %rbp
andq %rax, %r13
movq %rax, %r15
shrq $0x34, %r15
andq %rcx, %r15
cmpq %rcx, %rbp
jne 0xd38b
testq %r12, %r12
jne 0xd3a5
cmpl $0x7ff, %r15d           # imm = 0x7FF
setne %cl
testq %r13, %r13
sete %dl
orb %cl, %dl
je 0xd3a5
jmp 0xd4c1
pushq $0x1
popq %rdx
testq %r15, %r15
je 0xd3c1
cmpl $0x7ff, %r15d           # imm = 0x7FF
jne 0xd3e3
testq %r13, %r13
je 0xd563
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xcb8c
testq %r13, %r13
je 0xd4c1
bsrq %r13, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r13
movl %edx, %eax
subl %ecx, %eax
movslq %eax, %r15
testq %rbp, %rbp
jne 0xd408
testq %r12, %r12
je 0xd563
bsrq %r12, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r12
subl %ecx, %edx
movslq %edx, %rbp
shlq $0xb, %r12
btsq $0x3f, %r12
subq %r15, %rbp
js 0xd55d
movq %rbx, 0x10(%rsp)
shrq $0x3f, %r14
movq %r14, 0x8(%rsp)
shlq $0xb, %r13
btsq $0x3f, %r13
xorl %r14d, %r14d
xorl %esi, %esi
cmpq %r12, %r13
setbe %sil
movl $0x0, %eax
cmovbeq %r13, %rax
subq %rax, %r12
addq $-0x40, %rbp
movq %r13, %rbx
shrq $0x2, %rbx
testq %rbp, %rbp
jle 0xd481
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0xadbc
movq %rax, %rsi
subq $0x2, %rsi
cmovbq %r14, %rsi
movq %rbx, %r12
imulq %rsi, %r12
negq %r12
addq $-0x3e, %rbp
jmp 0xd454
cmpq $-0x3f, %rbp
jl 0xd4d4
xorl %r14d, %r14d
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0xadbc
movq %rax, %rsi
subq $0x2, %rsi
cmovbq %r14, %rsi
movl %ebp, %ecx
negb %cl
shrq %cl, %rsi
shrq %r12
addb $0x3f, %bpl
movl %ebp, %ecx
shlq %cl, %r12
movq %rsi, %rax
imulq %rbx, %rax
subq %rax, %r12
jmp 0xd4d8
movabsq $0x7ff8000000000000, %r14 # imm = 0x7FF8000000000000
orb $0x1, 0x2(%rbx)
jmp 0xd563
shrq $0x2, %r12
movq 0x8(%rsp), %r8
movq %r12, %rcx
subq %rbx, %rcx
cmpq $-0x1, %rcx
pushq $-0x1
popq %rax
cmovlq %rcx, %rax
notq %rax
addq %r12, %rax
xorl %edx, %edx
divq %rbx
movq %rbx, %rcx
imulq %rax, %rcx
movq %r12, %rdx
subq %rcx, %rdx
movq %rax, %rcx
notq %rcx
imulq %rbx, %rcx
addq %r12, %rcx
movq %rcx, %rdi
addq %rdx, %rdi
js 0xd527
addl %eax, %esi
andl $0x1, %esi
movb $0x1, %al
orq %rsi, %rdi
jne 0xd536
movq %rdx, %rax
shrq $0x3f, %rax
movq %rdx, %rcx
testq %rdx, %rdx
jns 0xd53c
negq %rcx
movq %rcx, %rdx
xorb %r8b, %al
movzbl %al, %edi
movq %r15, %rsi
movq 0x10(%rsp), %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9591
cmpq $-0x1, %rbp
je 0xd575
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x10(%rsp)
shrq %r12
jmp 0xd41f