// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, 0x4(%rsp)
movzbl 0x1(%rcx), %r12d
cmpq $0x4, %r12
ja 0x9554
movq %rcx, %r14
movl %edi, %ebx
leaq 0xb335(%rip), %rax      # 0x14780
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb $0x40, %cl
jmp 0x9472
xorl %ecx, %ecx
jmp 0x9472
xorl %eax, %eax
testb %bl, %bl
pushq $0x7f
popq %rcx
cmovel %eax, %ecx
jmp 0x9472
xorl %eax, %eax
testb %bl, %bl
pushq $0x7f
popq %rcx
cmovnel %eax, %ecx
movzwl %si, %eax
movzbl %cl, %ebp
cmpl $0xfd, %eax
jb 0x94b4
cmpq $0xfd, %rsi
jle 0x94a0
orb $0x28, 0x2(%r14)
movzbl %bl, %eax
shll $0x1f, %eax
cmpb $0x1, %cl
sbbl $0x0, %eax
addl $0x7f800000, %eax       # imm = 0x7F800000
jmp 0x94ec
jne 0x94af
movl $0xfd, %esi
movl %ebp, %eax
addl %edx, %eax
jns 0x94b4
jmp 0x9488
testq %rsi, %rsi
js 0x94fb
movl %edx, %eax
andl $0x7f, %eax
je 0x94c0
orb $0x20, 0x2(%r14)
testb %r12b, %r12b
sete %cl
addl %ebp, %edx
shrl $0x7, %edx
cmpl $0x40, %eax
sete %al
andb %cl, %al
movzbl %al, %ecx
notl %ecx
andl %edx, %ecx
movzbl %bl, %eax
shll $0x1f, %eax
shll $0x17, %esi
testl %ecx, %ecx
cmovel %ecx, %esi
orl %ecx, %eax
addl %esi, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x4(%r14)
je 0x950f
orb $-0x80, 0x2(%r14)
movzbl %bl, %eax
shll $0x1f, %eax
jmp 0x94ec
movb $0x1, %r13b
cmpq $-0x1, %rsi
jne 0x9526
cmpb $0x1, (%r14)
je 0x9526
movl %ebp, %eax
addl %edx, %eax
setns %r13b
negq %rsi
leaq 0x4(%rsp), %r15
movl %edx, %edi
movq %r15, %rdx
callq 0xb590
movl (%r15), %edx
testb $0x7f, %dl
setne %al
andb %r13b, %al
cmpb $0x1, %al
jne 0x954d
orb $0x10, 0x2(%r14)
xorl %esi, %esi
jmp 0x94b4
callq 0x1040