// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
testb %al, %al
sete -0x22(%rbp)
movsbl -0x21(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x4, %eax
ja 0x11d37
movq -0x30(%rbp), %rax
leaq 0x13b3a(%rip), %rcx     # 0x25830
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x40, -0x23(%rbp)
jmp 0x11d3c
movb $0x0, -0x23(%rbp)
jmp 0x11d3c
movzbl -0x5(%rbp), %edx
movl $0x7f, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x23(%rbp)
jmp 0x11d3c
movzbl -0x5(%rbp), %edx
xorl %eax, %eax
movl $0x7f, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x23(%rbp)
jmp 0x11d3c
callq 0x1030
movl -0x14(%rbp), %eax
andl $0x7f, %eax
movb %al, -0x24(%rbp)
movq -0x10(%rbp), %rax
movzwl %ax, %ecx
movl $0xfd, %eax
cmpl %ecx, %eax
jg 0x11e75
movl $0xfd, %eax
cmpq -0x10(%rbp), %rax
jl 0x11d7c
cmpq $0xfd, -0x10(%rbp)
jne 0x11db6
movl -0x14(%rbp), %eax
movsbl -0x23(%rbp), %ecx
addl %ecx, %eax
cmpl $0x0, %eax
jge 0x11db6
movq -0x20(%rbp), %rsi
movl $0x28, %edi
callq 0x11080
movb -0x5(%rbp), %al
movsbl -0x23(%rbp), %ecx
cmpl $0x0, %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
xorl %edx, %edx
subl %ecx, %edx
movl $0xff, %esi
movzbl %al, %edi
callq 0x11750
movl %eax, -0x4(%rbp)
jmp 0x11edc
cmpq $0x0, -0x10(%rbp)
jge 0x11e73
movq -0x20(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x11df0
movq -0x20(%rbp), %rsi
movl $0xffffff80, %edi       # imm = 0xFFFFFF80
callq 0x11080
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movzbl -0x5(%rbp), %edi
callq 0x11750
movl %eax, -0x4(%rbp)
jmp 0x11edc
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x31(%rbp)
je 0x11e21
movb $0x1, %al
cmpq $-0x1, -0x10(%rbp)
movb %al, -0x31(%rbp)
jl 0x11e21
movl -0x14(%rbp), %eax
movsbl -0x23(%rbp), %ecx
addl %ecx, %eax
cmpl $0x80000000, %eax       # imm = 0x80000000
setb %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x25(%rbp)
movl -0x14(%rbp), %edi
xorl %eax, %eax
movl %eax, %esi
subq -0x10(%rbp), %rsi
leaq -0x14(%rbp), %rdx
callq 0x158d0
movq $0x0, -0x10(%rbp)
movl -0x14(%rbp), %eax
andl $0x7f, %eax
movb %al, -0x24(%rbp)
movzbl -0x25(%rbp), %eax
cmpl $0x0, %eax
je 0x11e71
movsbl -0x24(%rbp), %eax
cmpl $0x0, %eax
je 0x11e71
movq -0x20(%rbp), %rsi
movl $0x10, %edi
callq 0x11080
jmp 0x11e73
jmp 0x11e75
cmpb $0x0, -0x24(%rbp)
je 0x11e89
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movl -0x14(%rbp), %eax
movsbl -0x23(%rbp), %ecx
addl %ecx, %eax
shrl $0x7, %eax
movl %eax, -0x14(%rbp)
movsbl -0x24(%rbp), %eax
xorl $0x40, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x22(%rbp), %ecx
andl %ecx, %eax
xorl $-0x1, %eax
andl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x11ec7
movq $0x0, -0x10(%rbp)
movb -0x5(%rbp), %al
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movzbl %al, %edi
callq 0x11750
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)