// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq 0x291025(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x2559e6(%rip), %rsi    # 0x3889ab
movb $0x0, %al
callq 0x22a0
movq -0x8(%rbp), %rdi
callq 0x20a0
movq %rax, %rdi
addq $0x32, %rdi
callq 0x2270
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq 0x2559d8(%rip), %rsi    # 0x3889cc
movb $0x0, %al
callq 0x2050
movq -0x20(%rbp), %rdi
leaq 0x2663cc(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq 0x2559c0(%rip), %rsi    # 0x3889de
movb $0x0, %al
callq 0x2050
movq -0x20(%rbp), %rdi
leaq 0x2663a2(%rip), %rsi    # 0x3993d2
callq 0x2200
movq %rax, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
leaq 0x292274(%rip), %rcx    # 0x3c52d0
cmpq 0x50(%rcx), %rax
jae 0x13323f
leaq 0x292263(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x133149
cmpq $0x0, -0x40(%rbp)
je 0x1330e4
movq -0x28(%rbp), %rdi
leaq 0x29223c(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x292228(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x38(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x292213(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x292208(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x263c6f(%rip), %rsi    # 0x396d4a
movb $0x0, %al
callq 0x22a0
jmp 0x133141
movq -0x28(%rbp), %rdi
leaq 0x2921e1(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x2921cd(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x38(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x2921b8(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x2921ad(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
movq -0x10(%rbp), %r8
leaq 0x2558b6(%rip), %rsi    # 0x3889f0
movb $0x0, %al
callq 0x22a0
movq $0x1, -0x40(%rbp)
leaq 0x292180(%rip), %rax    # 0x3c52d0
movq 0x28(%rax), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x13322c
cmpq $0x0, -0x48(%rbp)
je 0x1331c7
movq -0x30(%rbp), %rdi
leaq 0x292159(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x292145(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x38(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x292130(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x292125(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
leaq 0x263b8c(%rip), %rsi    # 0x396d4a
movb $0x0, %al
callq 0x22a0
jmp 0x133224
movq -0x30(%rbp), %rdi
leaq 0x2920fe(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
leaq 0x2920ea(%rip), %rcx    # 0x3c52d0
movq 0x40(%rcx), %rcx
movq -0x38(%rbp), %rdx
subq (%rcx,%rdx,8), %rax
movl %eax, %edx
leaq 0x2920d5(%rip), %rax    # 0x3c52d0
movq 0x8(%rax), %rcx
leaq 0x2920ca(%rip), %rax    # 0x3c52d0
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rsi
addq (%rax,%rsi,8), %rcx
movq -0x18(%rbp), %r8
leaq 0x2557d3(%rip), %rsi    # 0x3889f0
movb $0x0, %al
callq 0x22a0
movq $0x1, -0x48(%rbp)
jmp 0x13322e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x133051
movq -0x20(%rbp), %rdi
callq 0x2210
movq -0x28(%rbp), %rdi
callq 0x21a0
movq -0x30(%rbp), %rdi
callq 0x21a0
movq 0x290d7f(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
leaq 0x25578e(%rip), %rsi    # 0x3889f9
movb $0x0, %al
callq 0x22a0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)