// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: write_yak_binning(char*, char*, char*)
void write_yak_binning(char *ou, char *fn_bin_yak1, char *fn_bin_yak2)
{
    fprintf(stderr, "Writing binning to disk ...... \n");
    char* paf_name = (char*)malloc(strlen(ou)+50);
    sprintf(paf_name, "%s.hap1.phase.bin", ou);
    FILE* oh1 = fopen(paf_name, "w");
    sprintf(paf_name, "%s.hap2.phase.bin", ou);
    FILE* oh2 = fopen(paf_name, "w");
    uint64_t i, s1, s2;

    for (i = s1 = s2 = 0; i < R_INF.total_reads; i++) {
        if(R_INF.trio_flag[i]==FATHER) {
            if(s1) {
                fprintf(oh1, "%.*s\n", (int)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i));
            } else {
                fprintf(oh1, "%.*s\t%s\n", (int)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i), fn_bin_yak1);
            }
            s1 = 1;
        }
        if(R_INF.trio_flag[i]==MOTHER) {
            if(s2) {
                fprintf(oh2, "%.*s\n", (int)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i));
            } else {
                fprintf(oh2, "%.*s\t%s\n", (int)Get_NAME_LENGTH(R_INF, i), Get_NAME(R_INF, i), fn_bin_yak2);
            }
            s2 = 1;
        }
    }
    free(paf_name);
    fclose(oh1); fclose(oh2);
    fprintf(stderr, "Binning has been written.\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
movq 0x288f04(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x22bcda(%rip), %rdi    # 0x237dc0
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x2410
movq %r14, %rdi
callq 0x2090
leaq 0x32(%rax), %rdi
callq 0x2280
movq %rax, %rbx
leaq 0x22bcd5(%rip), %rsi    # 0x237de1
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x23c5c2(%rip), %r12    # 0x2486e2
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, %r13
leaq 0x22bcbe(%rip), %rsi    # 0x237df3
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
movq %rbx, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, %rbp
leaq 0x28a0d5(%rip), %r14    # 0x296230
cmpq $0x0, 0x50(%r14)
je 0xc214
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r12d, %r12d
movq 0x28(%r14), %rax
cmpb $0x1, (%rax,%r12)
jne 0xc1ba
movq 0x40(%r14), %rax
movl 0x8(%rax,%r12,8), %edx
movq (%rax,%r12,8), %rcx
subl %ecx, %edx
addq 0x8(%r14), %rcx
movq %r13, %rdi
testq %rbx, %rbx
je 0xc1a4
leaq 0x239fff(%rip), %rsi    # 0x24619a
xorl %eax, %eax
callq 0x22b0
jmp 0xc1b7
leaq 0x22bc5a(%rip), %rsi    # 0x237e05
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %rbx
movq 0x28(%r14), %rax
cmpb $0x2, (%rax,%r12)
jne 0xc207
movq 0x40(%r14), %rax
movl 0x8(%rax,%r12,8), %edx
movq (%rax,%r12,8), %rcx
subl %ecx, %edx
addq 0x8(%r14), %rcx
movq %rbp, %rdi
testq %r15, %r15
je 0xc1f0
leaq 0x239fb3(%rip), %rsi    # 0x24619a
xorl %eax, %eax
callq 0x22b0
jmp 0xc203
leaq 0x22bc0e(%rip), %rsi    # 0x237e05
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %r15
incq %r12
cmpq 0x50(%r14), %r12
jb 0xc16e
movq (%rsp), %rdi
callq 0x2220
movq %r13, %rdi
callq 0x2190
movq %rbp, %rdi
callq 0x2190
movq 0x288dac(%rip), %rax    # 0x294fe0
movq (%rax), %rcx
leaq 0x22bbd0(%rip), %rdi    # 0x237e0e
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2410