// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movzbl 0x1(%rcx), %r12d
cmpq $0x4, %r12
ja 0x98bb
movq %rcx, %r14
movl %edi, %ebx
leaq 0xb02c(%rip), %rax      # 0x14794
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x200, %r13d           # imm = 0x200
jmp 0x979c
xorl %r13d, %r13d
jmp 0x979c
xorl %eax, %eax
testb %bl, %bl
movl $0x3ff, %r13d           # imm = 0x3FF
cmoveq %rax, %r13
jmp 0x979c
xorl %eax, %eax
testb %bl, %bl
movl $0x3ff, %r13d           # imm = 0x3FF
cmovneq %rax, %r13
movl %edx, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movzwl %si, %ecx
cmpl $0x7fd, %ecx            # imm = 0x7FD
jb 0x97f2
cmpq $0x7fd, %rsi            # imm = 0x7FD
jg 0x97ca
setne %dil
movq %r13, %rcx
addq %rdx, %rcx
setns %r8b
orb %dil, %r8b
jne 0x97ed
orb $0x28, 0x2(%r14)
movzbl %bl, %ecx
shlq $0x3f, %rcx
cmpq $0x1, %r13
sbbq $0x0, %rcx
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
addq %rcx, %rax
jmp 0x983e
testq %rsi, %rsi
js 0x984d
testq %rax, %rax
je 0x980c
movb 0x2(%r14), %cl
orb $0x20, %cl
movb %cl, 0x2(%r14)
cmpl $0x200, %eax            # imm = 0x200
sete %al
jmp 0x980e
xorl %eax, %eax
testb %r12b, %r12b
sete %cl
addq %r13, %rdx
shrq $0xa, %rdx
andb %al, %cl
movzbl %cl, %ecx
notq %rcx
andq %rdx, %rcx
shlq $0x34, %rsi
movzbl %bl, %eax
shlq $0x3f, %rax
testq %rcx, %rcx
cmoveq %rcx, %rsi
orq %rcx, %rax
addq %rsi, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x4(%r14)
je 0x9862
orb $-0x80, 0x2(%r14)
movzbl %bl, %eax
shlq $0x3f, %rax
jmp 0x983e
cmpb $0x1, (%r14)
sete %al
cmpq $-0x1, %rsi
setne %dil
testq %rcx, %rcx
setns %bpl
orb %dil, %bpl
orb %al, %bpl
negq %rsi
movq %rsp, %r15
movq %rdx, %rdi
movq %r15, %rdx
callq 0x93e7
movq (%r15), %rdx
movq %rdx, %rax
andq $0x3ff, %rax            # imm = 0x3FF
setne %cl
andb %bpl, %cl
cmpb $0x1, %cl
jne 0x98b4
movb 0x2(%r14), %cl
orb $0x10, %cl
xorl %esi, %esi
jmp 0x97fb
xorl %esi, %esi
jmp 0x97f2
callq 0x1040