// File: /workspace/github_c_makefile_star2_O1/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 %r8, %r14
movq %rdx, %r9
movl %esi, %edx
movq %rdi, %rax
movl $0x7fff, %esi           # imm = 0x7FFF
movl %ecx, %edi
andl %esi, %edi
movl %edx, %r8d
notl %r8d
testl $0x7fff, %r8d           # imm = 0x7FFF
jne 0x10d5d
leaq (,%rax,2), %rsi
testq %rsi, %rsi
jne 0x10d7e
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
movzwl %di, %edi
cmpl $0x7fff, %edi           # imm = 0x7FFF
setne %dil
testq %rsi, %r9
sete %sil
orb %dil, %sil
je 0x10d7e
jmp 0x10dd7
testw %di, %di
je 0x10d93
movzwl %di, %ebp
cmpl $0x7fff, %ebp           # imm = 0x7FFF
jne 0x10daa
leaq (,%r9,2), %rsi
testq %rsi, %rsi
je 0x11046
movq %rax, %rdi
movl %edx, %esi
movq %r9, %rdx
movq %r14, %r8
callq 0xfecb
jmp 0x11046
testq %r9, %r9
je 0x10dd7
bsrq %r9, %rcx
xorq $0x3f, %rcx
shlq %cl, %r9
movl $0x1, %ebp
subl %ecx, %ebp
movl %edx, %r15d
movabsq $0x7fffffffffffffff, %rbx # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, %r12
andl %esi, %r15d
jne 0x10e03
testq %rbx, %rax
je 0x11046
testq %rax, %rax
je 0x10def
bsrq %rax, %rcx
xorq $0x3f, %rcx
jmp 0x10df4
orb $0x1, 0x2(%r14)
movw $0xffff, %dx            # imm = 0xFFFF
movabsq $-0x4000000000000000, %rax # imm = 0xC000000000000000
jmp 0x11046
movl $0x40, %ecx
movq %rax, %r12
shlq %cl, %r12
movl $0x1, %r15d
subl %ecx, %r15d
subl %ebp, %r15d
js 0x1100d
xorl %r13d, %r13d
movzwl %dx, %esi
incq %rbx
orq %r9, %rbx
xorl %edx, %edx
xorl %eax, %eax
cmpq %r12, %rbx
cmovbeq %rbx, %rdx
setbe %cl
subq %rdx, %r12
cmpl $0x41, %r15d
movq %r9, 0x20(%rsp)
jb 0x10ee0
movl %esi, 0xc(%rsp)
movq %rbp, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq %rbx, %r14
shrq $0x20, %r14
movl %r9d, %ebp
addl $-0x2, %r15d
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0xb99f
subq $0x2, %rax
movl $0x0, %ecx
cmovbq %rcx, %rax
movq %rax, %rcx
shrq $0x20, %rcx
movl %eax, %edx
movq %rcx, %rsi
imulq %rbp, %rsi
imulq %r14, %rdx
addq %rsi, %rdx
imull %r14d, %ecx
movq %rdx, %rsi
shrq $0x20, %rsi
shlq $0x20, %rdx
movq %rax, %rdi
imulq %rbx, %rdi
xorl %r8d, %r8d
cmpq %rdx, %rdi
setb %r8b
xorl %edx, %edx
subq %rdi, %r13
setb %dl
subl %edx, %r12d
addl %ecx, %esi
subl %esi, %r12d
subl %r8d, %r12d
shldq $0x3e, %r13, %r12
shlq $0x3e, %r13
addl $-0x3e, %r15d
cmpl $0x3e, %r15d
jg 0x10e54
addl $-0x3e, %r15d
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rbp
movl 0xc(%rsp), %esi
jmp 0x10ee6
movb %cl, %al
addl $-0x40, %r15d
shrl $0xf, %esi
cmpl $-0x3f, %r15d
jl 0x10fda
movl %esi, 0xc(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0xb99f
xorl %edx, %edx
subq $0x2, %rax
cmovbq %rdx, %rax
movl %r15d, %ecx
negb %cl
shrq %cl, %rax
movq %rax, %rsi
shlq %cl, %rsi
movq %rbx, %r9
shrq $0x20, %r9
movq %rsi, %r8
shrq $0x20, %r8
movl 0x20(%rsp), %r10d
movl %esi, %edi
imulq %r8, %r10
imulq %r9, %rdi
imulq %r9, %r8
xorl %r9d, %r9d
addq %r10, %rdi
setae %r9b
shlq $0x20, %r9
movq %rdi, %r10
shrq $0x20, %r10
imulq %rbx, %rsi
subq %rsi, %r13
sbbq $0x0, %r12
addq %r8, %r10
subq %r10, %r12
addq %r9, %r12
shlq $0x20, %rdi
cmpq %rdi, %rsi
movq %r12, %rsi
sbbq $0x0, %rsi
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
addq %rsi, %r12
movq %rbx, %r8
shlq %cl, %r8
movl %r15d, %ecx
shrq %cl, %rbx
testl %r15d, %r15d
cmoveq %rdx, %rbx
cmpq %r12, %rbx
setne %cl
cmpq %r13, %r8
seta %dl
cmpq %r12, %rbx
jb 0x10faa
orb %dl, %cl
jne 0x10fd4
movq %r8, %rcx
negq %rcx
incq %rax
leaq (%rcx,%r13), %rsi
subq %r8, %r13
sbbq %rbx, %r12
cmpq %r12, %rbx
setne %dl
cmpq %rsi, %r8
seta %sil
cmpq %r12, %rbx
jb 0x10fb0
orb %sil, %dl
je 0x10fb0
movl 0xc(%rsp), %esi
jmp 0x10fdd
xorl %r8d, %r8d
subq %r13, %r8
sbbq %r12, %rbx
cmpq %r12, %rbx
sete %cl
cmpq %r13, %r8
setb %dl
cmpq %r12, %rbx
jb 0x11007
andb %cl, %dl
jne 0x11007
cmpq %r13, %r8
jne 0x11025
cmpq %r12, %rbx
jne 0x11025
andl $0x1, %eax
je 0x11025
xorb $0x1, %sil
jmp 0x1102b
cmpl $-0x1, %r15d
jne 0x11046
movq %r12, %r13
shrq %r12
shlq $0x3f, %r13
xorl %r15d, %r15d
jmp 0x10e0f
movq %r12, %rbx
movq %r13, %r8
leal (%r15,%rbp), %edx
addl $0x40, %edx
movzbl %sil, %esi
movl $0x50, %edi
movq %rbx, %rcx
movq %r14, %r9
callq 0x11055
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq