// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: roundAndPackFloat64
static float64 roundAndPackFloat64(flag zSign, int_fast16_t zExp, uint64_t zSig,
                                   float_status *status)
{
    int8 roundingMode;
    flag roundNearestEven;
    int_fast16_t roundIncrement, roundBits;
    flag isTiny;

    roundingMode = status->float_rounding_mode;
    roundNearestEven = ( roundingMode == float_round_nearest_even );
    switch (roundingMode) {
    case float_round_nearest_even:
    case float_round_ties_away:
        roundIncrement = 0x200;
        break;
    case float_round_to_zero:
        roundIncrement = 0;
        break;
    case float_round_up:
        roundIncrement = zSign ? 0 : 0x3ff;
        break;
    case float_round_down:
        roundIncrement = zSign ? 0x3ff : 0;
        break;
    default:
        abort();
    }
    roundBits = zSig & 0x3FF;
    if ( 0x7FD <= (uint16_t) zExp ) {
        if (    ( 0x7FD < zExp )
             || (    ( zExp == 0x7FD )
                  && ( (int64_t) ( zSig + roundIncrement ) < 0 ) )
           ) {
            float_raise(float_flag_overflow | float_flag_inexact, status);
            return packFloat64( zSign, 0x7FF, - ( roundIncrement == 0 ));
        }
        if ( zExp < 0 ) {
            if (status->flush_to_zero) {
                float_raise(float_flag_output_denormal, status);
                return packFloat64(zSign, 0, 0);
            }
            isTiny =
                   (status->float_detect_tininess
                    == float_tininess_before_rounding)
                || ( zExp < -1 )
                || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );
            shift64RightJamming( zSig, - zExp, &zSig );
            zExp = 0;
            roundBits = zSig & 0x3FF;
            if (isTiny && roundBits) {
                float_raise(float_flag_underflow, status);
            }
        }
    }
    if (roundBits) {
        status->float_exception_flags |= float_flag_inexact;
    }
    zSig = ( zSig + roundIncrement )>>10;
    zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
    if ( zSig == 0 ) zExp = 0;
    return packFloat64( zSign, zExp, zSig );

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %dil, %al
movb %al, -0x9(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb %al, %al
sete -0x2a(%rbp)
movsbl -0x29(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x4, %eax
ja 0x12426
movq -0x50(%rbp), %rax
leaq 0x1346d(%rip), %rcx     # 0x25844
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq $0x200, -0x38(%rbp)     # imm = 0x200
jmp 0x1242b
movq $0x0, -0x38(%rbp)
jmp 0x1242b
movzbl -0x9(%rbp), %edx
movl $0x3ff, %eax            # imm = 0x3FF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
cltq
movq %rax, -0x38(%rbp)
jmp 0x1242b
movzbl -0x9(%rbp), %edx
xorl %eax, %eax
movl $0x3ff, %ecx            # imm = 0x3FF
cmpl $0x0, %edx
cmovnel %ecx, %eax
cltq
movq %rax, -0x38(%rbp)
jmp 0x1242b
callq 0x1030
movq -0x20(%rbp), %rax
andq $0x3ff, %rax            # imm = 0x3FF
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movzwl %ax, %ecx
movl $0x7fd, %eax            # imm = 0x7FD
cmpl %ecx, %eax
jg 0x12578
movl $0x7fd, %eax            # imm = 0x7FD
cmpq -0x18(%rbp), %rax
jl 0x12470
cmpq $0x7fd, -0x18(%rbp)     # imm = 0x7FD
jne 0x124ac
movq -0x20(%rbp), %rax
addq -0x38(%rbp), %rax
cmpq $0x0, %rax
jge 0x124ac
movq -0x28(%rbp), %rsi
movl $0x28, %edi
callq 0x11080
movb -0x9(%rbp), %al
cmpq $0x0, -0x38(%rbp)
sete %cl
andb $0x1, %cl
movzbl %cl, %edx
xorl %ecx, %ecx
subl %edx, %ecx
movslq %ecx, %rdx
movl $0x7ff, %esi            # imm = 0x7FF
movzbl %al, %edi
callq 0x118b0
movq %rax, -0x8(%rbp)
jmp 0x125ec
cmpq $0x0, -0x18(%rbp)
jge 0x12576
movq -0x28(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x124e8
movq -0x28(%rbp), %rsi
movl $0xffffff80, %edi       # imm = 0xFFFFFF80
callq 0x11080
xorl %eax, %eax
movl %eax, %edx
movzbl -0x9(%rbp), %edi
movq %rdx, %rsi
callq 0x118b0
movq %rax, -0x8(%rbp)
jmp 0x125ec
movq -0x28(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x51(%rbp)
je 0x12520
movb $0x1, %al
cmpq $-0x1, -0x18(%rbp)
movb %al, -0x51(%rbp)
jl 0x12520
movq -0x20(%rbp), %rax
addq -0x38(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, %rax
setb %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x41(%rbp)
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
subq -0x18(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x11c20
movq $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rax
andq $0x3ff, %rax            # imm = 0x3FF
movq %rax, -0x40(%rbp)
movzbl -0x41(%rbp), %eax
cmpl $0x0, %eax
je 0x12574
cmpq $0x0, -0x40(%rbp)
je 0x12574
movq -0x28(%rbp), %rsi
movl $0x10, %edi
callq 0x11080
jmp 0x12576
jmp 0x12578
cmpq $0x0, -0x40(%rbp)
je 0x1258d
movq -0x28(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movq -0x20(%rbp), %rax
addq -0x38(%rbp), %rax
shrq $0xa, %rax
movq %rax, -0x20(%rbp)
movq -0x40(%rbp), %rax
xorq $0x200, %rax            # imm = 0x200
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x2a(%rbp), %ecx
andl %ecx, %eax
xorl $-0x1, %eax
cltq
andq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x125d5
movq $0x0, -0x18(%rbp)
movb -0x9(%rbp), %al
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movzbl %al, %edi
callq 0x118b0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)