// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/softfloat.c
// Function: float32_round_to_int
float32 float32_round_to_int(float32 a, float_status *status)
{
    flag aSign;
    int_fast16_t aExp;
    uint32_t lastBitMask, roundBitsMask;
    uint32_t z;
    a = float32_squash_input_denormal(a, status);

    aExp = extractFloat32Exp( a );
    if ( 0x96 <= aExp ) {
        if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
            return propagateFloat32NaN(a, a, status);
        }
        return a;
    }
    if ( aExp <= 0x7E ) {
        if ( (uint32_t) ( float32_val(a)<<1 ) == 0 ) return a;
        status->float_exception_flags |= float_flag_inexact;
        aSign = extractFloat32Sign( a );
        switch (status->float_rounding_mode) {
         case float_round_nearest_even:
            if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
                return packFloat32( aSign, 0x7F, 0 );
            }
            break;
        case float_round_ties_away:
            if (aExp == 0x7E) {
                return packFloat32(aSign, 0x7F, 0);
            }
            break;
         case float_round_down:
            return make_float32(aSign ? 0xBF800000 : 0);
         case float_round_up:
            return make_float32(aSign ? 0x80000000 : 0x3F800000);
        }
        return packFloat32( aSign, 0, 0 );
    }
    lastBitMask = 1;
    lastBitMask <<= 0x96 - aExp;
    roundBitsMask = lastBitMask - 1;
    z = float32_val(a);
    switch (status->float_rounding_mode) {
    case float_round_nearest_even:
        z += lastBitMask>>1;
        if ((z & roundBitsMask) == 0) {
            z &= ~lastBitMask;
        }
        break;
    case float_round_ties_away:
        z += lastBitMask >> 1;
        break;
    case float_round_to_zero:
        break;
    case float_round_up:
        if (!extractFloat32Sign(make_float32(z))) {
            z += roundBitsMask;
        }
        break;
    case float_round_down:
        if (extractFloat32Sign(make_float32(z))) {
            z += roundBitsMask;
        }
        break;
    default:
        abort();
    }
    z &= ~ roundBitsMask;
    if (z != float32_val(a)) {
        status->float_exception_flags |= float_flag_inexact;
    }
    return make_float32(z);

}

// Assembly:
pushq %rbx
movq %rsi, %rbx
callq 0x91e7
movl %eax, %edx
shrl $0x17, %edx
movzbl %dl, %ecx
cmpl $0x96, %ecx
jb 0xa2c1
cmpl $0xff, %ecx
setne %cl
testl $0x7fffff, %eax         # imm = 0x7FFFFF
sete %dl
orb %cl, %dl
jne 0xa3af
movl %eax, %edi
movl %eax, %esi
movq %rbx, %rdx
popq %rbx
jmp 0xa3b6
cmpl $0x7e, %ecx
ja 0xa318
testl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0xa3af
orb $0x20, 0x2(%rbx)
movl %eax, %edx
andl $0x80000000, %edx       # imm = 0x80000000
movzbl 0x1(%rbx), %esi
cmpq $0x4, %rsi
ja 0xa3ad
leaq 0xa506(%rip), %rdi      # 0x147f8
movslq (%rdi,%rsi,4), %rsi
addq %rdi, %rsi
jmpq *%rsi
movl %edx, %esi
orl $0x3f800000, %esi       # imm = 0x3F800000
cmpl $0x7e, %ecx
cmovnel %edx, %esi
testl $0x7fffff, %eax         # imm = 0x7FFFFF
cmovel %edx, %esi
movl %esi, %eax
jmp 0xa3af
movb $-0x6a, %cl
subb %dl, %cl
pushq $0x1
popq %rdx
shll %cl, %edx
movzbl 0x1(%rbx), %ecx
cmpq $0x4, %rcx
ja 0xa3b1
leal -0x1(%rdx), %esi
leaq 0xa4ab(%rip), %rdi      # 0x147e4
movslq (%rdi,%rcx,4), %r8
addq %rdi, %r8
movl %eax, %ecx
jmpq *%r8
movl %edx, %ecx
shrl %ecx
addl %eax, %ecx
testl %esi, %ecx
jne 0xa373
movl %edx, %esi
notl %esi
andl %esi, %ecx
jmp 0xa373
movl %edx, %ecx
shrl %ecx
jmp 0xa364
movl %eax, %ecx
sarl $0x1f, %ecx
andl %esi, %ecx
addl %eax, %ecx
jmp 0xa373
xorl %ecx, %ecx
testl %eax, %eax
cmovsl %ecx, %esi
addl %eax, %esi
movl %esi, %ecx
negl %edx
andl %ecx, %edx
cmpl %eax, %edx
je 0xa3af
orb $0x20, 0x2(%rbx)
movl %edx, %eax
jmp 0xa3af
testl %eax, %eax
movl $0x3f800000, %ecx       # imm = 0x3F800000
movl $0x80000000, %eax       # imm = 0x80000000
cmovnsl %ecx, %eax
jmp 0xa3af
sarl $0x1f, %eax
andl $0xbf800000, %eax       # imm = 0xBF800000
jmp 0xa3af
movl %edx, %eax
orl $0x3f800000, %eax       # imm = 0x3F800000
cmpl $0x7e, %ecx
cmovnel %edx, %eax
jmp 0xa3af
movl %edx, %eax
popq %rbx
retq
callq 0x1040