// File: /workspace/github_c_makefile_star2_O1/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:
movq %rsi, %rdx
movabsq $0xfffffffffffff, %rcx  # imm = 0xFFFFFFFFFFFFF
cmpb $0x0, 0x5(%rsi)
je 0xd9c5
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
testq %rax, %rdi
setne %al
testq %rcx, %rdi
sete %sil
orb %al, %sil
jne 0xd9c5
orb $0x40, 0x2(%rdx)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq %rax, %rdi
movq %rdi, %r8
shrq $0x34, %r8
andl $0x7ff, %r8d            # imm = 0x7FF
cmpq $0x433, %r8             # imm = 0x433
jb 0xd9f8
cmpl $0x7ff, %r8d            # imm = 0x7FF
setne %al
testq %rcx, %rdi
sete %cl
orb %al, %cl
jne 0xda59
movq %rdi, %rsi
jmp 0xdb26
cmpl $0x3fe, %r8d            # imm = 0x3FE
ja 0xda5d
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
leaq -0x1(%rsi), %rax
testq %rax, %rdi
je 0xda59
orb $0x20, 0x2(%rdx)
movq %rdi, %rax
andq %rsi, %rax
movzbl 0x1(%rdx), %edx
cmpq $0x4, %rdx
ja 0xdade
leaq 0x8e01(%rip), %r9       # 0x16834
movslq (%r9,%rdx,4), %rdx
addq %r9, %rdx
jmpq *%rdx
cmpl $0x3fe, %r8d            # imm = 0x3FE
setne %dl
testq %rcx, %rdi
sete %cl
orb %dl, %cl
jne 0xdade
jmp 0xdb0f
movq %rdi, %rax
retq
movb $0x33, %cl
subb %r8b, %cl
movl $0x1, %eax
shlq %cl, %rax
movzbl 0x1(%rdx), %ecx
cmpq $0x4, %rcx
ja 0xdb20
leaq -0x1(%rax), %rsi
leaq 0x8d9d(%rip), %r8       # 0x16820
movslq (%r8,%rcx,4), %r9
addq %r8, %r9
movq %rdi, %rcx
jmpq *%r9
movq %rax, %rcx
shrq %rcx
addq %rdi, %rcx
testq %rsi, %rcx
jne 0xdacf
movq %rax, %rsi
notq %rsi
andq %rsi, %rcx
jmp 0xdacf
movq %rax, %rcx
shrq %rcx
jmp 0xdabb
movq %rdi, %rcx
sarq $0x3f, %rcx
andq %rsi, %rcx
addq %rdi, %rcx
jmp 0xdacf
xorl %ecx, %ecx
testq %rdi, %rdi
cmovsq %rcx, %rsi
addq %rdi, %rsi
movq %rsi, %rcx
negq %rax
andq %rcx, %rax
cmpq %rdi, %rax
je 0xdade
orb $0x20, 0x2(%rdx)
retq
testq %rdi, %rdi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
cmovnsq %rax, %rsi
movq %rsi, %rax
retq
sarq $0x3f, %rdi
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
andq %rdi, %rax
retq
cmpl $0x3fe, %r8d            # imm = 0x3FE
jne 0xdade
andq %rsi, %rdi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
orq %rdi, %rax
retq
pushq %rax
callq 0x1040