// File: /workspace/github_c_makefile_star2_O3/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:
movq %rsi, %rdx
cmpb $0x0, 0x5(%rsi)
je 0xae36
testl $0x7f800000, %edi       # imm = 0x7F800000
setne %al
testl $0x7fffff, %edi         # imm = 0x7FFFFF
sete %cl
orb %al, %cl
jne 0xae36
orb $0x40, 0x2(%rdx)
andl $0x80000000, %edi       # imm = 0x80000000
movl %edi, %esi
shrl $0x17, %esi
movzbl %sil, %eax
cmpl $0x96, %eax
jb 0xae66
cmpl $0xff, %eax
setne %al
testl $0x7fffff, %edi         # imm = 0x7FFFFF
sete %cl
orb %al, %cl
jne 0xaf5b
movl %edi, %esi
jmp 0xaf64
cmpl $0x7e, %eax
ja 0xaebf
testl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
je 0xaf5b
orb $0x20, 0x2(%rdx)
movl %edi, %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
movzbl 0x1(%rdx), %edx
cmpq $0x4, %rdx
ja 0xaf59
leaq 0xb960(%rip), %rsi      # 0x167f8
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl %ecx, %edx
orl $0x3f800000, %edx       # imm = 0x3F800000
cmpl $0x7e, %eax
cmovnel %ecx, %edx
testl $0x7fffff, %edi         # imm = 0x7FFFFF
cmovel %ecx, %edx
movl %edx, %edi
jmp 0xaf5b
movb $-0x6a, %cl
subb %sil, %cl
movl $0x1, %eax
shll %cl, %eax
movzbl 0x1(%rdx), %ecx
cmpq $0x4, %rcx
ja 0xaf5e
leal -0x1(%rax), %esi
leaq 0xb901(%rip), %r8       # 0x167e4
movslq (%r8,%rcx,4), %r9
addq %r8, %r9
movl %edi, %ecx
jmpq *%r9
movl %eax, %ecx
shrl %ecx
addl %edi, %ecx
testl %esi, %ecx
jne 0xaf1d
movl %eax, %esi
notl %esi
andl %esi, %ecx
jmp 0xaf1d
movl %eax, %ecx
shrl %ecx
jmp 0xaf0e
movl %edi, %ecx
sarl $0x1f, %ecx
andl %esi, %ecx
addl %edi, %ecx
jmp 0xaf1d
xorl %ecx, %ecx
testl %edi, %edi
cmovsl %ecx, %esi
addl %edi, %esi
movl %esi, %ecx
negl %eax
andl %ecx, %eax
cmpl %edi, %eax
je 0xaf5b
orb $0x20, 0x2(%rdx)
movl %eax, %edi
jmp 0xaf5b
testl %edi, %edi
movl $0x3f800000, %eax       # imm = 0x3F800000
movl $0x80000000, %edi       # imm = 0x80000000
cmovnsl %eax, %edi
jmp 0xaf5b
sarl $0x1f, %edi
andl $0xbf800000, %edi       # imm = 0xBF800000
jmp 0xaf5b
movl %ecx, %edi
orl $0x3f800000, %edi       # imm = 0x3F800000
cmpl $0x7e, %eax
cmovnel %ecx, %edi
jmp 0xaf5b
movl %ecx, %edi
movl %edi, %eax
retq
pushq %rax
callq 0x1040