// File: /workspace/github_c_makefile_star2_O3/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
movl %esi, %ebp
movq %rdi, %rax
movl $0x7fff, %r8d           # imm = 0x7FFF
movl %ecx, %esi
andl %r8d, %esi
movl %ebp, %edi
notl %edi
testl $0x7fff, %edi           # imm = 0x7FFF
jne 0x10d5f
leaq (,%rax,2), %rdi
testq %rdi, %rdi
jne 0x10d80
movabsq $0x7fffffffffffffff, %rdi # imm = 0x7FFFFFFFFFFFFFFF
movzwl %si, %esi
cmpl $0x7fff, %esi           # imm = 0x7FFF
setne %sil
testq %rdi, %rdx
sete %dil
orb %sil, %dil
je 0x10d80
jmp 0x10dd5
testw %si, %si
je 0x10d92
movzwl %si, %edi
cmpl $0x7fff, %edi           # imm = 0x7FFF
jne 0x10da9
leaq (,%rdx,2), %rsi
testq %rsi, %rsi
je 0x1105c
movq %rax, %rdi
movl %ebp, %esi
movq %r14, %r8
callq 0xff00
jmp 0x1105a
testq %rdx, %rdx
je 0x10dd5
bsrq %rdx, %rcx
xorq $0x3f, %rcx
shlq %cl, %rdx
movl $0x1, %edi
subl %ecx, %edi
movl %ebp, %esi
movabsq $0x7fffffffffffffff, %rbx # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, %r15
andl %r8d, %esi
jne 0x10dff
testq %rbx, %rax
je 0x1105c
testq %rax, %rax
je 0x10ded
bsrq %rax, %rcx
xorq $0x3f, %rcx
jmp 0x10df2
orb $0x1, 0x2(%r14)
movw $0xffff, %bp            # imm = 0xFFFF
movabsq $-0x4000000000000000, %rax # imm = 0xC000000000000000
jmp 0x1105c
movl $0x40, %ecx
movq %rax, %r15
shlq %cl, %r15
movl $0x1, %esi
subl %ecx, %esi
incq %rbx
orq %rdx, %rbx
movl %esi, %r12d
subl %edi, %r12d
js 0x10ed0
xorl %eax, %eax
cmpq %r15, %rbx
cmovbeq %rbx, %rax
movq %r15, %r13
subq %rax, %r13
cmpl $0x41, %r12d
jb 0x10ef4
movq %rdi, 0x8(%rsp)
movl %ebp, 0x14(%rsp)
movq %r14, 0x20(%rsp)
movq %rbx, %r14
shrq $0x20, %r14
movq %rdx, 0x18(%rsp)
movl %edx, %ebp
addl $-0x2, %r12d
xorl %r15d, %r15d
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xba2b
subq $0x2, %rax
movl $0x0, %ecx
cmovaeq %rax, %rcx
movq %rcx, %rax
shrq $0x20, %rax
movl %ecx, %edx
movq %rax, %rsi
imulq %rbp, %rsi
imulq %r14, %rdx
addq %rsi, %rdx
imull %r14d, %eax
movq %rdx, %rsi
shrq $0x20, %rsi
shlq $0x20, %rdx
imulq %rbx, %rcx
xorl %edi, %edi
cmpq %rdx, %rcx
setb %dil
xorl %edx, %edx
subq %rcx, %r15
setb %dl
subl %edx, %r13d
addl %eax, %esi
subl %esi, %r13d
subl %edi, %r13d
shldq $0x3e, %r15, %r13
shlq $0x3e, %r15
addl $-0x3e, %r12d
cmpl $0x3e, %r12d
ja 0x10e4d
addl $-0x3e, %r12d
movq 0x20(%rsp), %r14
movl 0x14(%rsp), %ebp
jmp 0x10f21
cmpl $-0x1, %r12d
jne 0x1105c
movq %r15, %r13
shrq %r13
shlq $0x3f, %r15
movl $0xffffffc0, %r12d      # imm = 0xFFFFFFC0
xorl %r8d, %r8d
xorl %eax, %eax
jmp 0x11003
xorl %eax, %eax
cmpq %r15, %rbx
setbe %cl
xorl %r15d, %r15d
cmpl %edi, %esi
jne 0x10f13
movb %cl, %al
movl $0xffffffc0, %r12d      # imm = 0xFFFFFFC0
xorl %r8d, %r8d
jmp 0x11003
movq %rdx, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
addl $-0x40, %r12d
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xba2b
xorl %edx, %edx
subq $0x2, %rax
cmovbq %rdx, %rax
movl %r12d, %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 0x18(%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, %r15
sbbq $0x0, %r13
addq %r8, %r10
subq %r10, %r13
addq %r9, %r13
shlq $0x20, %rdi
cmpq %rdi, %rsi
movq %r13, %rsi
sbbq $0x0, %rsi
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
addq %rsi, %r13
movq %rbx, %r8
shlq %cl, %r8
movl %r12d, %ecx
shrq %cl, %rbx
testl %r12d, %r12d
cmoveq %rdx, %rbx
cmpq %r13, %rbx
setne %cl
cmpq %r15, %r8
seta %dl
cmpq %r13, %rbx
jb 0x10fd4
orb %dl, %cl
jne 0x10ffe
movq %r8, %rcx
negq %rcx
incq %rax
leaq (%rcx,%r15), %rsi
subq %r8, %r15
sbbq %rbx, %r13
cmpq %r13, %rbx
setne %dl
cmpq %rsi, %r8
seta %sil
cmpq %r13, %rbx
jb 0x10fda
orb %sil, %dl
je 0x10fda
movq 0x8(%rsp), %rdi
movzwl %bp, %ecx
shrl $0xf, %ecx
subq %r15, %r8
sbbq %r13, %rbx
cmpq %r13, %rbx
sete %dl
cmpq %r15, %r8
setb %sil
cmpq %r13, %rbx
jb 0x11035
andb %dl, %sil
jne 0x11035
cmpq %r15, %r8
jne 0x1103a
cmpq %r13, %rbx
jne 0x1103a
andl $0x1, %eax
je 0x1103a
xorb $0x1, %cl
jmp 0x11040
movq %r13, %rbx
movq %r15, %r8
leal (%rdi,%r12), %edx
addl $0x40, %edx
movzbl %cl, %esi
movl $0x50, %edi
movq %rbx, %rcx
movq %r14, %r9
callq 0x1106d
movl %edx, %ebp
movl %ebp, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq