// File: /workspace/github_c_makefile_star2_O1/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 0xad8c
testl $0x7f800000, %edi       # imm = 0x7F800000
setne %al
testl $0x7fffff, %edi         # imm = 0x7FFFFF
sete %cl
orb %al, %cl
jne 0xad8c
orb $0x40, 0x2(%rdx)
andl $0x80000000, %edi       # imm = 0x80000000
movl %edi, %eax
shrl $0x17, %eax
movzbl %al, %ecx
cmpl $0x96, %ecx
jb 0xadbd
cmpl $0xff, %ecx
setne %al
testl $0x7fffff, %edi         # imm = 0x7FFFFF
sete %cl
orb %al, %cl
jne 0xaea5
movl %edi, %esi
jmp 0xaeae
cmpl $0x7e, %ecx
ja 0xae0f
testl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
je 0xaea5
orb $0x20, 0x2(%rdx)
movl %edi, %eax
andl $0x80000000, %eax       # imm = 0x80000000
movzbl 0x1(%rdx), %edx
cmpq $0x4, %rdx
ja 0xae78
leaq 0xba0a(%rip), %rsi      # 0x167f8
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
cmpl $0x7e, %ecx
setne %cl
testl $0x7fffff, %edi         # imm = 0x7FFFFF
sete %dl
orb %cl, %dl
jne 0xae78
jmp 0xae99
movb $-0x6a, %cl
subb %al, %cl
movl $0x1, %eax
shll %cl, %eax
movzbl 0x1(%rdx), %ecx
cmpq $0x4, %rcx
ja 0xaea8
leal -0x1(%rax), %esi
leaq 0xb9b2(%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 0xae6c
movl %eax, %esi
notl %esi
andl %esi, %ecx
jmp 0xae6c
movl %eax, %ecx
shrl %ecx
jmp 0xae5d
movl %edi, %ecx
sarl $0x1f, %ecx
andl %esi, %ecx
addl %edi, %ecx
jmp 0xae6c
xorl %ecx, %ecx
testl %edi, %edi
cmovsl %ecx, %esi
addl %edi, %esi
movl %esi, %ecx
negl %eax
andl %ecx, %eax
cmpl %edi, %eax
je 0xae78
orb $0x20, 0x2(%rdx)
retq
testl %edi, %edi
movl $0x3f800000, %ecx       # imm = 0x3F800000
movl $0x80000000, %eax       # imm = 0x80000000
cmovnsl %ecx, %eax
retq
sarl $0x1f, %edi
andl $0xbf800000, %edi       # imm = 0xBF800000
jmp 0xaea5
cmpl $0x7e, %ecx
jne 0xae78
andl $0x80000000, %edi       # imm = 0x80000000
orl $0x3f800000, %edi       # imm = 0x3F800000
movl %edi, %eax
retq
pushq %rax
callq 0x1040