// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x11570
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %edi
callq 0x115d0
movq %rax, -0x20(%rbp)
movl $0x96, %eax
cmpq -0x20(%rbp), %rax
jg 0x139fe
cmpq $0xff, -0x20(%rbp)
jne 0x139f3
movl -0x8(%rbp), %edi
callq 0x115f0
cmpl $0x0, %eax
je 0x139f3
movl -0x8(%rbp), %edi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x13be0
movl %eax, -0x4(%rbp)
jmp 0x13bd5
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13bd5
cmpq $0x7e, -0x20(%rbp)
jg 0x13afc
movl -0x8(%rbp), %eax
shll %eax
cmpl $0x0, %eax
jne 0x13a1e
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13bd5
movq -0x10(%rbp), %rax
movb 0x2(%rax), %cl
orb $0x20, %cl
movb %cl, 0x2(%rax)
movl -0x8(%rbp), %edi
callq 0x12810
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x4, %eax
ja 0x13ae5
movq -0x38(%rbp), %rax
leaq 0x11e50(%rip), %rcx     # 0x258a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x7e, -0x20(%rbp)
jne 0x13a8d
movl -0x8(%rbp), %edi
callq 0x115f0
cmpl $0x0, %eax
je 0x13a8d
movl $0x7f, %esi
xorl %edx, %edx
movzbl -0x11(%rbp), %edi
callq 0x11750
movl %eax, -0x4(%rbp)
jmp 0x13bd5
jmp 0x13ae5
cmpq $0x7e, -0x20(%rbp)
jne 0x13aae
movl $0x7f, %esi
xorl %edx, %edx
movzbl -0x11(%rbp), %edi
callq 0x11750
movl %eax, -0x4(%rbp)
jmp 0x13bd5
jmp 0x13ae5
movzbl -0x11(%rbp), %edx
xorl %eax, %eax
movl $0xbf800000, %ecx       # imm = 0xBF800000
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x13bd5
movzbl -0x11(%rbp), %edx
movl $0x3f800000, %eax       # imm = 0x3F800000
movl $0x80000000, %ecx       # imm = 0x80000000
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x13bd5
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movzbl -0x11(%rbp), %edi
callq 0x11750
movl %eax, -0x4(%rbp)
jmp 0x13bd5
movl $0x1, -0x24(%rbp)
movb -0x20(%rbp), %dl
movl -0x24(%rbp), %eax
movb $-0x6a, %cl
subb %dl, %cl
shll %cl, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
decl %eax
movl %eax, -0x28(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x4, %eax
ja 0x13ba8
movq -0x40(%rbp), %rax
leaq 0x11d56(%rip), %rcx     # 0x25894
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x24(%rbp), %eax
shrl %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
andl -0x28(%rbp), %eax
cmpl $0x0, %eax
jne 0x13b69
movl -0x24(%rbp), %eax
xorl $-0x1, %eax
andl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x13bad
movl -0x24(%rbp), %eax
shrl %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x13bad
jmp 0x13bad
movl -0x2c(%rbp), %edi
callq 0x12810
cmpb $0x0, %al
jne 0x13b8f
movl -0x28(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x13bad
movl -0x2c(%rbp), %edi
callq 0x12810
cmpb $0x0, %al
je 0x13ba6
movl -0x28(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x13bad
callq 0x1030
movl -0x28(%rbp), %eax
xorl $-0x1, %eax
andl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
je 0x13bcf
movq -0x10(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop