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

    a = float32_squash_input_denormal(a, status);

    aSig = extractFloat32Frac( a );
    aExp = extractFloat32Exp( a );
    aSign = extractFloat32Sign( a );
    if ( aExp == 0xFF ) {
        if (aSig) {
            /* Input is a NaN */
            if (!ieee) {
                float_raise(float_flag_invalid, status);
                return packFloat16(aSign, 0, 0);
            }
            return commonNaNToFloat16(
                float32ToCommonNaN(a, status), status);
        }
        /* Infinity */
        if (!ieee) {
            float_raise(float_flag_invalid, status);
            return packFloat16(aSign, 0x1f, 0x3ff);
        }
        return packFloat16(aSign, 0x1f, 0);
    }
    if (aExp == 0 && aSig == 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.
     */
    aSig |= 0x00800000;
    aExp -= 0x71;

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %sil, %al
movl %edi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movl -0x8(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x11570
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %edi
callq 0x115f0
movl %eax, -0x2c(%rbp)
movl -0x8(%rbp), %edi
callq 0x115d0
movq %rax, -0x28(%rbp)
movl -0x8(%rbp), %edi
callq 0x12810
movb %al, -0x19(%rbp)
cmpq $0xff, -0x28(%rbp)
jne 0x17298
cmpl $0x0, -0x2c(%rbp)
je 0x17255
cmpb $0x0, -0x9(%rbp)
jne 0x17216
movq -0x18(%rbp), %rsi
movl $0x1, %edi
callq 0x11080
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movzbl -0x19(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x172f1
movl -0x8(%rbp), %esi
movq -0x18(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x13550
movq -0x18(%rbp), %rdi
leaq -0x48(%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 0x172f1
cmpb $0x0, -0x9(%rbp)
jne 0x17282
movq -0x18(%rbp), %rsi
movl $0x1, %edi
callq 0x11080
movl $0x1f, %esi
movl $0x3ff, %edx            # imm = 0x3FF
movzbl -0x19(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x172f1
movl $0x1f, %esi
xorl %edx, %edx
movzbl -0x19(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x172f1
cmpq $0x0, -0x28(%rbp)
jne 0x172ba
cmpl $0x0, -0x2c(%rbp)
jne 0x172ba
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movzbl -0x19(%rbp), %edi
callq 0x17300
movw %ax, -0x2(%rbp)
jmp 0x172f1
movl -0x2c(%rbp), %eax
orl $0x800000, %eax         # imm = 0x800000
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
subq $0x71, %rax
movq %rax, -0x28(%rbp)
movb -0x19(%rbp), %cl
movq -0x28(%rbp), %rsi
movl -0x2c(%rbp), %edx
movb -0x9(%rbp), %al
movq -0x18(%rbp), %r8
movzbl %cl, %edi
movzbl %al, %ecx
callq 0x17390
movw %ax, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)