// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/softfloat.c
// Function: float64_muladd
float64 float64_muladd(float64 a, float64 b, float64 c, int flags,
                       float_status *status)
{
    flag aSign, bSign, cSign, zSign;
    int_fast16_t aExp, bExp, cExp, pExp, zExp, expDiff;
    uint64_t aSig, bSig, cSig;
    flag pInf, pZero, pSign;
    uint64_t pSig0, pSig1, cSig0, cSig1, zSig0, zSig1;
    int shiftcount;
    flag signflip, infzero;

    a = float64_squash_input_denormal(a, status);
    b = float64_squash_input_denormal(b, status);
    c = float64_squash_input_denormal(c, status);
    aSig = extractFloat64Frac(a);
    aExp = extractFloat64Exp(a);
    aSign = extractFloat64Sign(a);
    bSig = extractFloat64Frac(b);
    bExp = extractFloat64Exp(b);
    bSign = extractFloat64Sign(b);
    cSig = extractFloat64Frac(c);
    cExp = extractFloat64Exp(c);
    cSign = extractFloat64Sign(c);

    infzero = ((aExp == 0 && aSig == 0 && bExp == 0x7ff && bSig == 0) ||
               (aExp == 0x7ff && aSig == 0 && bExp == 0 && bSig == 0));

    /* It is implementation-defined whether the cases of (0,inf,qnan)
     * and (inf,0,qnan) raise InvalidOperation or not (and what QNaN
     * they return if they do), so we have to hand this information
     * off to the target-specific pick-a-NaN routine.
     */
    if (((aExp == 0x7ff) && aSig) ||
        ((bExp == 0x7ff) && bSig) ||
        ((cExp == 0x7ff) && cSig)) {
        return propagateFloat64MulAddNaN(a, b, c, infzero, status);
    }

    if (infzero) {
        float_raise(float_flag_invalid, status);
        return float64_default_nan;
    }

    if (flags & float_muladd_negate_c) {
        cSign ^= 1;
    }

    signflip = (flags & float_muladd_negate_result) ? 1 : 0;

    /* Work out the sign and type of the product */
    pSign = aSign ^ bSign;
    if (flags & float_muladd_negate_product) {
        pSign ^= 1;
    }
    pInf = (aExp == 0x7ff) || (bExp == 0x7ff);
    pZero = ((aExp | aSig) == 0) || ((bExp | bSig) == 0);

    if (cExp == 0x7ff) {
        if (pInf && (pSign ^ cSign)) {
            /* addition of opposite-signed infinities => InvalidOperation */
            float_raise(float_flag_invalid, status);
            return float64_default_nan;
        }
        /* Otherwise generate an infinity of the same sign */
        return packFloat64(cSign ^ signflip, 0x7ff, 0);
    }

    if (pInf) {
        return packFloat64(pSign ^ signflip, 0x7ff, 0);
    }

    if (pZero) {
        if (cExp == 0) {
            if (cSig == 0) {
                /* Adding two exact zeroes */
                if (pSign == cSign) {
                    zSign = pSign;
                } else if (status->float_rounding_mode == float_round_down) {
                    zSign = 1;
                } else {
                    zSign = 0;
                }
                return packFloat64(zSign ^ signflip, 0, 0);
            }
            /* Exact zero plus a denorm */
            if (status->flush_to_zero) {
                float_raise(float_flag_output_denormal, status);
                return packFloat64(cSign ^ signflip, 0, 0);
            }
        }
        /* Zero plus something non-zero : just return the something */
        if (flags & float_muladd_halve_result) {
            if (cExp == 0) {
                normalizeFloat64Subnormal(cSig, &cExp, &cSig);
            }
            /* Subtract one to halve, and one again because roundAndPackFloat64
             * wants one less than the true exponent.
             */
            cExp -= 2;
            cSig = (cSig | 0x0010000000000000ULL) << 10;
            return roundAndPackFloat64(cSign ^ signflip, cExp, cSig, status);
        }
        return packFloat64(cSign ^ signflip, cExp, cSig);
    }

    if (aExp == 0) {
        normalizeFloat64Subnormal(aSig, &aExp, &aSig);
    }
    if (bExp == 0) {
        normalizeFloat64Subnormal(bSig, &bExp, &bSig);
    }

    /* Calculate the actual result a * b + c */

    /* Multiply first; this is easy. */
    /* NB: we subtract 0x3fe where float64_mul() subtracts 0x3ff
     * because we want the true exponent, not the "one-less-than"
     * flavour that roundAndPackFloat64() takes.
     */
    pExp = aExp + bExp - 0x3fe;
    aSig = (aSig | LIT64(0x0010000000000000))<<10;
    bSig = (bSig | LIT64(0x0010000000000000))<<11;
    mul64To128(aSig, bSig, &pSig0, &pSig1);
    if ((int64_t)(pSig0 << 1) >= 0) {
        shortShift128Left(pSig0, pSig1, 1, &pSig0, &pSig1);
        pExp--;
    }

    zSign = pSign ^ signflip;

    /* Now [pSig0:pSig1] is the significand of the multiply, with the explicit
     * bit in position 126.
     */
    if (cExp == 0) {
        if (!cSig) {
            /* Throw out the special case of c being an exact zero now */
            shift128RightJamming(pSig0, pSig1, 64, &pSig0, &pSig1);
            if (flags & float_muladd_halve_result) {
                pExp--;
            }
            return roundAndPackFloat64(zSign, pExp - 1,
                                       pSig1, status);
        }
        normalizeFloat64Subnormal(cSig, &cExp, &cSig);
    }

    /* Shift cSig and add the explicit bit so [cSig0:cSig1] is the
     * significand of the addend, with the explicit bit in position 126.
     */
    cSig0 = cSig << (126 - 64 - 52);
    cSig1 = 0;
    cSig0 |= LIT64(0x4000000000000000);
    expDiff = pExp - cExp;

    if (pSign == cSign) {
        /* Addition */
        if (expDiff > 0) {
            /* scale c to match p */
            shift128RightJamming(cSig0, cSig1, expDiff, &cSig0, &cSig1);
            zExp = pExp;
        } else if (expDiff < 0) {
            /* scale p to match c */
            shift128RightJamming(pSig0, pSig1, -expDiff, &pSig0, &pSig1);
            zExp = cExp;
        } else {
            /* no scaling needed */
            zExp = cExp;
        }
        /* Add significands and make sure explicit bit ends up in posn 126 */
        add128(pSig0, pSig1, cSig0, cSig1, &zSig0, &zSig1);
        if ((int64_t)zSig0 < 0) {
            shift128RightJamming(zSig0, zSig1, 1, &zSig0, &zSig1);
        } else {
            zExp--;
        }
        shift128RightJamming(zSig0, zSig1, 64, &zSig0, &zSig1);
        if (flags & float_muladd_halve_result) {
            zExp--;
        }
        return roundAndPackFloat64(zSign, zExp, zSig1, status);
    } else {
        /* Subtraction */
        if (expDiff > 0) {
            shift128RightJamming(cSig0, cSig1, expDiff, &cSig0, &cSig1);
            sub128(pSig0, pSig1, cSig0, cSig1, &zSig0, &zSig1);
            zExp = pExp;
        } else if (expDiff < 0) {
            shift128RightJamming(pSig0, pSig1, -expDiff, &pSig0, &pSig1);
            sub128(cSig0, cSig1, pSig0, pSig1, &zSig0, &zSig1);
            zExp = cExp;
            zSign ^= 1;
        } else {
            zExp = pExp;
            if (lt128(cSig0, cSig1, pSig0, pSig1)) {
                sub128(pSig0, pSig1, cSig0, cSig1, &zSig0, &zSig1);
            } else if (lt128(pSig0, pSig1, cSig0, cSig1)) {
                sub128(cSig0, cSig1, pSig0, pSig1, &zSig0, &zSig1);
                zSign ^= 1;
            } else {
                /* Exact zero */
                zSign = signflip;
                if (status->float_rounding_mode == float_round_down) {
                    zSign ^= 1;
                }
                return packFloat64(zSign, 0, 0);
            }
        }
        --zExp;
        /* Do the equivalent of normalizeRoundAndPackFloat64() but
         * starting with the significand in a pair of uint64_t.
         */
        if (zSig0) {
            shiftcount = countLeadingZeros64(zSig0) - 1;
            shortShift128Left(zSig0, zSig1, shiftcount, &zSig0, &zSig1);
            if (zSig1) {
                zSig0 |= 1;
            }
            zExp -= shiftcount;
        } else {
            shiftcount = countLeadingZeros64(zSig1);
            if (shiftcount == 0) {
                zSig0 = (zSig1 >> 1) | (zSig1 & 1);
                zExp -= 63;
            } else {
                shiftcount--;
                zSig0 = zSig1 << shiftcount;
                zExp -= (shiftcount + 64);
            }
        }
        if (flags & float_muladd_halve_result) {
            zExp--;
        }
        return roundAndPackFloat64(zSign, zExp, zSig0, status);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r13
movl %ecx, 0xc(%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %r8, %rsi
callq 0x920d
movq %rax, %rbx
movq %r15, %rdi
movq %r13, %rsi
callq 0x920d
movq %rax, %r12
movq %r14, %rdi
movq %r13, 0x10(%rsp)
movq %r13, %rsi
callq 0x920d
movabsq $0xfffffffffffff, %r14  # imm = 0xFFFFFFFFFFFFF
movq %rbx, %rdi
andq %r14, %rdi
movq %rbx, %r13
shrq $0x34, %r13
movl $0x7ff, %r8d            # imm = 0x7FF
andq %r8, %r13
movq %r12, %rsi
andq %r14, %rsi
movq %r12, %rbp
shrq $0x34, %rbp
andq %r8, %rbp
movq %r13, %rcx
orq %rdi, %rcx
cmpq %r8, %rbp
jne 0xd610
movq %rcx, %rdx
orq %rsi, %rdx
jne 0xd610
xorl %edx, %edx
movb $0x1, %r9b
jmp 0xd64d
cmpq $0x7ff, %rbp            # imm = 0x7FF
sete %r10b
cmpl $0x7ff, %r13d           # imm = 0x7FF
sete %dl
movq %rsi, %r9
orq %rdi, %r9
orq %rbp, %r9
sete %r9b
testq %rdi, %rdi
setne %r15b
testq %rsi, %rsi
setne %r11b
testb %dl, %r15b
jne 0xd675
andb %r10b, %r11b
jne 0xd675
andb %dl, %r9b
andq %rax, %r14
movq %rax, %r15
shrq $0x34, %r15
andq %r8, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
setne %r8b
testq %r14, %r14
sete %r10b
orb %r8b, %r10b
jne 0xd76a
movabsq $0x7ff8000000000000, %r15 # imm = 0x7FF8000000000000
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
movq %rbx, %rdx
andq %r15, %rdx
cmpq %rcx, %rdx
sete %sil
movq %rbx, %rdi
shlq $0xd, %rdi
setne %r8b
andb %sil, %r8b
movq %r12, %rsi
andq %r15, %rsi
cmpq %rcx, %rsi
sete %dil
movq %r12, %r9
shlq $0xd, %r9
setne %r10b
andb %dil, %r10b
movq %rax, %rdi
andq %r15, %rdi
cmpq %rcx, %rdi
sete %r9b
movq %rax, %r11
shlq $0xd, %r11
setne %r11b
testb %r8b, %r8b
movq 0x10(%rsp), %r14
jne 0xd6eb
testb %r10b, %r10b
jne 0xd6eb
andb %r11b, %r9b
je 0xd6f0
orb $0x1, 0x2(%r14)
cmpb $0x0, 0x6(%r14)
jne 0xd837
movabsq $-0x10000000000001, %r11 # imm = 0xFFEFFFFFFFFFFFFF
movabsq $0x7ffffffffffff, %r9   # imm = 0x7FFFFFFFFFFFF
leaq (%rbx,%rbx), %r14
leaq (%r12,%r12), %r15
cmpq %r11, %r15
seta %bpl
orb %r10b, %bpl
movzbl %bpl, %ebp
pushq $0x2
popq %r10
subl %ebp, %r10d
xorl %ebp, %ebp
testb %r8b, %r8b
cmovnel %ebp, %r10d
cmpq %r11, %r14
cmoval %ebp, %r10d
leaq 0x1(%r9), %r15
cmpl $0x2, %r10d
je 0xd7f5
cmpl $0x1, %r10d
jne 0xd808
orq %r12, %r15
testq %r9, %r12
cmoveq %r12, %r15
cmpq %rcx, %rsi
cmovneq %r12, %r15
jmp 0xd837
testb %r9b, %r9b
je 0xd787
movabsq $0x7ff8000000000000, %r15 # imm = 0x7FF8000000000000
movq 0x10(%rsp), %rax
orb $0x1, 0x2(%rax)
jmp 0xd837
shrq $0x3f, %rax
cmpq $0x7ff, %rbp            # imm = 0x7FF
sete %r8b
movl 0xc(%rsp), %r9d
movl %r9d, %r11d
andb $0x1, %r11b
xorb %al, %r11b
movl %r9d, %r10d
shrb $0x2, %r10b
andb $0x1, %r10b
xorq %rbx, %r12
shrq $0x3f, %r12
movl %r9d, %ebx
shrb %bl
andb $0x1, %bl
xorb %r12b, %bl
orb %dl, %r8b
testq %rcx, %rcx
sete %al
movq %rbp, %rcx
orq %rsi, %rcx
sete %cl
cmpl $0x7ff, %r15d           # imm = 0x7FF
jne 0xd81b
cmpb %r11b, %bl
setne %al
andb %al, %r8b
cmpb $0x1, %r8b
je 0xd76f
xorb %r10b, %r11b
movzbl %r11b, %eax
jmp 0xd826
orq %rax, %r15
testq %r9, %rax
cmoveq %rax, %r15
cmpq %rcx, %rdi
cmovneq %rax, %r15
jmp 0xd837
orq %rbx, %r15
testq %r9, %rbx
cmoveq %rbx, %r15
cmpq %rcx, %rdx
cmovneq %rbx, %r15
jmp 0xd837
testb %r8b, %r8b
je 0xd849
xorb %r10b, %bl
movzbl %bl, %eax
shlq $0x3f, %rax
movabsq $0x7ff0000000000000, %r15 # imm = 0x7FF0000000000000
orq %rax, %r15
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
orb %cl, %al
pushq $0x1
popq %rdx
je 0xd87c
testq %r15, %r15
je 0xd890
testb $0x8, 0xc(%rsp)
movq 0x10(%rsp), %r8
jne 0xdb28
xorb %r10b, %r11b
movzbl %r11b, %eax
shlq $0x3f, %rax
shlq $0x34, %r15
orq %rax, %r15
orq %r14, %r15
jmp 0xd837
testq %r13, %r13
jne 0xd8c1
testq %rdi, %rdi
je 0xd8ac
bsrq %rdi, %rax
xorq $0x3f, %rax
jmp 0xd8af
testq %r14, %r14
movq 0x10(%rsp), %r8
je 0xd8df
cmpb $0x0, 0x4(%r8)
je 0xdb06
orb $-0x80, 0x2(%r8)
jmp 0xd8ed
pushq $0x40
popq %rax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %rdi
movl %edx, %eax
subl %ecx, %eax
movslq %eax, %r13
testq %rbp, %rbp
movb %r10b, 0xb(%rsp)
movb %r11b, 0xa(%rsp)
jne 0xd912
testq %rsi, %rsi
je 0xd8fd
bsrq %rsi, %rax
xorq $0x3f, %rax
jmp 0xd900
cmpb %r11b, %bl
je 0xd8ed
cmpb $0x1, 0x1(%r8)
sete %r11b
xorb %r10b, %r11b
movzbl %r11b, %r15d
shlq $0x3f, %r15
jmp 0xd837
pushq $0x40
popq %rax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %rsi
movl %edx, %eax
subl %ecx, %eax
movslq %eax, %rbp
shlq $0xa, %rdi
btsq $0x3e, %rdi
shlq $0xb, %rsi
btsq $0x3f, %rsi
leaq 0x20(%rsp), %r12
leaq 0x18(%rsp), %rcx
movq %r12, %rdx
callq 0xd0a6
movq (%r12), %r12
btq $0x3e, %r12
jb 0xd965
addq %r13, %rbp
movq 0x18(%rsp), %rax
leaq (%rax,%rax), %rcx
movq %rcx, 0x18(%rsp)
shldq $0x1, %rax, %r12
movq %r12, 0x20(%rsp)
addq $-0x3ff, %rbp           # imm = 0xFC01
jmp 0xd96f
addq %r13, %rbp
addq $-0x3fe, %rbp           # imm = 0xFC02
movb 0xb(%rsp), %sil
movb 0xa(%rsp), %dl
movl %ebx, %edi
xorb %sil, %dil
testq %r15, %r15
jne 0xd9a5
testq %r14, %r14
je 0xdad9
bsrq %r14, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r14
pushq $0x1
popq %rax
subl %ecx, %eax
movslq %eax, %r15
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
shlq $0xa, %r14
orq %rax, %r14
andq $0x0, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movq %rbp, %rax
subq %r15, %rax
cmpb %dl, %bl
jne 0xda01
testq %rax, %rax
jle 0xda73
leaq 0x30(%rsp), %r15
leaq 0x28(%rsp), %r13
movl %edi, %ebx
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %r13, %r8
callq 0xdc4f
movl %ebx, %edi
movq (%r15), %r14
movq (%r13), %rax
jmp 0xdb75
testq %rax, %rax
jle 0xda80
leaq 0x30(%rsp), %r15
leaq 0x28(%rsp), %r13
movl %edi, %ebx
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %r13, %r8
callq 0xdc4f
movl %ebx, %edi
movq 0x18(%rsp), %rdx
subq (%r13), %rdx
sbbq (%r15), %r12
testq %r12, %r12
je 0xdac3
bsrq %r12, %rax
xorq $0x3f, %rax
leaq -0x1(%rax), %rcx
movq %rdx, %rsi
shlq %cl, %rsi
testq %rcx, %rcx
je 0xda60
shlq %cl, %r12
movb $0x1, %cl
subb %al, %cl
shrq %cl, %rdx
orq %rdx, %r12
xorl %edx, %edx
testq %rsi, %rsi
setne %dl
orq %r12, %rdx
subq %rax, %rbp
jmp 0xdc03
js 0xdb4a
xorl %eax, %eax
jmp 0xdb72
movq 0x18(%rsp), %rdx
js 0xdba2
cmpq %r12, %r14
sete %al
testq %rdx, %rdx
setne %cl
cmpq %r12, %r14
jb 0xdc2f
andb %cl, %al
jne 0xdc2f
cmpq %r14, %r12
jae 0xdc37
negq %rdx
sbbq %r12, %r14
xorb $0x1, %dil
movq %r14, %r12
jmp 0xda33
testq %rdx, %rdx
je 0xdbe0
bsrq %rdx, %rax
xorq $0x3f, %rax
jmp 0xdbe3
xorl %eax, %eax
cmpq $0x0, 0x18(%rsp)
setne %al
orq %rax, %r12
movl 0xc(%rsp), %eax
shll $0x1c, %eax
sarl $0x1f, %eax
cltq
leaq (%rax,%rbp), %rsi
decq %rsi
movzbl %dil, %edi
movq %r12, %rdx
jmp 0xdc17
testb $0x8, 0xc(%rsp)
je 0xd865
bsrq %r14, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r14
subl %ecx, %edx
movslq %edx, %r15
addq $-0x2, %r15
shlq $0xa, %r14
btsq $0x3e, %r14
xorb %r10b, %r11b
movzbl %r11b, %edi
movq %r15, %rsi
movq %r14, %rdx
movq %r8, %rcx
jmp 0xdc1c
leaq 0x18(%rsp), %r8
movq (%r8), %rsi
negq %rax
leaq 0x20(%rsp), %r13
movl %edi, %ebx
movq %r12, %rdi
movq %rax, %rdx
movq %r13, %rcx
callq 0xdc4f
movl %ebx, %edi
xorl %eax, %eax
movq (%r13), %r12
movq %r15, %rbp
addq 0x18(%rsp), %rax
adcq %r12, %r14
js 0xdb84
decq %rbp
jmp 0xdb95
movq %r14, %rcx
shldq $0x3f, %rax, %rcx
andl $0x1, %eax
orq %rcx, %rax
shrq %r14
xorl %edx, %edx
testq %rax, %rax
setne %dl
orq %r14, %rdx
jmp 0xdc03
negq %rax
leaq 0x20(%rsp), %rbp
leaq 0x18(%rsp), %r13
movl %edi, %ebx
movq %r12, %rdi
movq %rdx, %rsi
movq %rax, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0xdc4f
movl %ebx, %edi
xorl %edx, %edx
subq (%r13), %rdx
sbbq (%rbp), %r14
xorb $0x1, %dil
movq %r14, %r12
movq %r15, %rbp
jmp 0xda33
pushq $0x40
popq %rax
testq %rax, %rax
je 0xdbf3
leal -0x1(%rax), %ecx
shlq %cl, %rdx
subq %rax, %rbp
jmp 0xdbff
movq %rdx, %rax
shrq %rax
andl $0x1, %edx
orq %rax, %rdx
addq $-0x40, %rbp
movl 0xc(%rsp), %eax
shll $0x1c, %eax
sarl $0x1f, %eax
movslq %eax, %rsi
addq %rbp, %rsi
movzbl %dil, %edi
movq 0x10(%rsp), %rcx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x973e
subq %r14, %r12
jmp 0xda33
movq 0x10(%rsp), %rax
cmpb $0x1, 0x1(%rax)
sete %al
xorb %al, %sil
movzbl %sil, %r15d
jmp 0xd8f4