// File: /workspace/github_c_makefile_star2_O3/mbitsnbites[P]SoftFP/./softfp_template.h
// Function: sqrt_sf128
F_UINT sqrt_sf(F_UINT a, RoundingModeEnum rm,
               uint32_t *pfflags)
{
    uint32_t a_sign;
    int32_t a_exp;
    F_UINT a_mant;

    a_sign = a >> (F_SIZE - 1);
    a_exp = (a >> MANT_SIZE) & EXP_MASK;
    a_mant = a & MANT_MASK;
    if (a_exp == EXP_MASK) {
        if (a_mant != 0) {
            if (issignan_sf(a)) {
                *pfflags |= FFLAG_INVALID_OP;
            }
            return F_QNAN;
        } else if (a_sign) {
            goto neg_error;
        } else {
            return a; /* +infinity */
        }
    }
    if (a_sign) {
        if (a_exp == 0 && a_mant == 0)
            return a; /* -zero */
    neg_error:
        *pfflags |= FFLAG_INVALID_OP;
        return F_QNAN;
    }
    if (a_exp == 0) {
        if (a_mant == 0)
            return pack_sf(0, 0, 0); /* zero */
        a_mant = normalize_subnormal_sf(&a_exp, a_mant);
    } else {
        a_mant |= (F_UINT)1 << MANT_SIZE;
    }
    a_exp -= EXP_MASK / 2;
    /* simpler to handle an even exponent */
    if (a_exp & 1) {
        a_exp--;
        a_mant <<= 1;
    }
    a_exp = (a_exp >> 1) + EXP_MASK / 2;
    a_mant <<= (F_SIZE - 4 - MANT_SIZE);
    if (sqrtrem_u(&a_mant, a_mant, 0))
        a_mant |= 1;
    return normalize_sf(a_sign, a_exp, a_mant, rm, pfflags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r9
movq %rsi, %r14
shrq $0x30, %r14
movl $0x7fff, %eax           # imm = 0x7FFF
andl %eax, %r14d
movabsq $0xffffffffffff, %r15   # imm = 0xFFFFFFFFFFFF
andq %rsi, %r15
cmpl %eax, %r14d
jne 0x88a9
orq %r15, %rdi
je 0x88c0
movabsq $0x7fff800000000000, %rdx # imm = 0x7FFF800000000000
andq %rdx, %rsi
movabsq $0x7fff000000000000, %rax # imm = 0x7FFF000000000000
cmpq %rax, %rsi
je 0x88e9
jmp 0x88ed
testq %rsi, %rsi
js 0x88cf
movl %edx, %r8d
testl %r14d, %r14d
je 0x88f4
btsq $0x30, %r15
movq %rdi, %r12
jmp 0x8938
testq %rsi, %rsi
js 0x88df
xorl %eax, %eax
movq %rsi, %rdx
jmp 0x8a57
testl %r14d, %r14d
sete %al
orq %r15, %rdi
sete %cl
testb %cl, %al
jne 0x88c5
movabsq $0x7fff800000000000, %rdx # imm = 0x7FFF800000000000
orb $0x10, (%r9)
xorl %eax, %eax
jmp 0x8a57
movq %rdi, %rax
orq %r15, %rax
je 0x8a66
bsrq %rdi, %rax
xorl $0x3f, %eax
orl $0x40, %eax
bsrq %r15, %rcx
xorl $0x3f, %ecx
testq %r15, %r15
cmovel %eax, %ecx
movl $0x10, %r14d
subl %ecx, %r14d
addb $-0xf, %cl
shldq %cl, %rdi, %r15
shlq %cl, %rdi
xorl %r12d, %r12d
testb $0x40, %cl
cmovneq %rdi, %r15
cmoveq %rdi, %r12
leal -0x3fff(%r14), %eax
movl %eax, %ecx
andl $0x1, %ecx
addl $0xffffc000, %r14d      # imm = 0xFFFFC000
testl %ecx, %ecx
cmovel %eax, %r14d
shldq %cl, %r12, %r15
shlq %cl, %r12
sarl %r14d
shldq $0xc, %r12, %r15
addl $0x3fff, %r14d          # imm = 0x3FFF
shlq $0xc, %r12
movq %r12, %rax
orq %r15, %rax
je 0x8a45
movl %r8d, 0x4(%rsp)
movq %r9, 0x8(%rsp)
movq %r12, %rax
addq $-0x1, %rax
movq %r15, %rcx
adcq $-0x1, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
bsrq %rax, %rax
xorl $0x3f, %eax
orl $0x40, %eax
testq %rcx, %rcx
cmovnel %edx, %eax
movl $0x101, %ecx            # imm = 0x101
subl %eax, %ecx
shrl %ecx
movl $0x1, %edx
xorl %esi, %esi
shldq %cl, %rdx, %rsi
shlq %cl, %rdx
xorl %eax, %eax
testb $0x40, %cl
cmovneq %rdx, %rsi
cmovneq %rax, %rdx
leaq 0x20(%rsp), %rbx
movq %rsi, %r13
movq %rdx, %rbp
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0x87c1
addq %rbp, %rax
adcq %r13, %rdx
movq %rdx, %rsi
shrq %rsi
shldq $0x3f, %rax, %rdx
cmpq %rbp, %rdx
movq %rsi, %rax
sbbq %r13, %rax
jb 0x89cf
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0x7da1
movq %rdx, %rcx
xorq %r12, %rax
xorq %r15, %rcx
orq 0x8(%rbx), %rcx
orq (%rbx), %rax
xorl %edx, %edx
orq %rcx, %rax
setne %dl
orq %rbp, %rdx
movq 0x8(%rsp), %r9
movl 0x4(%rsp), %r8d
jmp 0x8a4a
xorl %edx, %edx
xorl %r13d, %r13d
xorl %edi, %edi
movl %r14d, %esi
movq %r13, %rcx
callq 0x7ad0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
xorl %edx, %edx
jmp 0x8a57