// File: /workspace/github_c_makefile_star2_O0/mbitsnbites[P]SoftFP/softfloat.c
// Function: float128_to_int64_round_to_zero
int64 float128_to_int64_round_to_zero(float128 a, float_status *status)
{
    flag aSign;
    int32 aExp, shiftCount;
    uint64_t aSig0, aSig1;
    int64 z;

    aSig1 = extractFloat128Frac1( a );
    aSig0 = extractFloat128Frac0( a );
    aExp = extractFloat128Exp( a );
    aSign = extractFloat128Sign( a );
    if ( aExp ) aSig0 |= LIT64( 0x0001000000000000 );
    shiftCount = aExp - 0x402F;
    if ( 0 < shiftCount ) {
        if ( 0x403E <= aExp ) {
            aSig0 &= LIT64( 0x0000FFFFFFFFFFFF );
            if (    ( a.high == LIT64( 0xC03E000000000000 ) )
                 && ( aSig1 < LIT64( 0x0002000000000000 ) ) ) {
                if (aSig1) {
                    status->float_exception_flags |= float_flag_inexact;
                }
            }
            else {
                float_raise(float_flag_invalid, status);
                if ( ! aSign || ( ( aExp == 0x7FFF ) && ( aSig0 | aSig1 ) ) ) {
                    return LIT64( 0x7FFFFFFFFFFFFFFF );
                }
            }
            return (int64_t) LIT64( 0x8000000000000000 );
        }
        z = ( aSig0<<shiftCount ) | ( aSig1>>( ( - shiftCount ) & 63 ) );
        if ( (uint64_t) ( aSig1<<shiftCount ) ) {
            status->float_exception_flags |= float_flag_inexact;
        }
    }
    else {
        if ( aExp < 0x3FFF ) {
            if ( aExp | aSig0 | aSig1 ) {
                status->float_exception_flags |= float_flag_inexact;
            }
            return 0;
        }
        z = aSig0>>( - shiftCount );
        if (    aSig1
             || ( shiftCount && (uint64_t) ( aSig0<<( shiftCount & 63 ) ) ) ) {
            status->float_exception_flags |= float_flag_inexact;
        }
    }
    if ( aSign ) z = - z;
    return z;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1e410
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1e430
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1e450
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1e470
movb %al, -0x21(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x1e7be
movabsq $0x1000000000000, %rax  # imm = 0x1000000000000
orq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x28(%rbp), %eax
subl $0x402f, %eax           # imm = 0x402F
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
cmpl -0x2c(%rbp), %eax
jge 0x1e8c3
movl $0x403e, %eax           # imm = 0x403E
cmpl -0x28(%rbp), %eax
jg 0x1e87e
movabsq $0xffffffffffff, %rax   # imm = 0xFFFFFFFFFFFF
andq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movabsq $-0x3fc2000000000000, %rax # imm = 0xC03E000000000000
cmpq %rax, -0x10(%rbp)
jne 0x1e82b
movabsq $0x2000000000000, %rax  # imm = 0x2000000000000
cmpq %rax, -0x40(%rbp)
jae 0x1e82b
cmpq $0x0, -0x40(%rbp)
je 0x1e829
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
jmp 0x1e86b
movq -0x20(%rbp), %rsi
movl $0x1, %edi
callq 0x11080
cmpb $0x0, -0x21(%rbp)
je 0x1e856
cmpl $0x7fff, -0x28(%rbp)    # imm = 0x7FFF
jne 0x1e869
movq -0x38(%rbp), %rax
orq -0x40(%rbp), %rax
cmpq $0x0, %rax
je 0x1e869
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movq %rax, -0x8(%rbp)
jmp 0x1e952
jmp 0x1e86b
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq %rax, -0x8(%rbp)
jmp 0x1e952
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
shlq %cl, %rax
movq -0x40(%rbp), %rdx
xorl %ecx, %ecx
subl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
shlq %cl, %rax
cmpq $0x0, %rax
je 0x1e8c1
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
jmp 0x1e93a
cmpl $0x3fff, -0x28(%rbp)    # imm = 0x3FFF
jge 0x1e8f6
movslq -0x28(%rbp), %rax
orq -0x38(%rbp), %rax
orq -0x40(%rbp), %rax
cmpq $0x0, %rax
je 0x1e8ec
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x1e952
movq -0x38(%rbp), %rax
xorl %ecx, %ecx
subl -0x2c(%rbp), %ecx
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x1e92a
cmpl $0x0, -0x2c(%rbp)
je 0x1e938
movq -0x38(%rbp), %rax
movl -0x2c(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
shlq %cl, %rax
cmpq $0x0, %rax
je 0x1e938
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
orl $0x20, %ecx
movb %cl, 0x2(%rax)
jmp 0x1e93a
cmpb $0x0, -0x21(%rbp)
je 0x1e94a
xorl %eax, %eax
subq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)