// File: /workspace/github_cpp_makefile_star2_O2/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 0x1aef77(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x145c4d(%rip), %rdi    # 0x1e9cc0
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 0x145c48(%rip), %rsi    # 0x1e9ce1
movq %rax, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x2050
leaq 0x1565f4(%rip), %r12    # 0x1fa6a1
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2210
movq %rax, %r13
leaq 0x145c31(%rip), %rsi    # 0x1e9cf3
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 0x1b0148(%rip), %r14    # 0x254230
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpq 0x50(%r14), %r12
jae 0xa419b
movq 0x28(%r14), %rax
cmpb $0x1, (%rax,%r12)
jne 0xa4147
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 %r15, %r15
je 0xa4130
leaq 0x153f43(%rip), %rsi    # 0x1f806a
xorl %eax, %eax
callq 0x22b0
jmp 0xa4143
leaq 0x145bce(%rip), %rsi    # 0x1e9d05
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %r15
movq 0x28(%r14), %rax
cmpb $0x2, (%rax,%r12)
jne 0xa4193
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 %rbx, %rbx
je 0xa417d
leaq 0x153ef6(%rip), %rsi    # 0x1f806a
xorl %eax, %eax
callq 0x22b0
jmp 0xa4190
leaq 0x145b81(%rip), %rsi    # 0x1e9d05
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x22b0
pushq $0x1
popq %rbx
incq %r12
jmp 0xa40f0
movq (%rsp), %rdi
callq 0x2220
movq %r13, %rdi
callq 0x2190
movq %rbp, %rdi
callq 0x2190
movq 0x1aee25(%rip), %rax    # 0x252fe0
movq (%rax), %rcx
leaq 0x145b49(%rip), %rdi    # 0x1e9d0e
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