// File: /workspace/github_c_makefile_star2_O3/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 0xa084
movq %rcx, %rax
leaq 0xc821(%rip), %rcx      # 0x16780
movslq (%rcx,%r8,4), %r9
addq %rcx, %r9
jmpq *%r9
movb $0x40, %r9b
jmp 0x9f93
xorl %r9d, %r9d
jmp 0x9f93
xorl %ecx, %ecx
testb %dil, %dil
movl $0x7f, %r9d
cmovel %ecx, %r9d
jmp 0x9f93
xorl %ecx, %ecx
testb %dil, %dil
movl $0x7f, %r9d
cmovnel %ecx, %r9d
movzwl %si, %ecx
cmpl $0xfd, %ecx
jb 0x9fd5
cmpq $0xfd, %rsi
jle 0x9fbf
orb $0x28, 0x2(%rax)
movzbl %dil, %eax
shll $0x1f, %eax
cmpb $0x1, %r9b
sbbl $0x0, %eax
addl $0x7f800000, %eax       # imm = 0x7F800000
retq
jne 0x9fd0
movzbl %r9b, %ecx
movl $0xfd, %esi
addl %edx, %ecx
jns 0x9fd5
jmp 0x9fa7
testq %rsi, %rsi
js 0xa013
movl %edx, %ecx
andl $0x7f, %ecx
je 0x9fe0
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 0xa025
orb $-0x80, 0x2(%rax)
movzbl %dil, %eax
shll $0x1f, %eax
retq
movb $0x1, %r10b
cmpq $-0x1, %rsi
jne 0xa03d
cmpb $0x1, (%rax)
je 0xa03d
movzbl %r9b, %ecx
addl %edx, %ecx
setns %r10b
negq %rsi
cmpq $0x1f, %rsi
ja 0xa061
movl %edx, %r11d
movl %esi, %ecx
shrl %cl, %r11d
negb %sil
movl %esi, %ecx
shll %cl, %edx
xorl %ecx, %ecx
testl %edx, %edx
setne %cl
orl %r11d, %ecx
jmp 0xa068
xorl %ecx, %ecx
testl %edx, %edx
setne %cl
movl %ecx, %edx
testb $0x7f, %dl
setne %cl
andb %cl, %r10b
cmpb $0x1, %r10b
jne 0xa07d
orb $0x10, 0x2(%rax)
xorl %esi, %esi
jmp 0x9fd5
pushq %rax
callq 0x1040