// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/softfloat.c
// Function: float64_round_to_int
float64 float64_round_to_int(float64 a, float_status *status)
{
    flag aSign;
    int_fast16_t aExp;
    uint64_t lastBitMask, roundBitsMask;
    uint64_t z;
    a = float64_squash_input_denormal(a, status);

    aExp = extractFloat64Exp( a );
    if ( 0x433 <= aExp ) {
        if ( ( aExp == 0x7FF ) && extractFloat64Frac( a ) ) {
            return propagateFloat64NaN(a, a, status);
        }
        return a;
    }
    if ( aExp < 0x3FF ) {
        if ( (uint64_t) ( float64_val(a)<<1 ) == 0 ) return a;
        status->float_exception_flags |= float_flag_inexact;
        aSign = extractFloat64Sign( a );
        switch (status->float_rounding_mode) {
         case float_round_nearest_even:
            if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) {
                return packFloat64( aSign, 0x3FF, 0 );
            }
            break;
        case float_round_ties_away:
            if (aExp == 0x3FE) {
                return packFloat64(aSign, 0x3ff, 0);
            }
            break;
         case float_round_down:
            return make_float64(aSign ? LIT64( 0xBFF0000000000000 ) : 0);
         case float_round_up:
            return make_float64(
            aSign ? LIT64( 0x8000000000000000 ) : LIT64( 0x3FF0000000000000 ));
        }
        return packFloat64( aSign, 0, 0 );
    }
    lastBitMask = 1;
    lastBitMask <<= 0x433 - aExp;
    roundBitsMask = lastBitMask - 1;
    z = float64_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 (!extractFloat64Sign(make_float64(z))) {
            z += roundBitsMask;
        }
        break;
    case float_round_down:
        if (extractFloat64Sign(make_float64(z))) {
            z += roundBitsMask;
        }
        break;
    default:
        abort();
    }
    z &= ~ roundBitsMask;
    if (z != float64_val(a)) {
        status->float_exception_flags |= float_flag_inexact;
    }
    return make_float64(z);

}

// Assembly:
pushq %rbx
movq %rsi, %rbx
callq 0x920d
movq %rax, %rdx
shrq $0x34, %rdx
andl $0x7ff, %edx            # imm = 0x7FF
cmpq $0x433, %rdx            # imm = 0x433
jb 0xca4f
cmpl $0x7ff, %edx            # imm = 0x7FF
setne %cl
movq %rax, %rdx
shlq $0xc, %rdx
sete %dl
orb %cl, %dl
jne 0xcb85
movq %rax, %rdi
movq %rax, %rsi
movq %rbx, %rdx
popq %rbx
jmp 0xcb8c
cmpl $0x3fe, %edx            # imm = 0x3FE
ja 0xcabd
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
leaq -0x1(%rsi), %rcx
testq %rcx, %rax
je 0xcb85
orb $0x20, 0x2(%rbx)
movq %rax, %rcx
andq %rsi, %rcx
movzbl 0x1(%rbx), %edi
cmpq $0x4, %rdi
ja 0xcb82
leaq 0x7da7(%rip), %r8       # 0x14834
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
shlq $0xc, %rax
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
orq %rcx, %rsi
cmpl $0x3fe, %edx            # imm = 0x3FE
cmovneq %rcx, %rsi
testq %rax, %rax
cmoveq %rcx, %rsi
jmp 0xcb51
movb $0x33, %cl
subb %dl, %cl
pushq $0x1
popq %rdx
shlq %cl, %rdx
movzbl 0x1(%rbx), %ecx
cmpq $0x4, %rcx
ja 0xcb87
leaq -0x1(%rdx), %rsi
leaq 0x7d40(%rip), %rdi      # 0x14820
movslq (%rdi,%rcx,4), %r8
addq %rdi, %r8
movq %rax, %rcx
jmpq *%r8
movq %rdx, %rcx
shrq %rcx
addq %rax, %rcx
testq %rsi, %rcx
jne 0xcb2c
movq %rdx, %rsi
notq %rsi
andq %rsi, %rcx
jmp 0xcb2c
movq %rdx, %rcx
shrq %rcx
jmp 0xcb18
movq %rax, %rcx
sarq $0x3f, %rcx
andq %rsi, %rcx
addq %rax, %rcx
jmp 0xcb2c
xorl %ecx, %ecx
testq %rax, %rax
cmovsq %rcx, %rsi
addq %rax, %rsi
movq %rsi, %rcx
negq %rdx
andq %rcx, %rdx
cmpq %rax, %rdx
je 0xcb85
orb $0x20, 0x2(%rbx)
movq %rdx, %rax
jmp 0xcb85
testq %rax, %rax
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
cmovnsq %rax, %rsi
movq %rsi, %rax
jmp 0xcb85
sarq $0x3f, %rax
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
andq %rcx, %rax
jmp 0xcb85
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
orq %rcx, %rax
cmpl $0x3fe, %edx            # imm = 0x3FE
cmovneq %rcx, %rax
jmp 0xcb85
movq %rcx, %rax
popq %rbx
retq
callq 0x1040