// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: roundAndPackFloatx80
static floatx80 roundAndPackFloatx80(int8 roundingPrecision, flag zSign,
                                     int32 zExp, uint64_t zSig0, uint64_t zSig1,
                                     float_status *status)
{
    int8 roundingMode;
    flag roundNearestEven, increment, isTiny;
    int64 roundIncrement, roundMask, roundBits;

    roundingMode = status->float_rounding_mode;
    roundNearestEven = ( roundingMode == float_round_nearest_even );
    if ( roundingPrecision == 80 ) goto precision80;
    if ( roundingPrecision == 64 ) {
        roundIncrement = LIT64( 0x0000000000000400 );
        roundMask = LIT64( 0x00000000000007FF );
    }
    else if ( roundingPrecision == 32 ) {
        roundIncrement = LIT64( 0x0000008000000000 );
        roundMask = LIT64( 0x000000FFFFFFFFFF );
    }
    else {
        goto precision80;
    }
    zSig0 |= ( zSig1 != 0 );
    switch (roundingMode) {
    case float_round_nearest_even:
    case float_round_ties_away:
        break;
    case float_round_to_zero:
        roundIncrement = 0;
        break;
    case float_round_up:
        roundIncrement = zSign ? 0 : roundMask;
        break;
    case float_round_down:
        roundIncrement = zSign ? roundMask : 0;
        break;
    default:
        abort();
    }
    roundBits = zSig0 & roundMask;
    if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
        if (    ( 0x7FFE < zExp )
             || ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )
           ) {
            goto overflow;
        }
        if ( zExp <= 0 ) {
            if (status->flush_to_zero) {
                float_raise(float_flag_output_denormal, status);
                return packFloatx80(zSign, 0, 0);
            }
            isTiny =
                   (status->float_detect_tininess
                    == float_tininess_before_rounding)
                || ( zExp < 0 )
                || ( zSig0 <= zSig0 + roundIncrement );
            shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
            zExp = 0;
            roundBits = zSig0 & roundMask;
            if (isTiny && roundBits) {
                float_raise(float_flag_underflow, status);
            }
            if (roundBits) {
                status->float_exception_flags |= float_flag_inexact;
            }
            zSig0 += roundIncrement;
            if ( (int64_t) zSig0 < 0 ) zExp = 1;
            roundIncrement = roundMask + 1;
            if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
                roundMask |= roundIncrement;
            }
            zSig0 &= ~ roundMask;
            return packFloatx80( zSign, zExp, zSig0 );
        }
    }
    if (roundBits) {
        status->float_exception_flags |= float_flag_inexact;
    }
    zSig0 += roundIncrement;
    if ( zSig0 < roundIncrement ) {
        ++zExp;
        zSig0 = LIT64( 0x8000000000000000 );
    }
    roundIncrement = roundMask + 1;
    if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
        roundMask |= roundIncrement;
    }
    zSig0 &= ~ roundMask;
    if ( zSig0 == 0 ) zExp = 0;
    return packFloatx80( zSign, zExp, zSig0 );
 precision80:
    switch (roundingMode) {
    case float_round_nearest_even:
    case float_round_ties_away:
        increment = ((int64_t)zSig1 < 0);
        break;
    case float_round_to_zero:
        increment = 0;
        break;
    case float_round_up:
        increment = !zSign && zSig1;
        break;
    case float_round_down:
        increment = zSign && zSig1;
        break;
    default:
        abort();
    }
    if ( 0x7FFD <= (uint32_t) ( zExp - 1 ) ) {
        if (    ( 0x7FFE < zExp )
             || (    ( zExp == 0x7FFE )
                  && ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
                  && increment
                )
           ) {
            roundMask = 0;
 overflow:
            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 packFloatx80( zSign, 0x7FFE, ~ roundMask );
            }
            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
        }
        if ( zExp <= 0 ) {
            isTiny =
                   (status->float_detect_tininess
                    == float_tininess_before_rounding)
                || ( zExp < 0 )
                || ! increment
                || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
            shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
            zExp = 0;
            if (isTiny && zSig1) {
                float_raise(float_flag_underflow, status);
            }
            if (zSig1) {
                status->float_exception_flags |= float_flag_inexact;
            }
            switch (roundingMode) {
            case float_round_nearest_even:
            case float_round_ties_away:
                increment = ((int64_t)zSig1 < 0);
                break;
            case float_round_to_zero:
                increment = 0;
                break;
            case float_round_up:
                increment = !zSign && zSig1;
                break;
            case float_round_down:
                increment = zSign && zSig1;
                break;
            default:
                abort();
            }
            if ( increment ) {
                ++zSig0;
                zSig0 &=
                    ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
                if ( (int64_t) zSig0 < 0 ) zExp = 1;
            }
            return packFloatx80( zSign, zExp, zSig0 );
        }
    }
    if (zSig1) {
        status->float_exception_flags |= float_flag_inexact;
    }
    if ( increment ) {
        ++zSig0;
        if ( zSig0 == 0 ) {
            ++zExp;
            zSig0 = LIT64( 0x8000000000000000 );
        }
        else {
            zSig0 &= ~ ( ( (uint64_t) ( zSig1<<1 ) == 0 ) & roundNearestEven );
        }
    }
    else {
        if ( zSig0 == 0 ) zExp = 0;
    }
    return packFloatx80( zSign, zExp, zSig0 );

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %sil, %al
movb %dil, %sil
movb %sil, -0x11(%rbp)
movb %al, -0x12(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x30(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x32(%rbp)
movsbl -0x11(%rbp), %eax
cmpl $0x50, %eax
jne 0x1c2b1
jmp 0x1c5d3
movsbl -0x11(%rbp), %eax
cmpl $0x40, %eax
jne 0x1c2cc
movq $0x400, -0x40(%rbp)     # imm = 0x400
movq $0x7ff, -0x48(%rbp)     # imm = 0x7FF
jmp 0x1c2fa
movsbl -0x11(%rbp), %eax
cmpl $0x20, %eax
jne 0x1c2f3
movabsq $0x8000000000, %rax     # imm = 0x8000000000
movq %rax, -0x40(%rbp)
movabsq $0xffffffffff, %rax     # imm = 0xFFFFFFFFFF
movq %rax, -0x48(%rbp)
jmp 0x1c2f8
jmp 0x1c5d3
jmp 0x1c2fa
movq -0x28(%rbp), %rax
testq %rax, %rax
setne %al
movzbl %al, %eax
movl %eax, %ecx
movq -0x20(%rbp), %rax
orq %rcx, %rax
movq %rax, -0x20(%rbp)
movsbl -0x31(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x4, %eax
ja 0x1c38b
movq -0x58(%rbp), %rax
leaq 0x9612(%rip), %rcx      # 0x25940
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x1c390
movq $0x0, -0x40(%rbp)
jmp 0x1c390
movzbl -0x12(%rbp), %eax
cmpl $0x0, %eax
je 0x1c354
xorl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x1c35c
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1c390
movzbl -0x12(%rbp), %eax
cmpl $0x0, %eax
je 0x1c379
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x1c381
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0x1c381
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1c390
callq 0x1030
movq -0x20(%rbp), %rax
andq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movl $0x7ffd, %eax           # imm = 0x7FFD
cmpl %ecx, %eax
ja 0x1c526
movl $0x7ffe, %eax           # imm = 0x7FFE
cmpl -0x18(%rbp), %eax
jl 0x1c3d0
cmpl $0x7ffe, -0x18(%rbp)    # imm = 0x7FFE
jne 0x1c3d5
movq -0x20(%rbp), %rax
addq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x1c3d5
jmp 0x1c6a6
cmpl $0x0, -0x18(%rbp)
jg 0x1c524
movq -0x30(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x1c413
movq -0x30(%rbp), %rsi
movl $0xffffff80, %edi       # imm = 0xFFFFFF80
callq 0x11080
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
movzbl -0x12(%rbp), %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1c970
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x69(%rbp)
je 0x1c444
movb $0x1, %al
cmpl $0x0, -0x18(%rbp)
movb %al, -0x69(%rbp)
jl 0x1c444
movq -0x20(%rbp), %rax
movq -0x20(%rbp), %rcx
addq -0x40(%rbp), %rcx
cmpq %rcx, %rax
setbe %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x34(%rbp)
movq -0x20(%rbp), %rdi
movl $0x1, %eax
subl -0x18(%rbp), %eax
movslq %eax, %rsi
leaq -0x20(%rbp), %rdx
callq 0x11c20
movl $0x0, -0x18(%rbp)
movq -0x20(%rbp), %rax
andq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movzbl -0x34(%rbp), %eax
cmpl $0x0, %eax
je 0x1c498
cmpq $0x0, -0x50(%rbp)
je 0x1c498
movq -0x30(%rbp), %rsi
movl $0x10, %edi
callq 0x11080
cmpq $0x0, -0x50(%rbp)
je 0x1c4ad
movq -0x30(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jge 0x1c4c7
movl $0x1, -0x18(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movzbl -0x32(%rbp), %eax
cmpl $0x0, %eax
je 0x1c4f5
movq -0x50(%rbp), %rax
shlq %rax
cmpq -0x40(%rbp), %rax
jne 0x1c4f5
movq -0x40(%rbp), %rax
orq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
xorq $-0x1, %rax
andq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movb -0x12(%rbp), %al
movl -0x18(%rbp), %esi
movq -0x20(%rbp), %rdx
movzbl %al, %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1c970
jmp 0x1c526
cmpq $0x0, -0x50(%rbp)
je 0x1c53b
movq -0x30(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x1c568
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movzbl -0x32(%rbp), %eax
cmpl $0x0, %eax
je 0x1c596
movq -0x50(%rbp), %rax
shlq %rax
cmpq -0x40(%rbp), %rax
jne 0x1c596
movq -0x40(%rbp), %rax
orq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
xorq $-0x1, %rax
andq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1c5b4
movl $0x0, -0x18(%rbp)
movb -0x12(%rbp), %al
movl -0x18(%rbp), %esi
movq -0x20(%rbp), %rdx
movzbl %al, %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1c970
movsbl -0x31(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x78(%rbp)
subl $0x4, %eax
ja 0x1c657
movq -0x78(%rbp), %rax
leaq 0x9367(%rip), %rcx      # 0x25954
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x28(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x33(%rbp)
jmp 0x1c65c
movb $0x0, -0x33(%rbp)
jmp 0x1c65c
xorl %eax, %eax
cmpb $0x0, -0x12(%rbp)
movb %al, -0x79(%rbp)
jne 0x1c624
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x33(%rbp)
jmp 0x1c65c
movzbl -0x12(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x7a(%rbp)
je 0x1c64a
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x7a(%rbp)
movb -0x7a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x33(%rbp)
jmp 0x1c65c
callq 0x1030
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
movl $0x7ffd, %eax           # imm = 0x7FFD
cmpl %ecx, %eax
ja 0x1c8d7
movl $0x7ffe, %eax           # imm = 0x7FFE
cmpl -0x18(%rbp), %eax
jl 0x1c69e
cmpl $0x7ffe, -0x18(%rbp)    # imm = 0x7FFE
jne 0x1c728
cmpq $-0x1, -0x20(%rbp)
jne 0x1c728
movzbl -0x33(%rbp), %eax
cmpl $0x0, %eax
je 0x1c728
movq $0x0, -0x48(%rbp)
movq -0x30(%rbp), %rsi
movl $0x28, %edi
callq 0x11080
movsbl -0x31(%rbp), %eax
cmpl $0x3, %eax
je 0x1c6de
movzbl -0x12(%rbp), %eax
cmpl $0x0, %eax
je 0x1c6cf
movsbl -0x31(%rbp), %eax
cmpl $0x2, %eax
je 0x1c6de
cmpb $0x0, -0x12(%rbp)
jne 0x1c703
movsbl -0x31(%rbp), %eax
cmpl $0x1, %eax
jne 0x1c703
movb -0x12(%rbp), %al
movq -0x48(%rbp), %rdx
xorq $-0x1, %rdx
movl $0x7ffe, %esi           # imm = 0x7FFE
movzbl %al, %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1c970
movl $0x7fff, %esi           # imm = 0x7FFF
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
movzbl -0x12(%rbp), %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1c970
cmpl $0x0, -0x18(%rbp)
jg 0x1c8d5
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x7b(%rbp)
je 0x1c764
movb $0x1, %al
cmpl $0x0, -0x18(%rbp)
movb %al, -0x7b(%rbp)
jl 0x1c764
movb $0x1, %al
cmpb $0x0, -0x33(%rbp)
movb %al, -0x7b(%rbp)
je 0x1c764
cmpq $-0x1, -0x20(%rbp)
setb %al
movb %al, -0x7b(%rbp)
movb -0x7b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x34(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x1, %eax
subl -0x18(%rbp), %eax
movslq %eax, %rdx
leaq -0x20(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x12ce0
movl $0x0, -0x18(%rbp)
movzbl -0x34(%rbp), %eax
cmpl $0x0, %eax
je 0x1c7b4
cmpq $0x0, -0x28(%rbp)
je 0x1c7b4
movq -0x30(%rbp), %rsi
movl $0x10, %edi
callq 0x11080
cmpq $0x0, -0x28(%rbp)
je 0x1c7c9
movq -0x30(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movsbl -0x31(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x88(%rbp)
subl $0x4, %eax
ja 0x1c869
movq -0x88(%rbp), %rax
leaq 0x917b(%rip), %rcx      # 0x25968
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpq $0x0, -0x28(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x33(%rbp)
jmp 0x1c86e
movb $0x0, -0x33(%rbp)
jmp 0x1c86e
xorl %eax, %eax
cmpb $0x0, -0x12(%rbp)
movb %al, -0x89(%rbp)
jne 0x1c82a
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x33(%rbp)
jmp 0x1c86e
movzbl -0x12(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x8a(%rbp)
je 0x1c859
cmpq $0x0, -0x28(%rbp)
setne %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb %al, -0x33(%rbp)
jmp 0x1c86e
callq 0x1030
cmpb $0x0, -0x33(%rbp)
je 0x1c8b6
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
shlq %rax
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x32(%rbp), %ecx
andl %ecx, %eax
xorl $-0x1, %eax
cltq
andq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jge 0x1c8b4
movl $0x1, -0x18(%rbp)
jmp 0x1c8b6
movb -0x12(%rbp), %al
movl -0x18(%rbp), %esi
movq -0x20(%rbp), %rdx
movzbl %al, %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
jmp 0x1c970
jmp 0x1c8d7
cmpq $0x0, -0x28(%rbp)
je 0x1c8ec
movq -0x30(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
cmpb $0x0, -0x33(%rbp)
je 0x1c946
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1c91e
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0x20(%rbp)
jmp 0x1c944
movq -0x28(%rbp), %rax
shlq %rax
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x32(%rbp), %ecx
andl %ecx, %eax
xorl $-0x1, %eax
cltq
andq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x1c956
cmpq $0x0, -0x20(%rbp)
jne 0x1c954
movl $0x0, -0x18(%rbp)
jmp 0x1c956
movb -0x12(%rbp), %al
movl -0x18(%rbp), %esi
movq -0x20(%rbp), %rdx
movzbl %al, %edi
callq 0x11990
movq %rax, -0x10(%rbp)
movw %dx, -0x8(%rbp)
movq -0x10(%rbp), %rax
movw -0x8(%rbp), %dx
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)