// File: /workspace/github_c_makefile_star2_O2/mbitsnbites[P]SoftFP/./softfp_template.h
// Function: add_sf128
F_UINT add_sf(F_UINT a, F_UINT b, RoundingModeEnum rm,
              uint32_t *pfflags)
{
    uint32_t a_sign, b_sign, a_exp, b_exp;
    F_UINT tmp, a_mant, b_mant;

    /* swap so that  abs(a) >= abs(b) */
    if ((a & ~SIGN_MASK) < (b & ~SIGN_MASK)) {
        tmp = a;
        a = b;
        b = tmp;
    }
    a_sign = a >> (F_SIZE - 1);
    b_sign = b >> (F_SIZE - 1);
    a_exp = (a >> MANT_SIZE) & EXP_MASK;
    b_exp = (b >> MANT_SIZE) & EXP_MASK;
    a_mant = (a & MANT_MASK) << 3;
    b_mant = (b & MANT_MASK) << 3;
    if (unlikely(a_exp == EXP_MASK)) {
        if (a_mant != 0) {
            /* NaN result */
            if (!(a_mant & (QNAN_MASK << 3)) || issignan_sf(b))
                *pfflags |= FFLAG_INVALID_OP;
            return F_QNAN;
        } else if (b_exp == EXP_MASK && a_sign != b_sign) {
            *pfflags |= FFLAG_INVALID_OP;
            return F_QNAN;
        } else {
            /* infinity */
            return a;
        }
    }
    if (a_exp == 0) {
        a_exp = 1;
    } else {
        a_mant |= (F_UINT)1 << (MANT_SIZE + 3);
    }
    if (b_exp == 0) {
        b_exp = 1;
    } else {
        b_mant |= (F_UINT)1 << (MANT_SIZE + 3);
    }
    b_mant = rshift_rnd(b_mant, a_exp - b_exp);
    if (a_sign == b_sign) {
        /* same signs : add the absolute values  */
        a_mant += b_mant;
    } else {
        /* different signs : subtract the absolute values  */
        a_mant -= b_mant;
        if (a_mant == 0) {
            /* zero result : the sign needs a specific handling */
            a_sign = (rm == RM_RDN);
        }
    }
    a_exp += (RND_SIZE - 3);
    return normalize_sf(a_sign, a_exp, a_mant, rm, pfflags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r10
movq %rdi, %rax
btrq $0x3f, %rsi
movq %rcx, %rdi
btrq $0x3f, %rdi
cmpq %rdx, %rax
sbbq %rdi, %rsi
movq %rdx, %rdi
cmovbq %rax, %rdi
movq %rcx, %rsi
cmovbq %r10, %rsi
cmovbq %rdx, %rax
cmovbq %rcx, %r10
movq %r10, %r14
shrq $0x3f, %r14
movq %rsi, %r12
shrq $0x3f, %r12
movq %r10, %r15
shrq $0x30, %r15
movq %rsi, %rcx
shrq $0x30, %rcx
movl $0x7fff, %r11d          # imm = 0x7FFF
andl %r11d, %ecx
movq %r10, %r13
shldq $0x3, %rax, %r13
leaq (,%rax,8), %rbx
movabsq $0x7ffffffffffff, %rdx  # imm = 0x7FFFFFFFFFFFF
andq %rdx, %r13
andl %r11d, %r15d
movl %r8d, 0x4(%rsp)
je 0x6f81
cmpl $0x7fff, %r15d          # imm = 0x7FFF
je 0x701f
movq %r9, %rbp
btsq $0x33, %r13
jmp 0x6f88
movq %r9, %rbp
pushq $0x1
popq %r15
shldq $0x3, %rdi, %rsi
shlq $0x3, %rdi
andq %rdx, %rsi
testl %ecx, %ecx
leaq 0x1(%rsi,%rdx), %rax
cmoveq %rsi, %rax
cmpl $0x1, %ecx
movl %r15d, %edx
sbbl %ecx, %edx
movq %rax, %rsi
callq 0x706a
movq %rdx, %rsi
cmpl %r12d, %r14d
jne 0x6fcd
addq %rbx, %rax
adcq %r13, %rsi
movq %rax, %rdx
movq %rsi, %rcx
movq %rbp, %r9
movl 0x4(%rsp), %r8d
jmp 0x6ffb
movq %rbx, %rdx
subq %rax, %rdx
movq %r13, %rcx
sbbq %rsi, %rcx
xorq %rax, %rbx
xorq %rsi, %r13
orq %rbx, %r13
movq %rbp, %r9
movl 0x4(%rsp), %r8d
jne 0x6ffb
xorl %r14d, %r14d
cmpl $0x2, %r8d
sete %r14b
xorl %edx, %edx
xorl %ecx, %ecx
addl $0xb, %r15d
movl %r14d, %edi
movl %r15d, %esi
callq 0x70e0
movq %rdx, %r14
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
orq %r13, %rbx
je 0x7046
movabsq $0x7fff800000000000, %r14 # imm = 0x7FFF800000000000
btq $0x2f, %r10
jae 0x705d
movq %r9, %rbx
callq 0x6e82
movq %rbx, %r9
testl %eax, %eax
jne 0x705d
jmp 0x7061
cmpl $0x7fff, %ecx           # imm = 0x7FFF
jne 0x7065
cmpl %r12d, %r14d
je 0x7065
movabsq $0x7fff800000000000, %r14 # imm = 0x7FFF800000000000
orb $0x10, (%r9)
xorl %eax, %eax
jmp 0x700d
movq %r10, %r14
jmp 0x700d