// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: roundAndPackInt32
static int32 roundAndPackInt32(flag zSign, uint64_t absZ, float_status *status)
{
    int8 roundingMode;
    flag roundNearestEven;
    int8 roundIncrement, roundBits;
    int32_t z;

    roundingMode = status->float_rounding_mode;
    roundNearestEven = ( roundingMode == float_round_nearest_even );
    switch (roundingMode) {
    case float_round_nearest_even:
    case float_round_ties_away:
        roundIncrement = 0x40;
        break;
    case float_round_to_zero:
        roundIncrement = 0;
        break;
    case float_round_up:
        roundIncrement = zSign ? 0 : 0x7f;
        break;
    case float_round_down:
        roundIncrement = zSign ? 0x7f : 0;
        break;
    default:
        abort();
    }
    roundBits = absZ & 0x7F;
    absZ = ( absZ + roundIncrement )>>7;
    absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
    z = absZ;
    if ( zSign ) z = - z;
    if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
        float_raise(float_flag_invalid, status);
        return zSign ? (int32_t) 0x80000000 : 0x7FFFFFFF;
    }
    if (roundBits) {
        status->float_exception_flags |= float_flag_inexact;
    }
    return z;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb 0x1(%rax), %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
testb %al, %al
sete -0x1a(%rbp)
movsbl -0x19(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x4, %eax
ja 0x128a4
movq -0x28(%rbp), %rax
leaq 0x12ff5(%rip), %rcx     # 0x25858
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x40, -0x1b(%rbp)
jmp 0x128a9
movb $0x0, -0x1b(%rbp)
jmp 0x128a9
movzbl -0x5(%rbp), %edx
movl $0x7f, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x1b(%rbp)
jmp 0x128a9
movzbl -0x5(%rbp), %edx
xorl %eax, %eax
movl $0x7f, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, -0x1b(%rbp)
jmp 0x128a9
callq 0x1030
movq -0x10(%rbp), %rax
andq $0x7f, %rax
movb %al, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movsbq -0x1b(%rbp), %rcx
addq %rcx, %rax
shrq $0x7, %rax
movq %rax, -0x10(%rbp)
movsbl -0x1c(%rbp), %eax
xorl $0x40, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x1a(%rbp), %ecx
andl %ecx, %eax
xorl $-0x1, %eax
cltq
andq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl %eax, -0x20(%rbp)
cmpb $0x0, -0x5(%rbp)
je 0x12902
xorl %eax, %eax
subl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
shrq $0x20, %rax
cmpq $0x0, %rax
jne 0x1292d
cmpl $0x0, -0x20(%rbp)
je 0x12954
cmpl $0x0, -0x20(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
movzbl -0x5(%rbp), %ecx
xorl %ecx, %eax
cmpl $0x0, %eax
je 0x12954
movq -0x18(%rbp), %rsi
movl $0x1, %edi
callq 0x11080
movzbl -0x5(%rbp), %edx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x80000000, %ecx       # imm = 0x80000000
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x1296e
cmpb $0x0, -0x1c(%rbp)
je 0x12968
movq -0x18(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)