// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: load_reads(reads_t*, enzyme const*, enzyme const*)
int load_reads(reads_t* x, const enzyme *fn1, const enzyme *fn2)
{
    kv_init(x->name);
    kv_init(x->name_Len);
    kv_init(x->r);
    kv_init(x->r_Len);
    
    int ret;
    uint64_t name_tot, base_total;
    int i;
    name_tot = base_total = 0;

    for (i = 0; i < fn1->n && i < fn2->n; i++)
    {
        gzFile fp;
        if ((fp = gzopen(fn1->a[i], "r")) == 0)
        {
            kv_destroy(x->name);
            kv_destroy(x->name_Len);
            kv_destroy(x->r);
            kv_destroy(x->r_Len);
            return 0;
        } 
        
        kseq_t *ks;
        ks = kseq_init(fp);

        while (((ret = kseq_read(ks)) >= 0))
        {
            kv_push(uint64_t, x->name_Len, name_tot);
            kv_resize(char, x->name, name_tot + ks->name.l);
            memcpy(x->name.a + name_tot, ks->name.s, ks->name.l);
            name_tot += ks->name.l;

            kv_push(uint64_t, x->r_Len, base_total);
            kv_resize(char, x->r, base_total + ks->seq.l);
            memcpy(x->r.a + base_total, ks->seq.s, ks->seq.l);
            base_total += ks->seq.l;
        }
        
        kseq_destroy(ks);
        gzclose(fp);
    }
    kv_push(uint64_t, x->name_Len, name_tot);
    kv_push(uint64_t, x->r_Len, base_total);
    x->idx = 0;
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %rbp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
xorl %ecx, %ecx
pushq $0x2
popq %r14
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %rsi, (%rsp)
movslq 0x8(%rbp), %rax
cmpq %rax, %rcx
jge 0xf625c
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %rcx
jge 0xf625c
movq 0x10(%rbp), %rax
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx,8), %rdi
leaq 0xfb601(%rip), %rsi     # 0x1f16b7
callq 0x22d0
testq %rax, %rax
je 0xf62e0
movq %rax, %r13
movq %rax, %rdi
callq 0xf6315
movq %rax, %rbp
movq %rbp, %rdi
callq 0xf635b
testl %eax, %eax
js 0xf623b
movq 0x18(%rbx), %rcx
movq 0x28(%rbx), %rax
cmpq 0x20(%rbx), %rcx
jne 0xf6113
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r14, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x18(%rbx)
movq %r15, (%rax,%rcx,8)
movq (%rbp), %rdx
leaq (%rdx,%r15), %rax
movq 0x10(%rbx), %rdi
cmpq %rax, 0x8(%rbx)
jae 0xf617c
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
callq 0x2370
movq %rax, %rdi
movq %rax, 0x10(%rbx)
movq (%rbp), %rdx
addq %r15, %rdi
movq 0x10(%rbp), %rsi
callq 0x2160
addq (%rbp), %r15
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rax
cmpq 0x50(%rbx), %rcx
jne 0xf61bd
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r14, %rsi
movq %rsi, 0x50(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x48(%rbx)
movq %r12, (%rax,%rcx,8)
movq 0x30(%rbp), %rdx
leaq (%rdx,%r12), %rax
movq 0x40(%rbx), %rdi
cmpq %rax, 0x38(%rbx)
jae 0xf6226
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x38(%rbx)
callq 0x2370
movq %rax, %rdi
movq %rax, 0x40(%rbx)
movq 0x30(%rbp), %rdx
addq %r12, %rdi
movq 0x40(%rbp), %rsi
callq 0x2160
addq 0x30(%rbp), %r12
jmp 0xf60d2
movq %rbp, %rdi
callq 0xf654e
movq %r13, %rdi
callq 0x2390
movq 0x10(%rsp), %rcx
incq %rcx
movq (%rsp), %rbp
jmp 0xf6083
movq 0x18(%rbx), %rcx
movq 0x28(%rbx), %rax
cmpq 0x20(%rbx), %rcx
jne 0xf628d
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r14, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x18(%rbx)
movq %r15, (%rax,%rcx,8)
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rax
cmpq 0x50(%rbx), %rcx
jne 0xf62ca
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r14, %rsi
movq %rsi, 0x50(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x48(%rbx)
movq %r12, (%rax,%rcx,8)
andq $0x0, 0x60(%rbx)
pushq $0x1
popq %rax
jmp 0xf6306
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x28(%rbx), %rdi
callq 0x2220
movq 0x40(%rbx), %rdi
callq 0x2220
movq 0x58(%rbx), %rdi
callq 0x2220
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq