// File: /workspace/github_c_makefile_star2_O1/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
movabsq $0x7ff0000000000000, %r11 # imm = 0x7FF0000000000000
movabsq $0xfffffffffffff, %rbx  # imm = 0xFFFFFFFFFFFFF
movb 0x5(%r8), %al
testb %al, %al
je 0xe5f5
testq %r11, %rdi
setne %r10b
testq %rbx, %rdi
sete %r9b
orb %r10b, %r9b
jne 0xe5f5
orb $0x40, 0x2(%r8)
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
andq %r9, %rdi
testb %al, %al
je 0xe61e
testq %r11, %rsi
setne %r10b
testq %rbx, %rsi
sete %r9b
orb %r10b, %r9b
jne 0xe61e
orb $0x40, 0x2(%r8)
movabsq $-0x8000000000000000, %r9 # imm = 0x8000000000000000
andq %r9, %rsi
testb %al, %al
movq %r8, 0x8(%rsp)
je 0xe64b
testq %r11, %rdx
setne %al
testq %rbx, %rdx
sete %r9b
orb %al, %r9b
jne 0xe64b
orb $0x40, 0x2(%r8)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rdx
movq %rdi, %r11
andq %rbx, %r11
movq %rdi, %r10
shrq $0x34, %r10
movl $0x7ff, %r14d           # imm = 0x7FF
andq %r14, %r10
movq %rsi, %r13
andq %rbx, %r13
movq %rsi, %r12
shrq $0x34, %r12
andq %r14, %r12
movq %r10, %r8
orq %r11, %r8
orq %r13, %r8
movl %ecx, 0x34(%rsp)
jne 0xe691
cmpl $0x7ff, %r12d           # imm = 0x7FF
jne 0xe691
movq %rbx, %rax
xorl %r8d, %r8d
jmp 0xe6ae
movq %rbx, %rax
movq %r10, %r8
xorq $0x7ff, %r8             # imm = 0x7FF
movq %r13, %r9
orq %r11, %r9
orq %r12, %r9
orq %r8, %r9
setne %r8b
movl $0x7ff, %r15d           # imm = 0x7FF
cmpl %r15d, %r12d
sete %r9b
cmpl %r15d, %r10d
sete %bpl
testq %r11, %r11
setne %bl
testq %r13, %r13
setne %r15b
testb %bpl, %bl
jne 0xe700
andb %r9b, %r15b
jne 0xe700
movq %rdx, %r15
shrq $0x34, %r15
andq %rdx, %rax
andq %r14, %r15
cmpl $0x7ff, %r15d           # imm = 0x7FF
setne %cl
testq %rax, %rax
sete %r9b
orb %cl, %r9b
jne 0xe7ed
movabsq $0x7ff8000000000000, %r15 # imm = 0x7FF8000000000000
movq %rdi, %rcx
andq %r15, %rcx
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
cmpq %rax, %rcx
sete %r8b
movq %rdi, %r9
shlq $0xd, %r9
setne %r10b
andb %r8b, %r10b
movq %rsi, %r8
andq %r15, %r8
cmpq %rax, %r8
sete %r9b
movq %rsi, %r11
shlq $0xd, %r11
setne %bpl
andb %r9b, %bpl
movq %rdx, %r9
andq %r15, %r9
cmpq %rax, %r9
sete %r11b
movq %rdx, %rbx
shlq $0xd, %rbx
setne %r14b
testb %r10b, %r10b
movq 0x8(%rsp), %rbx
jne 0xe776
testb %bpl, %bpl
jne 0xe776
andb %r14b, %r11b
je 0xe77a
orb $0x1, 0x2(%rbx)
cmpb $0x0, 0x6(%rbx)
jne 0xe8bd
movabsq $-0x10000000000001, %r14 # imm = 0xFFEFFFFFFFFFFFFF
movabsq $0x7ffffffffffff, %r11  # imm = 0x7FFFFFFFFFFFF
leaq (%rdi,%rdi), %r15
leaq (%rsi,%rsi), %rbx
cmpq %r14, %rbx
seta %bl
orb %bpl, %bl
movzbl %bl, %ebp
movl $0x2, %ebx
subl %ebp, %ebx
xorl %ebp, %ebp
testb %r10b, %r10b
cmovnel %ebp, %ebx
cmpq %r14, %r15
cmoval %ebp, %ebx
leaq 0x1(%r11), %r15
cmpl $0x2, %ebx
je 0xe872
cmpl $0x1, %ebx
jne 0xe885
orq %rsi, %r15
testq %r11, %rsi
cmoveq %rsi, %r15
cmpq %rax, %r8
cmovneq %rsi, %r15
jmp 0xe8bd
testb %r8b, %r8b
je 0xe85d
shrq $0x3f, %rdx
movl $0x7ff, %ecx            # imm = 0x7FF
cmpq %rcx, %r10
sete %bl
cmpq %rcx, %r12
sete %cl
movl 0x34(%rsp), %ebp
movl %ebp, %r9d
andb $0x1, %r9b
xorb %dl, %r9b
movl %ebp, %r8d
shrb $0x2, %r8b
andb $0x1, %r8b
xorq %rdi, %rsi
shrq $0x3f, %rsi
movl %ebp, %edx
shrb %dl
andb $0x1, %dl
xorb %sil, %dl
orb %bl, %cl
movq %r10, %rsi
orq %r11, %rsi
sete %sil
movq %r12, %rdi
orq %r13, %rdi
sete %dil
cmpl $0x7ff, %r15d           # imm = 0x7FF
jne 0xe898
cmpb %r9b, %dl
setne %dl
andb %dl, %cl
cmpb $0x1, %cl
jne 0xe8a5
movabsq $0x7ff8000000000000, %r15 # imm = 0x7FF8000000000000
movq 0x8(%rsp), %rax
orb $0x1, 0x2(%rax)
jmp 0xe8bd
orq %rdx, %r15
testq %r11, %rdx
cmoveq %rdx, %r15
cmpq %rax, %r9
cmovneq %rdx, %r15
jmp 0xe8bd
orq %rdi, %r15
testq %r11, %rdi
cmoveq %rdi, %r15
cmpq %rax, %rcx
cmovneq %rdi, %r15
jmp 0xe8bd
testb %cl, %cl
je 0xe8cf
xorb %r8b, %dl
movzbl %dl, %r15d
jmp 0xe8ac
xorb %r8b, %r9b
movzbl %r9b, %r15d
shlq $0x3f, %r15
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
orq %rax, %r15
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
orb %dil, %sil
je 0xe8fe
testq %r15, %r15
movq 0x8(%rsp), %r10
je 0xe912
testb $0x8, %bpl
jne 0xe92c
xorb %r8b, %r9b
movzbl %r9b, %eax
shlq $0x3f, %rax
shlq $0x34, %r15
orq %rax, %r15
orq %r14, %r15
jmp 0xe8bd
testq %r10, %r10
jne 0xe957
testq %r11, %r11
je 0xe93d
bsrq %r11, %rax
xorq $0x3f, %rax
jmp 0xe942
testq %r14, %r14
je 0xe96b
cmpb $0x0, 0x4(%r10)
je 0xe8e1
orb $-0x80, 0x2(%r10)
xorb %r8b, %r9b
movzbl %r9b, %r15d
jmp 0xe97f
testq %r15, %r15
je 0xec2a
movq %r14, %rdx
jmp 0xece2
movl $0x40, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r11
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %r10
testq %r12, %r12
jne 0xe9a2
testq %r13, %r13
je 0xe988
bsrq %r13, %rax
xorq $0x3f, %rax
jmp 0xe98d
cmpb %r9b, %dl
je 0xe978
cmpb $0x1, 0x1(%r10)
sete %dl
xorb %r8b, %dl
movzbl %dl, %r15d
shlq $0x3f, %r15
jmp 0xe8bd
movl $0x40, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r13
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %r12
shlq $0xa, %r11
movq %r11, %rcx
btsq $0x3e, %rcx
shlq $0xb, %r13
movq %r13, %rax
btsq $0x3f, %rax
movq %rcx, %rsi
shrq $0x20, %rsi
movq %rax, %rdi
shrq $0x20, %rdi
movl %r11d, %r11d
movl %r13d, %ebx
imulq %rdi, %r11
imulq %rsi, %rbx
imulq %rsi, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
incq %rsi
xorl %r13d, %r13d
addq %r11, %rbx
cmovbq %rsi, %r13
movq %rbx, %rsi
shrq $0x20, %rsi
addq %rdi, %rsi
shlq $0x20, %rbx
imulq %rcx, %rax
cmpq %rbx, %rax
adcq %r13, %rsi
movq %rax, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
btq $0x3e, %rsi
jb 0xea34
addq %r10, %r12
leaq (%rax,%rax), %rcx
movq %rcx, 0x10(%rsp)
shldq $0x1, %rax, %rsi
movq %rsi, 0x18(%rsp)
addq $-0x3ff, %r12           # imm = 0xFC01
jmp 0xea3e
addq %r10, %r12
addq $-0x3fe, %r12           # imm = 0xFC02
movl %edx, %r13d
xorb %r8b, %r13b
testq %r15, %r15
jne 0xea6e
testq %r14, %r14
je 0xebf7
bsrq %r14, %rax
xorl $0x3f, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %r14
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %r15
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
shlq $0xa, %r14
orq %rax, %r14
movq $0x0, 0x20(%rsp)
movq %r14, %rbx
movq %r14, 0x28(%rsp)
movq %r12, %rax
subq %r15, %rax
cmpb %r9b, %dl
jne 0xeac0
testq %rax, %rax
jle 0xeb3d
leaq 0x28(%rsp), %rcx
leaq 0x20(%rsp), %r8
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0xed27
jmp 0xeb5d
testq %rax, %rax
jle 0xeb78
leaq 0x28(%rsp), %r15
movl %r13d, %r14d
leaq 0x20(%rsp), %r13
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %r13, %r8
callq 0xed27
movq 0x10(%rsp), %rdx
subq (%r13), %rdx
movl %r14d, %r13d
movq 0x18(%rsp), %rdi
sbbq (%r15), %rdi
testq %rdi, %rdi
je 0xebe1
bsrq %rdi, %rax
xorq $0x3f, %rax
leaq -0x1(%rax), %rcx
movq %rdx, %rsi
shlq %cl, %rsi
testq %rcx, %rcx
je 0xeb2a
shlq %cl, %rdi
movb $0x1, %cl
subb %al, %cl
shrq %cl, %rdx
orq %rdx, %rdi
xorl %edx, %edx
testq %rsi, %rsi
setne %dl
orq %rdi, %rdx
subq %rax, %r12
jmp 0xeca9
jns 0xeb5a
leaq 0x18(%rsp), %rcx
movq (%rcx), %rdi
leaq 0x10(%rsp), %r8
movq (%r8), %rsi
negq %rax
movq %rax, %rdx
callq 0xed27
movq %r15, %r12
movq 0x20(%rsp), %rcx
addq 0x10(%rsp), %rcx
movq 0x28(%rsp), %rax
adcq 0x18(%rsp), %rax
js 0xebc0
decq %r12
jmp 0xebd1
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rdx
js 0xec43
cmpq %rdi, %rbx
sete %al
testq %rdx, %rdx
setne %cl
cmpq %rdi, %rbx
jb 0xecc0
andb %cl, %al
jne 0xecc0
cmpq %rbx, %rdi
jae 0xed0f
negq %rdx
sbbq %rdi, %rbx
xorb $0x1, %r13b
movq %rbx, %rdi
jmp 0xeafd
movq %rax, %rdx
shldq $0x3f, %rcx, %rdx
andl $0x1, %ecx
orq %rdx, %rcx
shrq %rax
xorl %edx, %edx
testq %rcx, %rcx
setne %dl
orq %rax, %rdx
jmp 0xeca9
testq %rdx, %rdx
je 0xec80
bsrq %rdx, %rax
xorq $0x3f, %rax
jmp 0xec85
xorl %edx, %edx
cmpq $0x0, 0x10(%rsp)
setne %dl
orq 0x18(%rsp), %rdx
movq %rdx, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
shll $0x1c, %ebp
sarl $0x1f, %ebp
movslq %ebp, %rax
leaq (%rax,%r12), %rsi
decq %rsi
jmp 0xecb5
movq %r14, %rdx
testq %r14, %r14
je 0xecc8
bsrq %rdx, %rax
xorq $0x3f, %rax
jmp 0xeccd
negq %rax
leaq 0x18(%rsp), %r12
movl %r13d, %r14d
leaq 0x10(%rsp), %r13
movq %rdx, %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0xed27
xorl %edx, %edx
subq (%r13), %rdx
movl %r14d, %r13d
sbbq (%r12), %rbx
xorb $0x1, %r13b
movq %rbx, %rdi
movq %r15, %r12
jmp 0xeafd
movl $0x40, %eax
testq %rax, %rax
je 0xec99
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %eax, %ecx
shlq %cl, %rdx
subq %rax, %r12
jmp 0xeca5
movq %rdx, %rax
shrq %rax
andl $0x1, %edx
orq %rax, %rdx
addq $-0x40, %r12
shll $0x1c, %ebp
sarl $0x1f, %ebp
movslq %ebp, %rsi
addq %r12, %rsi
movzbl %r13b, %edi
movq 0x8(%rsp), %rcx
jmp 0xecfc
subq %rbx, %rdi
jmp 0xeafd
movl $0x40, %eax
addl $0xf5, %eax
movzbl %al, %ecx
shlq %cl, %rdx
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %r15
addq $-0x2, %r15
shlq $0xa, %rdx
btsq $0x3e, %rdx
xorb %r8b, %r9b
movzbl %r9b, %edi
movq %r15, %rsi
movq %r10, %rcx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa1a9
movq 0x8(%rsp), %rax
cmpb $0x1, 0x1(%rax)
sete %al
xorb %al, %r8b
movzbl %r8b, %r15d
jmp 0xe97f