// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/softfloat.c
// Function: float128_rem
float128 float128_rem(float128 a, float128 b, float_status *status)
{
    flag aSign, zSign;
    int32 aExp, bExp, expDiff;
    uint64_t aSig0, aSig1, bSig0, bSig1, q, term0, term1, term2;
    uint64_t allZero, alternateASig0, alternateASig1, sigMean1;
    int64_t sigMean0;
    float128 z;

    aSig1 = extractFloat128Frac1( a );
    aSig0 = extractFloat128Frac0( a );
    aExp = extractFloat128Exp( a );
    aSign = extractFloat128Sign( a );
    bSig1 = extractFloat128Frac1( b );
    bSig0 = extractFloat128Frac0( b );
    bExp = extractFloat128Exp( b );
    if ( aExp == 0x7FFF ) {
        if (    ( aSig0 | aSig1 )
             || ( ( bExp == 0x7FFF ) && ( bSig0 | bSig1 ) ) ) {
            return propagateFloat128NaN(a, b, status);
        }
        goto invalid;
    }
    if ( bExp == 0x7FFF ) {
        if (bSig0 | bSig1) {
            return propagateFloat128NaN(a, b, status);
        }
        return a;
    }
    if ( bExp == 0 ) {
        if ( ( bSig0 | bSig1 ) == 0 ) {
 invalid:
            float_raise(float_flag_invalid, status);
            z.low = float128_default_nan_low;
            z.high = float128_default_nan_high;
            return z;
        }
        normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 );
    }
    if ( aExp == 0 ) {
        if ( ( aSig0 | aSig1 ) == 0 ) return a;
        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
    }
    expDiff = aExp - bExp;
    if ( expDiff < -1 ) return a;
    shortShift128Left(
        aSig0 | LIT64( 0x0001000000000000 ),
        aSig1,
        15 - ( expDiff < 0 ),
        &aSig0,
        &aSig1
    );
    shortShift128Left(
        bSig0 | LIT64( 0x0001000000000000 ), bSig1, 15, &bSig0, &bSig1 );
    q = le128( bSig0, bSig1, aSig0, aSig1 );
    if ( q ) sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 );
    expDiff -= 64;
    while ( 0 < expDiff ) {
        q = estimateDiv128To64( aSig0, aSig1, bSig0 );
        q = ( 4 < q ) ? q - 4 : 0;
        mul128By64To192( bSig0, bSig1, q, &term0, &term1, &term2 );
        shortShift192Left( term0, term1, term2, 61, &term1, &term2, &allZero );
        shortShift128Left( aSig0, aSig1, 61, &aSig0, &allZero );
        sub128( aSig0, 0, term1, term2, &aSig0, &aSig1 );
        expDiff -= 61;
    }
    if ( -64 < expDiff ) {
        q = estimateDiv128To64( aSig0, aSig1, bSig0 );
        q = ( 4 < q ) ? q - 4 : 0;
        q >>= - expDiff;
        shift128Right( bSig0, bSig1, 12, &bSig0, &bSig1 );
        expDiff += 52;
        if ( expDiff < 0 ) {
            shift128Right( aSig0, aSig1, - expDiff, &aSig0, &aSig1 );
        }
        else {
            shortShift128Left( aSig0, aSig1, expDiff, &aSig0, &aSig1 );
        }
        mul128By64To192( bSig0, bSig1, q, &term0, &term1, &term2 );
        sub128( aSig0, aSig1, term1, term2, &aSig0, &aSig1 );
    }
    else {
        shift128Right( aSig0, aSig1, 12, &aSig0, &aSig1 );
        shift128Right( bSig0, bSig1, 12, &bSig0, &bSig1 );
    }
    do {
        alternateASig0 = aSig0;
        alternateASig1 = aSig1;
        ++q;
        sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 );
    } while ( 0 <= (int64_t) aSig0 );
    add128(
        aSig0, aSig1, alternateASig0, alternateASig1, (uint64_t *)&sigMean0, &sigMean1 );
    if (    ( sigMean0 < 0 )
         || ( ( ( sigMean0 | sigMean1 ) == 0 ) && ( q & 1 ) ) ) {
        aSig0 = alternateASig0;
        aSig1 = alternateASig1;
    }
    zSign = ( (int64_t) aSig0 < 0 );
    if ( zSign ) sub128( 0, 0, aSig0, aSig1, &aSig0, &aSig1 );
    return normalizeRoundAndPackFloat128(aSign ^ zSign, bExp - 4, aSig0, aSig1,
                                         status);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, %rbp
movq %rsi, %r13
movq %rdi, %r14
movabsq $0xffffffffffff, %r12   # imm = 0xFFFFFFFFFFFF
movq %rdi, 0x48(%rsp)
movq %rsi, %r15
andq %r12, %r15
movq %r15, 0x50(%rsp)
movq %rsi, %rbx
shrq $0x30, %rbx
movl $0x7fff, %esi           # imm = 0x7FFF
andl %esi, %ebx
movl %ebx, 0x2c(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, %rdi
andq %r12, %rdi
movq %rdi, 0x40(%rsp)
movq %rcx, %rax
shrq $0x30, %rax
andl %esi, %eax
movl %eax, 0x4(%rsp)
cmpl %esi, %ebx
jne 0x11c6b
orq %r14, %r15
jne 0x11c7b
cmpl $0x7fff, %eax           # imm = 0x7FFF
setne %al
orq %rdx, %rdi
sete %sil
orb %al, %sil
je 0x11c7b
jmp 0x11e03
testl %eax, %eax
je 0x11ca4
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x11cca
orq %rdx, %rdi
je 0x11c8f
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %r8
callq 0x10ca1
movq %rax, %r14
movq %rdx, %r13
movq %r14, %rax
movq %r13, %rdx
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rax
orq %rdx, %rax
je 0x11e03
leaq 0x4(%rsp), %rax
leaq 0x40(%rsp), %rcx
leaq 0x38(%rsp), %r8
movq %rdx, %rsi
movq %rax, %rdx
callq 0x1092e
testl %ebx, %ebx
jne 0x11cf5
movq %r15, %rax
orq %r14, %rax
je 0x11c8f
leaq 0x2c(%rsp), %rbx
leaq 0x50(%rsp), %rcx
leaq 0x48(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1092e
movl (%rbx), %ebx
movl 0x4(%rsp), %esi
subl %esi, %ebx
cmpl $-0x1, %ebx
jl 0x11c8f
movq %rbp, 0x58(%rsp)
movq %r13, 0x60(%rsp)
incq %r12
orq 0x50(%rsp), %r12
movq 0x48(%rsp), %r15
cmpl $-0x1, %ebx
sete %al
movl %eax, %ecx
xorb $0xf, %cl
movq %r15, %r13
shlq %cl, %r13
shlq %cl, %r12
addb $0x31, %al
movl %eax, %ecx
shrq %cl, %r15
orq %r12, %r15
movq 0x40(%rsp), %r12
movq 0x38(%rsp), %rax
movq %rax, %rdi
shlq $0xf, %rdi
movq %rax, 0x8(%rsp)
shldq $0xf, %rax, %r12
btsq $0x3f, %r12
cmpq %r12, %r15
seta %al
sete %cl
cmpq %rdi, %r13
setae %dl
andb %cl, %dl
orb %al, %dl
movzbl %dl, %ebp
cmpb $0x1, %bpl
movl %esi, 0x28(%rsp)
movq %rdi, 0x18(%rsp)
jne 0x11d80
subq %rdi, %r13
sbbq %r12, %r15
shrq $0x31, 0x8(%rsp)
leal -0x40(%rbx), %r14d
testl %r14d, %r14d
jle 0x11e19
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xadbc
movq %rax, %rbp
subq $0x4, %rbp
movl $0x0, %eax
cmovbq %rax, %rbp
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
leaq 0x30(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x20(%rsp), %r9
callq 0x11b64
movq 0x30(%rsp), %rax
movq 0x10(%rsp), %rcx
shldq $0x3d, %r13, %r15
movq 0x20(%rsp), %r13
shldq $0x3d, %rcx, %rax
shrdq $0x3, %rcx, %r13
movq %r13, 0x20(%rsp)
movq %rax, 0x10(%rsp)
negq %r13
sbbq %rax, %r15
addl $-0x3d, %ebx
jmp 0x11d86
orb $0x1, 0x2(%rbp)
movabsq $0x7fff800000000000, %r13 # imm = 0x7FFF800000000000
xorl %r14d, %r14d
jmp 0x11c8f
cmpl $-0x3f, %r14d
jl 0x11e78
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xadbc
xorl %ebp, %ebp
subq $0x4, %rax
cmovaeq %rax, %rbp
movl %ebx, %ecx
negb %cl
shrq %cl, %rbp
shrq $0xc, %r12
movq 0x18(%rsp), %rax
shldq $0x34, %rax, 0x8(%rsp)
cmpl $-0x35, %r14d
jg 0x11e99
movb $0xc, %al
subb %bl, %al
movq %r15, %rdx
movl %eax, %ecx
shrq %cl, %rdx
addb $-0xc, %bl
movl %ebx, %ecx
shlq %cl, %r15
movl %eax, %ecx
shrq %cl, %r13
orq %r15, %r13
movq %r13, %r14
movq %rdx, %r15
jmp 0x11eb2
shrdq $0xc, %r15, %r13
shrq $0xc, %r15
shrq $0xc, %r12
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %rax
shldq $0x34, %rax, %rbx
movq %r13, %r14
jmp 0x11ee3
leal -0xc(%rbx), %ecx
movq %r13, %r14
shlq %cl, %r14
cmpl $0xc, %ebx
je 0x11eb2
shlq %cl, %r15
negb %cl
shrq %cl, %r13
orq %r13, %r15
leaq 0x30(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0x20(%rsp), %r13
movq %r12, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %r9
callq 0x11b64
subq (%r13), %r14
leaq 0x10(%rsp), %rax
sbbq (%rax), %r15
leaq (%rbx,%r14), %rcx
leaq (%rbx,%r14,2), %rax
leaq (%rbx,%rbx), %rdx
decq %rbp
movq 0x60(%rsp), %rsi
movq %r15, %rdi
subq %rdx, %rax
subq %r12, %r15
subq %rbx, %rcx
incq %rbp
subq %rbx, %r14
sbbq $0x0, %r15
jns 0x11ef7
leaq (%r15,%rdi), %rdx
cmpq %r14, %rax
adcq $0x0, %rdx
js 0x11f27
orq %rax, %rdx
andl $0x1, %ebp
orq %rdx, %rbp
jne 0x11f35
movq %rdi, %r15
movq %rcx, %r14
movq %rdi, %rdx
testq %rdi, %rdi
jns 0x11f46
xorl %edx, %edx
negq %r14
sbbq %rdx, %rdx
subq %r15, %rdx
movq %r15, %rdi
movq %r14, %rcx
xorq %rsi, %rdi
shrq $0x3f, %rdi
movl 0x28(%rsp), %esi
addl $-0x4, %esi
movq 0x58(%rsp), %r8
callq 0x98e4
jmp 0x11c89