// File: /workspace/github_c_makefile_star2_O1/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 %rdi, %r15
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
movabsq $0xfffffffffffff, %r14  # imm = 0xFFFFFFFFFFFFF
movb 0x5(%rdx), %cl
testb %cl, %cl
je 0xe316
testq %rax, %r15
setne %dl
testq %r14, %r15
sete %dil
orb %dl, %dil
jne 0xe316
orb $0x40, 0x2(%rbx)
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
andq %rdx, %r15
testb %cl, %cl
je 0xe33b
testq %rax, %rsi
setne %al
testq %r14, %rsi
sete %cl
orb %al, %cl
jne 0xe33b
orb $0x40, 0x2(%rbx)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rsi
movq %r15, %r13
andq %r14, %r13
movq %r15, %rbp
shrq $0x34, %rbp
movl $0x7ff, %eax            # imm = 0x7FF
andq %rax, %rbp
andq %rsi, %r14
movq %rsi, %r12
shrq $0x34, %r12
andq %rax, %r12
cmpq %rax, %rbp
jne 0xe380
testq %r13, %r13
jne 0xe397
cmpl $0x7ff, %r12d           # imm = 0x7FF
setne %al
testq %r14, %r14
sete %cl
orb %al, %cl
je 0xe397
jmp 0xe484
testq %r12, %r12
je 0xe3b0
cmpl $0x7ff, %r12d           # imm = 0x7FF
jne 0xe3d5
testq %r14, %r14
je 0xe561
movq %r15, %rdi
movq %rbx, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdb26
testq %r14, %r14
je 0xe484
bsrq %r14, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r14
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %r12
testq %rbp, %rbp
jne 0xe3ff
testq %r13, %r13
je 0xe561
bsrq %r13, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r13
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %rbp
shlq $0xb, %r13
btsq $0x3f, %r13
subq %r12, %rbp
js 0xe55b
shlq $0xb, %r14
btsq $0x3f, %r14
xorl %ecx, %ecx
xorl %esi, %esi
cmpq %r13, %r14
cmovbeq %r14, %rcx
setbe %al
subq %rcx, %r13
cmpq $0x41, %rbp
jl 0xe497
movq %rbx, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq %r14, %r15
shrq $0x2, %r15
addq $-0x2, %rbp
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xb99f
movq %rax, %rsi
subq $0x2, %rsi
cmovbq %rbx, %rsi
movq %r15, %r13
imulq %rsi, %r13
negq %r13
addq $-0x3e, %rbp
cmpq $0x3e, %rbp
jg 0xe448
addq $-0x3e, %rbp
movq 0x10(%rsp), %r15
movq 0x8(%rsp), %rbx
jmp 0xe49e
movabsq $0x7ff8000000000000, %r15 # imm = 0x7FF8000000000000
orb $0x1, 0x2(%rbx)
jmp 0xe561
movb %al, %sil
addq $-0x40, %rbp
cmpq $-0x3f, %rbp
jl 0xe4e4
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xb99f
movq %rax, %rsi
subq $0x2, %rsi
movl $0x0, %eax
cmovbq %rax, %rsi
movl %ebp, %ecx
negb %cl
shrq %cl, %rsi
shrq %r13
addb $0x3f, %bpl
movl %ebp, %ecx
shlq %cl, %r13
shrq $0x2, %r14
movq %rsi, %rax
imulq %r14, %rax
subq %rax, %r13
jmp 0xe4ec
shrq $0x2, %r13
shrq $0x2, %r14
movq %r13, %rcx
subq %r14, %rcx
cmpq $-0x1, %rcx
movq $-0x1, %rax
cmovlq %rcx, %rax
notq %rax
addq %r13, %rax
xorl %edx, %edx
divq %r14
movq %r14, %rcx
imulq %rax, %rcx
movq %r13, %rdx
subq %rcx, %rdx
movq %rax, %rcx
notq %rcx
imulq %r14, %rcx
addq %r13, %rcx
movq %rcx, %rdi
addq %rdx, %rdi
js 0xe538
addl %eax, %esi
andl $0x1, %esi
orq %rsi, %rdi
jne 0xe53b
movq %rdx, %rcx
movq %rcx, %rdx
negq %rdx
cmovsq %rcx, %rdx
xorq %rcx, %r15
shrq $0x3f, %r15
testq %rdx, %rdx
je 0xe573
bsrq %rdx, %rcx
xorq $0x3f, %rcx
jmp 0xe578
cmpq $-0x1, %rbp
je 0xe59e
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x40, %ecx
decq %rcx
subq %rcx, %r12
shlq %cl, %rdx
movzbl %r15b, %edi
movq %r12, %rsi
movq %rbx, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa1a9
shrq %r13
jmp 0xe411