// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: floatx80_round_to_int
floatx80 floatx80_round_to_int(floatx80 a, float_status *status)
{
    flag aSign;
    int32 aExp;
    uint64_t lastBitMask, roundBitsMask;
    floatx80 z;

    aExp = extractFloatx80Exp( a );
    if ( 0x403E <= aExp ) {
        if ( ( aExp == 0x7FFF ) && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) {
            return propagateFloatx80NaN(a, a, status);
        }
        return a;
    }
    if ( aExp < 0x3FFF ) {
        if (    ( aExp == 0 )
             && ( (uint64_t) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) {
            return a;
        }
        status->float_exception_flags |= float_flag_inexact;
        aSign = extractFloatx80Sign( a );
        switch (status->float_rounding_mode) {
         case float_round_nearest_even:
            if ( ( aExp == 0x3FFE ) && (uint64_t) ( extractFloatx80Frac( a )<<1 )
               ) {
                return
                    packFloatx80( aSign, 0x3FFF, LIT64( 0x8000000000000000 ) );
            }
            break;
        case float_round_ties_away:
            if (aExp == 0x3FFE) {
                return packFloatx80(aSign, 0x3FFF, LIT64(0x8000000000000000));
            }
            break;
         case float_round_down:
            return
                  aSign ?
                      packFloatx80( 1, 0x3FFF, LIT64( 0x8000000000000000 ) )
                : packFloatx80( 0, 0, 0 );
         case float_round_up:
            return
                  aSign ? packFloatx80( 1, 0, 0 )
                : packFloatx80( 0, 0x3FFF, LIT64( 0x8000000000000000 ) );
        }
        return packFloatx80( aSign, 0, 0 );
    }
    lastBitMask = 1;
    lastBitMask <<= 0x403E - aExp;
    roundBitsMask = lastBitMask - 1;
    z = a;
    switch (status->float_rounding_mode) {
    case float_round_nearest_even:
        z.low += lastBitMask>>1;
        if ((z.low & roundBitsMask) == 0) {
            z.low &= ~lastBitMask;
        }
        break;
    case float_round_ties_away:
        z.low += lastBitMask >> 1;
        break;
    case float_round_to_zero:
        break;
    case float_round_up:
        if (!extractFloatx80Sign(z)) {
            z.low += roundBitsMask;
        }
        break;
    case float_round_down:
        if (extractFloatx80Sign(z)) {
            z.low += roundBitsMask;
        }
        break;
    default:
        abort();
    }
    z.low &= ~ roundBitsMask;
    if ( z.low == 0 ) {
        ++z.high;
        z.low = LIT64( 0x8000000000000000 );
    }
    if (z.low != a.low) {
        status->float_exception_flags |= float_flag_inexact;
    }
    return z;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movw %si, %ax
movq %rdi, -0x20(%rbp)
movw %ax, -0x18(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movzwl -0x18(%rbp), %esi
callq 0x1ab50
movl %eax, -0x30(%rbp)
movl $0x403e, %eax           # imm = 0x403E
cmpl -0x30(%rbp), %eax
jg 0x1b37e
cmpl $0x7fff, -0x30(%rbp)    # imm = 0x7FFF
jne 0x1b369
movq -0x20(%rbp), %rdi
movzwl -0x18(%rbp), %esi
callq 0x1ab30
shlq %rax
cmpq $0x0, %rax
je 0x1b369
movq -0x28(%rbp), %r8
movq -0x20(%rbp), %rdi
movw -0x18(%rbp), %ax
movq -0x20(%rbp), %rdx
movzwl %ax, %esi
movzwl -0x18(%rbp), %ecx
callq 0x1b670
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b65d
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1b65d
cmpl $0x3fff, -0x30(%rbp)    # imm = 0x3FFF
jge 0x1b527
cmpl $0x0, -0x30(%rbp)
jne 0x1b3bc
movq -0x20(%rbp), %rdi
movzwl -0x18(%rbp), %esi
callq 0x1ab30
shlq %rax
cmpq $0x0, %rax
jne 0x1b3bc
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1b65d
movq -0x28(%rbp), %rax
movb 0x2(%rax), %cl
orb $0x20, %cl
movb %cl, 0x2(%rax)
movq -0x20(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x1ab70
movb %al, -0x29(%rbp)
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x4, %eax
ja 0x1b50b
movq -0x58(%rbp), %rax
leaq 0xa532(%rip), %rcx      # 0x2592c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x3ffe, -0x30(%rbp)    # imm = 0x3FFE
jne 0x1b447
movq -0x20(%rbp), %rdi
movzwl -0x18(%rbp), %esi
callq 0x1ab30
shlq %rax
cmpq $0x0, %rax
je 0x1b447
movl $0x3fff, %esi           # imm = 0x3FFF
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movzbl -0x29(%rbp), %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b65d
jmp 0x1b50b
cmpl $0x3ffe, -0x30(%rbp)    # imm = 0x3FFE
jne 0x1b47a
movl $0x3fff, %esi           # imm = 0x3FFF
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movzbl -0x29(%rbp), %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b65d
jmp 0x1b50b
movzbl -0x29(%rbp), %eax
cmpl $0x0, %eax
je 0x1b4ab
movl $0x1, %edi
movl $0x3fff, %esi           # imm = 0x3FFF
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b4c0
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
movl %esi, %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b65d
movzbl -0x29(%rbp), %eax
cmpl $0x0, %eax
je 0x1b4e8
movl $0x1, %edi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b506
xorl %edi, %edi
movl $0x3fff, %esi           # imm = 0x3FFF
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b65d
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
movzbl -0x29(%rbp), %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1b65d
movq $0x1, -0x38(%rbp)
movb -0x30(%rbp), %dl
movq -0x38(%rbp), %rax
movb $0x3e, %cl
subb %dl, %cl
shlq %cl, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
decq %rax
movq %rax, -0x40(%rbp)
movups -0x20(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x4, %eax
ja 0x1b5ff
movq -0x60(%rbp), %rax
leaq 0xa3a2(%rip), %rcx      # 0x25918
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x38(%rbp), %rax
shrq %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
andq -0x40(%rbp), %rax
cmpq $0x0, %rax
jne 0x1b5ac
movq -0x38(%rbp), %rax
xorq $-0x1, %rax
andq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x1b604
movq -0x38(%rbp), %rax
shrq %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x1b604
jmp 0x1b604
movq -0x50(%rbp), %rdi
movzwl -0x48(%rbp), %esi
callq 0x1ab70
cmpb $0x0, %al
jne 0x1b5de
movq -0x40(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x1b604
movq -0x50(%rbp), %rdi
movzwl -0x48(%rbp), %esi
callq 0x1ab70
cmpb $0x0, %al
je 0x1b5fd
movq -0x40(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x1b604
callq 0x1030
movq -0x40(%rbp), %rax
xorq $-0x1, %rax
andq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x1b635
movw -0x48(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x48(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x20(%rbp), %rax
je 0x1b64d
movq -0x28(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movq -0x50(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movw -0x8(%rbp), %dx
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)