// File: /workspace/github_c_makefile_star2_O1/mbitsnbites[P]SoftFP/softfloat.c
// Function: roundAndPackFloat32
static float32 roundAndPackFloat32(flag zSign, int_fast16_t zExp, uint32_t zSig,
                                   float_status *status)
{
    int8 roundingMode;
    flag roundNearestEven;
    int8 roundIncrement, roundBits;
    flag isTiny;

    roundingMode = status->float_rounding_mode;
    roundNearestEven = ( roundingMode == float_round_nearest_even );
    switch (roundingMode) {
    case float_round_nearest_even:
    case float_round_ties_away:
        roundIncrement = 0x40;
        break;
    case float_round_to_zero:
        roundIncrement = 0;
        break;
    case float_round_up:
        roundIncrement = zSign ? 0 : 0x7f;
        break;
    case float_round_down:
        roundIncrement = zSign ? 0x7f : 0;
        break;
    default:
        abort();
        break;
    }
    roundBits = zSig & 0x7F;
    if ( 0xFD <= (uint16_t) zExp ) {
        if (    ( 0xFD < zExp )
             || (    ( zExp == 0xFD )
                  && ( (int32_t) ( zSig + roundIncrement ) < 0 ) )
           ) {
            float_raise(float_flag_overflow | float_flag_inexact, status);
            return packFloat32( zSign, 0xFF, - ( roundIncrement == 0 ));
        }
        if ( zExp < 0 ) {
            if (status->flush_to_zero) {
                float_raise(float_flag_output_denormal, status);
                return packFloat32(zSign, 0, 0);
            }
            isTiny =
                (status->float_detect_tininess
                 == float_tininess_before_rounding)
                || ( zExp < -1 )
                || ( zSig + roundIncrement < 0x80000000 );
            shift32RightJamming( zSig, - zExp, &zSig );
            zExp = 0;
            roundBits = zSig & 0x7F;
            if (isTiny && roundBits) {
                float_raise(float_flag_underflow, status);
            }
        }
    }
    if (roundBits) {
        status->float_exception_flags |= float_flag_inexact;
    }
    zSig = ( zSig + roundIncrement )>>7;
    zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
    if ( zSig == 0 ) zExp = 0;
    return packFloat32( zSign, zExp, zSig );

}

// Assembly:
movzbl 0x1(%rcx), %r8d
cmpq $0x4, %r8
ja 0x9fce
movq %rcx, %rax
leaq 0xc8cc(%rip), %rcx      # 0x16780
movslq (%rcx,%r8,4), %r9
addq %rcx, %r9
jmpq *%r9
movb $0x40, %r9b
jmp 0x9ee8
xorl %r9d, %r9d
jmp 0x9ee8
xorl %ecx, %ecx
testb %dil, %dil
movl $0x7f, %r9d
cmovel %ecx, %r9d
jmp 0x9ee8
xorl %ecx, %ecx
testb %dil, %dil
movl $0x7f, %r9d
cmovnel %ecx, %r9d
movzwl %si, %ecx
cmpl $0xfd, %ecx
jb 0x9f23
cmpq $0xfd, %rsi
jle 0x9f14
orb $0x28, 0x2(%rax)
movzbl %dil, %eax
shll $0x1f, %eax
cmpb $0x1, %r9b
sbbl $0x0, %eax
addl $0x7f800000, %eax       # imm = 0x7F800000
retq
jne 0x9f1e
movzbl %r9b, %ecx
addl %edx, %ecx
js 0x9efc
testq %rsi, %rsi
js 0x9f61
movl %edx, %ecx
andl $0x7f, %ecx
je 0x9f2e
orb $0x20, 0x2(%rax)
testb %r8b, %r8b
sete %al
movzbl %r9b, %r8d
addl %r8d, %edx
shrl $0x7, %edx
cmpl $0x40, %ecx
sete %cl
andb %al, %cl
movzbl %cl, %ecx
notl %ecx
andl %edx, %ecx
movzbl %dil, %eax
shll $0x1f, %eax
shll $0x17, %esi
testl %ecx, %ecx
cmovel %ecx, %esi
orl %ecx, %eax
addl %esi, %eax
retq
cmpb $0x0, 0x4(%rax)
je 0x9f73
orb $-0x80, 0x2(%rax)
movzbl %dil, %eax
shll $0x1f, %eax
retq
movb $0x1, %r10b
cmpq $-0x1, %rsi
jne 0x9f8b
cmpb $0x1, (%rax)
je 0x9f8b
movzbl %r9b, %ecx
addl %edx, %ecx
setns %r10b
cmpq $-0x1f, %rsi
jl 0x9fab
movl %esi, %ecx
negb %cl
movl %edx, %r11d
shrl %cl, %r11d
movl %esi, %ecx
shll %cl, %edx
xorl %ecx, %ecx
testl %edx, %edx
setne %cl
orl %r11d, %ecx
jmp 0x9fb2
xorl %ecx, %ecx
testl %edx, %edx
setne %cl
movl %ecx, %edx
testb $0x7f, %dl
setne %cl
andb %cl, %r10b
cmpb $0x1, %r10b
jne 0x9fc7
orb $0x10, 0x2(%rax)
xorl %esi, %esi
jmp 0x9f23
pushq %rax
callq 0x1040