// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/softfloat.c
// Function: floatx80_rem
floatx80 floatx80_rem(floatx80 a, floatx80 b, float_status *status)
{
    flag aSign, zSign;
    int32 aExp, bExp, expDiff;
    uint64_t aSig0, aSig1, bSig;
    uint64_t q, term0, term1, alternateASig0, alternateASig1;
    floatx80 z;

    aSig0 = extractFloatx80Frac( a );
    aExp = extractFloatx80Exp( a );
    aSign = extractFloatx80Sign( a );
    bSig = extractFloatx80Frac( b );
    bExp = extractFloatx80Exp( b );
    if ( aExp == 0x7FFF ) {
        if (    (uint64_t) ( aSig0<<1 )
             || ( ( bExp == 0x7FFF ) && (uint64_t) ( bSig<<1 ) ) ) {
            return propagateFloatx80NaN(a, b, status);
        }
        goto invalid;
    }
    if ( bExp == 0x7FFF ) {
        if ((uint64_t)(bSig << 1)) {
            return propagateFloatx80NaN(a, b, status);
        }
        return a;
    }
    if ( bExp == 0 ) {
        if ( bSig == 0 ) {
 invalid:
            float_raise(float_flag_invalid, status);
            z.low = floatx80_default_nan_low;
            z.high = floatx80_default_nan_high;
            return z;
        }
        normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
    }
    if ( aExp == 0 ) {
        if ( (uint64_t) ( aSig0<<1 ) == 0 ) return a;
        normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 );
    }
    bSig |= LIT64( 0x8000000000000000 );
    zSign = aSign;
    expDiff = aExp - bExp;
    aSig1 = 0;
    if ( expDiff < 0 ) {
        if ( expDiff < -1 ) return a;
        shift128Right( aSig0, 0, 1, &aSig0, &aSig1 );
        expDiff = 0;
    }
    q = ( bSig <= aSig0 );
    if ( q ) aSig0 -= bSig;
    expDiff -= 64;
    while ( 0 < expDiff ) {
        q = estimateDiv128To64( aSig0, aSig1, bSig );
        q = ( 2 < q ) ? q - 2 : 0;
        mul64To128( bSig, q, &term0, &term1 );
        sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
        shortShift128Left( aSig0, aSig1, 62, &aSig0, &aSig1 );
        expDiff -= 62;
    }
    expDiff += 64;
    if ( 0 < expDiff ) {
        q = estimateDiv128To64( aSig0, aSig1, bSig );
        q = ( 2 < q ) ? q - 2 : 0;
        q >>= 64 - expDiff;
        mul64To128( bSig, q<<( 64 - expDiff ), &term0, &term1 );
        sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
        shortShift128Left( 0, bSig, 64 - expDiff, &term0, &term1 );
        while ( le128( term0, term1, aSig0, aSig1 ) ) {
            ++q;
            sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
        }
    }
    else {
        term1 = 0;
        term0 = bSig;
    }
    sub128( term0, term1, aSig0, aSig1, &alternateASig0, &alternateASig1 );
    if (    lt128( alternateASig0, alternateASig1, aSig0, aSig1 )
         || (    eq128( alternateASig0, alternateASig1, aSig0, aSig1 )
              && ( q & 1 ) )
       ) {
        aSig0 = alternateASig0;
        aSig1 = alternateASig1;
        zSign = ! zSign;
    }
    return
        normalizeRoundAndPackFloatx80(
            80, zSign, bExp + expDiff, aSig0, aSig1, status);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movl %esi, %edx
movq %rdi, %rax
movl $0x7fff, %r9d           # imm = 0x7FFF
movl %ecx, %esi
andl %r9d, %esi
movl %edx, %edi
notl %edi
testw $0x7fff, %di            # imm = 0x7FFF
jne 0xf8d0
leaq (,%rax,2), %rdi
testq %rdi, %rdi
jne 0xf8f4
movabsq $0x7fffffffffffffff, %rdi # imm = 0x7FFFFFFFFFFFFFFF
cmpw $0x7fff, %si            # imm = 0x7FFF
setne %sil
testq %rdi, %r14
sete %dil
orb %sil, %dil
je 0xf8f4
jmp 0xf946
pushq $0x1
popq %rdi
testw %si, %si
je 0xf906
movzwl %si, %ebp
cmpl $0x7fff, %ebp           # imm = 0x7FFF
jne 0xf91a
leaq (,%r14,2), %rsi
testq %rsi, %rsi
je 0xfb01
movq %rax, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0xec53
jmp 0xfb01
testq %r14, %r14
je 0xf946
bsrq %r14, %rcx
xorq $0x3f, %rcx
shlq %cl, %r14
movl %edi, %ebp
subl %ecx, %ebp
movl %edx, %ebx
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, %r15
andl %r9d, %ebx
jne 0xf96b
testq %rsi, %rax
je 0xfb01
testq %rax, %rax
je 0xf95e
bsrq %rax, %rcx
xorq $0x3f, %rcx
jmp 0xf961
orb $0x1, 0x2(%r8)
movw $0xffff, %dx            # imm = 0xFFFF
movabsq $-0x4000000000000000, %rax # imm = 0xC000000000000000
jmp 0xfb01
pushq $0x40
popq %rcx
movq %rax, %r15
shlq %cl, %r15
subl %ecx, %edi
movl %edi, %ebx
subl %ebp, %ebx
js 0xfacc
movq %r8, 0x10(%rsp)
xorl %r12d, %r12d
movzwl %dx, %eax
shrl $0xf, %eax
movl %eax, 0xc(%rsp)
incq %rsi
orq %rsi, %r14
xorl %eax, %eax
xorl %r13d, %r13d
cmpq %r15, %r14
setbe %r13b
cmovbeq %r14, %rax
subq %rax, %r15
addl %ebx, %ebp
addl $-0x40, %ebx
testl %ebx, %ebx
jle 0xf9fb
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xadbc
subq $0x2, %rax
movl $0x0, %r13d
cmovaeq %rax, %r13
movq %r14, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0xd0a6
xorl %eax, %eax
subq 0x18(%rsp), %r12
setb %al
subl 0x20(%rsp), %r15d
subl %eax, %r15d
shldq $0x3e, %r12, %r15
shlq $0x3e, %r12
addl $-0x3e, %ebx
addl $-0x3e, %ebp
jmp 0xf9a3
cmpl $-0x3f, %ebx
jl 0xfa91
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0xadbc
movq %rax, %r13
xorl %eax, %eax
subq $0x2, %r13
cmovbq %rax, %r13
movl %ebx, %ecx
negb %cl
movb %cl, 0xb(%rsp)
shrq %cl, %r13
movq %r13, %rsi
shlq %cl, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r14, %rdi
callq 0xd0a6
leaq 0x18(%rsp), %rax
subq (%rax), %r12
leaq 0x20(%rsp), %rax
sbbq (%rax), %r15
movq %r14, %r8
movb 0xb(%rsp), %cl
shlq %cl, %r8
movl %ebx, %ecx
shrq %cl, %r14
testl %ebx, %ebx
movl $0x0, %eax
cmoveq %rax, %r14
movq 0x10(%rsp), %r9
cmpq %r14, %r15
setne %al
cmpq %r12, %r8
seta %cl
cmpq %r14, %r15
ja 0xfa86
orb %cl, %al
jne 0xfa99
incq %r13
subq %r8, %r12
sbbq %r14, %r15
jmp 0xfa71
xorl %r8d, %r8d
movq 0x10(%rsp), %r9
subq %r12, %r8
sbbq %r15, %r14
cmpq %r15, %r14
sete %al
cmpq %r12, %r8
setb %cl
cmpq %r15, %r14
jb 0xfac4
andb %al, %cl
jne 0xfac4
cmpq %r12, %r8
jne 0xfae7
cmpq %r15, %r14
jne 0xfae7
andl $0x1, %r13d
je 0xfae7
movl 0xc(%rsp), %eax
xorb $0x1, %al
jmp 0xfaf1
cmpl $-0x1, %ebx
jne 0xfb01
movq %r8, 0x10(%rsp)
movq %r15, %r12
shrq %r15
shlq $0x3f, %r12
xorl %ebx, %ebx
jmp 0xf97b
movq %r15, %r14
movq %r12, %r8
movl 0xc(%rsp), %eax
movzbl %al, %esi
pushq $0x50
popq %rdi
movl %ebp, %edx
movq %r14, %rcx
callq 0xfb10
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq