// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: roundAndPackFloat128
static float128 roundAndPackFloat128(flag zSign, int32 zExp,
                                     uint64_t zSig0, uint64_t zSig1,
                                     uint64_t zSig2, float_status *status)
{
    int8 roundingMode;
    flag roundNearestEven, increment, isTiny;

    roundingMode = status->float_rounding_mode;
    roundNearestEven = ( roundingMode == float_round_nearest_even );
    switch (roundingMode) {
    case float_round_nearest_even:
    case float_round_ties_away:
        increment = ((int64_t)zSig2 < 0);
        break;
    case float_round_to_zero:
        increment = 0;
        break;
    case float_round_up:
        increment = !zSign && zSig2;
        break;
    case float_round_down:
        increment = zSign && zSig2;
        break;
    default:
        abort();
    }
    if ( 0x7FFD <= (uint32_t) zExp ) {
        if (    ( 0x7FFD < zExp )
             || (    ( zExp == 0x7FFD )
                  && eq128(
                         LIT64( 0x0001FFFFFFFFFFFF ),
                         LIT64( 0xFFFFFFFFFFFFFFFF ),
                         zSig0,
                         zSig1
                     )
                  && increment
                )
           ) {
            float_raise(float_flag_overflow | float_flag_inexact, status);
            if (    ( roundingMode == float_round_to_zero )
                 || ( zSign && ( roundingMode == float_round_up ) )
                 || ( ! zSign && ( roundingMode == float_round_down ) )
               ) {
                return
                    packFloat128(
                        zSign,
                        0x7FFE,
                        LIT64( 0x0000FFFFFFFFFFFF ),
                        LIT64( 0xFFFFFFFFFFFFFFFF )
                    );
            }
            return packFloat128( zSign, 0x7FFF, 0, 0 );
        }
        if ( zExp < 0 ) {
            if (status->flush_to_zero) {
                float_raise(float_flag_output_denormal, status);
                return packFloat128(zSign, 0, 0, 0);
            }
            isTiny =
                   (status->float_detect_tininess
                    == float_tininess_before_rounding)
                || ( zExp < -1 )
                || ! increment
                || lt128(
                       zSig0,
                       zSig1,
                       LIT64( 0x0001FFFFFFFFFFFF ),
                       LIT64( 0xFFFFFFFFFFFFFFFF )
                   );
            shift128ExtraRightJamming(
                zSig0, zSig1, zSig2, - zExp, &zSig0, &zSig1, &zSig2 );
            zExp = 0;
            if (isTiny && zSig2) {
                float_raise(float_flag_underflow, status);
            }
            switch (roundingMode) {
            case float_round_nearest_even:
            case float_round_ties_away:
                increment = ((int64_t)zSig2 < 0);
                break;
            case float_round_to_zero:
                increment = 0;
                break;
            case float_round_up:
                increment = !zSign && zSig2;
                break;
            case float_round_down:
                increment = zSign && zSig2;
                break;
            default:
                abort();
            }
        }
    }
    if (zSig2) {
        status->float_exception_flags |= float_flag_inexact;
    }
    if ( increment ) {
        add128( zSig0, zSig1, 0, 1, &zSig0, &zSig1 );
        zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
    }
    else {
        if ( ( zSig0 | zSig1 ) == 0 ) zExp = 0;
    }
    return packFloat128( zSign, zExp, zSig0, zSig1 );

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dil, %al
movb %al, -0x11(%rbp)
movl %esi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x38(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb %al, %al
sete -0x3a(%rbp)
movsbl -0x39(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x4, %eax
ja 0x20648
movq -0x48(%rbp), %rax
leaq 0x53da(%rip), %rcx      # 0x259b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x30(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3b(%rbp)
jmp 0x2064d
movb $0x0, -0x3b(%rbp)
jmp 0x2064d
xorl %eax, %eax
cmpb $0x0, -0x11(%rbp)
movb %al, -0x49(%rbp)
jne 0x20615
cmpq $0x0, -0x30(%rbp)
setne %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3b(%rbp)
jmp 0x2064d
movzbl -0x11(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a(%rbp)
je 0x2063b
cmpq $0x0, -0x30(%rbp)
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3b(%rbp)
jmp 0x2064d
callq 0x1030
movl $0x7ffd, %eax           # imm = 0x7FFD
cmpl -0x18(%rbp), %eax
ja 0x208a7
movl $0x7ffd, %eax           # imm = 0x7FFD
cmpl -0x18(%rbp), %eax
jl 0x206a9
cmpl $0x7ffd, -0x18(%rbp)    # imm = 0x7FFD
jne 0x2072f
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movabsq $0x1ffffffffffff, %rdi  # imm = 0x1FFFFFFFFFFFF
movq $-0x1, %rsi
callq 0x1d320
movzbl %al, %eax
cmpl $0x0, %eax
je 0x2072f
movzbl -0x3b(%rbp), %eax
cmpl $0x0, %eax
je 0x2072f
movq -0x38(%rbp), %rsi
movl $0x28, %edi
callq 0x11080
movsbl -0x39(%rbp), %eax
cmpl $0x3, %eax
je 0x206e1
movzbl -0x11(%rbp), %eax
cmpl $0x0, %eax
je 0x206d2
movsbl -0x39(%rbp), %eax
cmpl $0x2, %eax
je 0x206e1
cmpb $0x0, -0x11(%rbp)
jne 0x2070d
movsbl -0x39(%rbp), %eax
cmpl $0x1, %eax
jne 0x2070d
movl $0x7ffe, %esi           # imm = 0x7FFE
movabsq $0xffffffffffff, %rdx   # imm = 0xFFFFFFFFFFFF
movq $-0x1, %rcx
movzbl -0x11(%rbp), %edi
callq 0x11a80
movq %rax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
jmp 0x2093e
movl $0x7fff, %esi           # imm = 0x7FFF
xorl %eax, %eax
movl %eax, %ecx
movzbl -0x11(%rbp), %edi
movq %rcx, %rdx
callq 0x11a80
movq %rax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
jmp 0x2093e
cmpl $0x0, -0x18(%rbp)
jge 0x208a5
movq -0x38(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x20770
movq -0x38(%rbp), %rsi
movl $0xffffff80, %edi       # imm = 0xFFFFFF80
callq 0x11080
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %ecx
movzbl -0x11(%rbp), %edi
movq %rcx, %rdx
callq 0x11a80
movq %rax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
jmp 0x2093e
movq -0x38(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x4b(%rbp)
je 0x207c1
movb $0x1, %al
cmpl $-0x1, -0x18(%rbp)
movb %al, -0x4b(%rbp)
jl 0x207c1
movb $0x1, %al
cmpb $0x0, -0x3b(%rbp)
movb %al, -0x4b(%rbp)
je 0x207c1
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movabsq $0x1ffffffffffff, %rdx  # imm = 0x1FFFFFFFFFFFF
movq $-0x1, %rcx
callq 0x19d70
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x4b(%rbp)
movb -0x4b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3c(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
xorl %eax, %eax
subl -0x18(%rbp), %eax
movslq %eax, %rcx
leaq -0x20(%rbp), %r8
leaq -0x28(%rbp), %r9
leaq -0x30(%rbp), %rax
movq %rax, (%rsp)
callq 0x20420
movl $0x0, -0x18(%rbp)
movzbl -0x3c(%rbp), %eax
cmpl $0x0, %eax
je 0x2081a
cmpq $0x0, -0x30(%rbp)
je 0x2081a
movq -0x38(%rbp), %rsi
movl $0x10, %edi
callq 0x11080
movsbl -0x39(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x4, %eax
ja 0x2089e
movq -0x58(%rbp), %rax
leaq 0x5198(%rip), %rcx      # 0x259cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x30(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3b(%rbp)
jmp 0x208a3
movb $0x0, -0x3b(%rbp)
jmp 0x208a3
xorl %eax, %eax
cmpb $0x0, -0x11(%rbp)
movb %al, -0x59(%rbp)
jne 0x2086b
cmpq $0x0, -0x30(%rbp)
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3b(%rbp)
jmp 0x208a3
movzbl -0x11(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x5a(%rbp)
je 0x20891
cmpq $0x0, -0x30(%rbp)
setne %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x3b(%rbp)
jmp 0x208a3
callq 0x1030
jmp 0x208a5
jmp 0x208a7
cmpq $0x0, -0x30(%rbp)
je 0x208bc
movq -0x38(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
cmpb $0x0, -0x3b(%rbp)
je 0x20909
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
leaq -0x20(%rbp), %r8
leaq -0x28(%rbp), %r9
callq 0x18bd0
movq -0x30(%rbp), %rax
addq -0x30(%rbp), %rax
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x3a(%rbp), %ecx
andl %ecx, %eax
xorl $-0x1, %eax
cltq
andq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x20920
movq -0x20(%rbp), %rax
orq -0x28(%rbp), %rax
cmpq $0x0, %rax
jne 0x2091e
movl $0x0, -0x18(%rbp)
jmp 0x20920
movb -0x11(%rbp), %al
movl -0x18(%rbp), %esi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movzbl %al, %edi
callq 0x11a80
movq %rax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)