// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: float64_to_float16
float16 float64_to_float16(float64 a, flag ieee, float_status *status)
{
    flag aSign;
    int_fast16_t aExp;
    uint64_t aSig;
    uint32_t zSig;

    a = float64_squash_input_denormal(a, status);

    aSig = extractFloat64Frac(a);
    aExp = extractFloat64Exp(a);
    aSign = extractFloat64Sign(a);
    if (aExp == 0x7FF) {
        if (aSig) {
            /* Input is a NaN */
            if (!ieee) {
                float_raise(float_flag_invalid, status);
                return packFloat16(aSign, 0, 0);
            }
            return commonNaNToFloat16(
                float64ToCommonNaN(a, status), status);
        }
        /* Infinity */
        if (!ieee) {
            float_raise(float_flag_invalid, status);
            return packFloat16(aSign, 0x1f, 0x3ff);
        }
        return packFloat16(aSign, 0x1f, 0);
    }
    shift64RightJamming(aSig, 29, &aSig);
    zSig = aSig;
    if (aExp == 0 && zSig == 0) {
        return packFloat16(aSign, 0, 0);
    }
    /* Decimal point between bits 22 and 23. Note that we add the 1 bit
     * even if the input is denormal; however this is harmless because
     * the largest possible single-precision denormal is still smaller
     * than the smallest representable half-precision denormal, and so we
     * will end up ignoring aSig and returning via the "always return zero"
     * codepath.
     */
    zSig |= 0x00800000;
    aExp -= 0x3F1;

    return roundAndPackFloat16(aSign, aExp, zSig, ieee, status);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x11610
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x116a0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11680
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x168f0
movb %al, -0x21(%rbp)
cmpq $0x7ff, -0x30(%rbp)     # imm = 0x7FF
jne 0x17854
cmpq $0x0, -0x38(%rbp)
je 0x1780e
cmpb $0x0, -0x11(%rbp)
jne 0x177ce
movq -0x20(%rbp), %rsi
movl $0x1, %edi
callq 0x11080
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movzbl -0x21(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x178c8
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x16f00
movq -0x20(%rbp), %rdi
leaq -0x58(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x17330
movw %ax, -0x2(%rbp)
jmp 0x178c8
cmpb $0x0, -0x11(%rbp)
jne 0x1783e
movq -0x20(%rbp), %rsi
movl $0x1, %edi
callq 0x11080
movl $0x1f, %esi
movl $0x3ff, %edx            # imm = 0x3FF
movzbl -0x21(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x178c8
movl $0x1f, %esi
xorl %edx, %edx
movzbl -0x21(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x178c8
movq -0x38(%rbp), %rdi
movl $0x1d, %esi
leaq -0x38(%rbp), %rdx
callq 0x11c20
movq -0x38(%rbp), %rax
movl %eax, -0x3c(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1788f
cmpl $0x0, -0x3c(%rbp)
jne 0x1788f
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movzbl -0x21(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x178c8
movl -0x3c(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
subq $0x3f1, %rax            # imm = 0x3F1
movq %rax, -0x30(%rbp)
movb -0x21(%rbp), %cl
movq -0x30(%rbp), %rsi
movl -0x3c(%rbp), %edx
movb -0x11(%rbp), %al
movq -0x20(%rbp), %r8
movzbl %cl, %edi
movzbl %al, %ecx
callq 0x17390
movw %ax, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)