// File: /workspace/github_c_makefile_star2_O3/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, %rax  # imm = 0xFFFFFFFFFFFFF
cmpb $0x0, 0x5(%rsi)
je 0xda64
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
testq %rcx, %rdi
setne %cl
testq %rax, %rdi
sete %sil
orb %cl, %sil
jne 0xda64
orb $0x40, 0x2(%rdx)
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
andq %rcx, %rdi
movq %rdi, %rsi
shrq $0x34, %rsi
andl $0x7ff, %esi            # imm = 0x7FF
cmpq $0x433, %rsi            # imm = 0x433
jb 0xda99
cmpl $0x7ff, %esi            # imm = 0x7FF
setne %cl
testq %rax, %rdi
sete %al
orb %cl, %al
jne 0xdbd1
movq %rdi, %rsi
jmp 0xdbdb
cmpl $0x3fe, %esi            # imm = 0x3FE
ja 0xdb06
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
leaq -0x1(%r8), %rcx
testq %rcx, %rdi
je 0xdbd1
orb $0x20, 0x2(%rdx)
movq %rdi, %rcx
andq %r8, %rcx
movzbl 0x1(%rdx), %edx
cmpq $0x4, %rdx
ja 0xdbce
leaq 0x8d5d(%rip), %r9       # 0x16834
movslq (%r9,%rdx,4), %rdx
addq %r9, %rdx
jmpq *%rdx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
orq %rcx, %rdx
cmpl $0x3fe, %esi            # imm = 0x3FE
cmovneq %rcx, %rdx
testq %rax, %rdi
cmoveq %rcx, %rdx
movq %rdx, %rdi
jmp 0xdbd1
movb $0x33, %cl
subb %sil, %cl
movl $0x1, %eax
shlq %cl, %rax
movzbl 0x1(%rdx), %ecx
cmpq $0x4, %rcx
ja 0xdbd5
leaq -0x1(%rax), %rsi
leaq 0x8cf4(%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 0xdb78
movq %rax, %rsi
notq %rsi
andq %rsi, %rcx
jmp 0xdb78
movq %rax, %rcx
shrq %rcx
jmp 0xdb64
movq %rdi, %rcx
sarq $0x3f, %rcx
andq %rsi, %rcx
addq %rdi, %rcx
jmp 0xdb78
xorl %ecx, %ecx
testq %rdi, %rdi
cmovsq %rcx, %rsi
addq %rdi, %rsi
movq %rsi, %rcx
negq %rax
andq %rcx, %rax
cmpq %rdi, %rax
je 0xdbd1
orb $0x20, 0x2(%rdx)
movq %rax, %rdi
jmp 0xdbd1
testq %rdi, %rdi
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
cmovnsq %rax, %r8
movq %r8, %rdi
jmp 0xdbd1
sarq $0x3f, %rdi
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
andq %rax, %rdi
jmp 0xdbd1
movabsq $0x3ff0000000000000, %rdi # imm = 0x3FF0000000000000
orq %rcx, %rdi
cmpl $0x3fe, %esi            # imm = 0x3FE
cmovneq %rcx, %rdi
jmp 0xdbd1
movq %rcx, %rdi
movq %rdi, %rax
retq
pushq %rax
callq 0x1040