// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11610
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x11680
movq %rax, -0x28(%rbp)
movl $0x433, %eax            # imm = 0x433
cmpq -0x28(%rbp), %rax
jg 0x17d29
cmpq $0x7ff, -0x28(%rbp)     # imm = 0x7FF
jne 0x17d1c
movq -0x10(%rbp), %rdi
callq 0x116a0
cmpq $0x0, %rax
je 0x17d1c
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x17f70
movq %rax, -0x8(%rbp)
jmp 0x17f58
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x17f58
cmpq $0x3ff, -0x28(%rbp)     # imm = 0x3FF
jge 0x17e53
movq -0x10(%rbp), %rax
shlq %rax
cmpq $0x0, %rax
jne 0x17d51
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x17f58
movq -0x18(%rbp), %rax
movb 0x2(%rax), %cl
orb $0x20, %cl
movb %cl, 0x2(%rax)
movq -0x10(%rbp), %rdi
callq 0x168f0
movb %al, -0x19(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x4, %eax
ja 0x17e3a
movq -0x48(%rbp), %rax
leaq 0xdb68(%rip), %rcx      # 0x258f4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x3fe, -0x28(%rbp)     # imm = 0x3FE
jne 0x17dc9
movq -0x10(%rbp), %rdi
callq 0x116a0
cmpq $0x0, %rax
je 0x17dc9
movl $0x3ff, %esi            # imm = 0x3FF
xorl %eax, %eax
movl %eax, %edx
movzbl -0x19(%rbp), %edi
callq 0x118b0
movq %rax, -0x8(%rbp)
jmp 0x17f58
jmp 0x17e3a
cmpq $0x3fe, -0x28(%rbp)     # imm = 0x3FE
jne 0x17df0
movl $0x3ff, %esi            # imm = 0x3FF
xorl %eax, %eax
movl %eax, %edx
movzbl -0x19(%rbp), %edi
callq 0x118b0
movq %rax, -0x8(%rbp)
jmp 0x17f58
jmp 0x17e3a
movzbl -0x19(%rbp), %edx
xorl %eax, %eax
movabsq $-0x4010000000000000, %rcx # imm = 0xBFF0000000000000
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x17f58
movzbl -0x19(%rbp), %edx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x17f58
xorl %eax, %eax
movl %eax, %edx
movzbl -0x19(%rbp), %edi
movq %rdx, %rsi
callq 0x118b0
movq %rax, -0x8(%rbp)
jmp 0x17f58
movq $0x1, -0x30(%rbp)
movb -0x28(%rbp), %dl
movq -0x30(%rbp), %rax
movb $0x33, %cl
subb %dl, %cl
shlq %cl, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
decq %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x4, %eax
ja 0x17f23
movq -0x50(%rbp), %rax
leaq 0xda3e(%rip), %rcx      # 0x258e0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
shrq %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
andq -0x38(%rbp), %rax
cmpq $0x0, %rax
jne 0x17ed8
movq -0x30(%rbp), %rax
xorq $-0x1, %rax
andq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x17f28
movq -0x30(%rbp), %rax
shrq %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x17f28
jmp 0x17f28
movq -0x40(%rbp), %rdi
callq 0x168f0
cmpb $0x0, %al
jne 0x17f06
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x17f28
movq -0x40(%rbp), %rdi
callq 0x168f0
cmpb $0x0, %al
je 0x17f21
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x17f28
callq 0x1030
movq -0x38(%rbp), %rax
xorq $-0x1, %rax
andq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x17f50
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)