// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10(%rsp)
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)
cmpl $0x0, 0x8(%rsi)
jle 0x1379f4
movq %rsi, %rbp
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %r15
jge 0x1379fa
movq 0x10(%rbp), %rax
movq (%rax,%r15,8), %rdi
leaq 0xfbda0(%rip), %rsi     # 0x2335a7
callq 0x22d0
testq %rax, %rax
je 0x1379b2
movq %rax, %r13
movq %rax, %rdi
callq 0x137aa0
movq %rax, %rbp
movq %rax, %rdi
jmp 0x13798e
movq 0x20(%rbx), %rax
cmpq %rax, 0x18(%rbx)
jne 0x13785a
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x20(%rbx)
movq 0x28(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rax
movq 0x28(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x18(%rbx)
movq %r14, (%rcx,%rax,8)
movq (%rbp), %rax
addq %r14, %rax
cmpq %rax, 0x8(%rbx)
jae 0x1378c3
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)
movq 0x10(%rbx), %rdi
callq 0x2370
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
addq %r14, %rdi
movq (%rbp), %rdx
movq 0x10(%rbp), %rsi
callq 0x2160
addq (%rbp), %r14
movq 0x50(%rbx), %rax
cmpq %rax, 0x48(%rbx)
jne 0x13790a
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x50(%rbx)
movq 0x58(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movq %r12, (%rcx,%rax,8)
movq 0x30(%rbp), %rax
addq %r12, %rax
cmpq %rax, 0x38(%rbx)
jae 0x137973
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)
movq 0x40(%rbx), %rdi
callq 0x2370
movq %rax, 0x40(%rbx)
movq 0x40(%rbx), %rdi
addq %r12, %rdi
movq 0x30(%rbp), %rdx
movq 0x40(%rbp), %rsi
callq 0x2160
addq 0x30(%rbp), %r12
movq %rbp, %rdi
callq 0x137aea
testl %eax, %eax
jns 0x13782b
movq %rbp, %rdi
callq 0x137e71
movq %r13, %rdi
callq 0x2390
movq 0x8(%rsp), %rbp
jmp 0x1379d9
movq %rax, %r13
movq 0x10(%rbx), %rdi
callq 0x2220
movq 0x28(%rbx), %rdi
callq 0x2220
movq 0x40(%rbx), %rdi
callq 0x2220
movq 0x58(%rbx), %rdi
callq 0x2220
testq %r13, %r13
je 0x137a8f
incq %r15
movslq 0x8(%rbp), %rax
cmpq %rax, %r15
jl 0x1377e6
jmp 0x1379fa
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x20(%rbx), %rax
cmpq %rax, 0x18(%rbx)
jne 0x137a29
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x20(%rbx)
movq 0x28(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rax
movq 0x28(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x18(%rbx)
movq %r14, (%rcx,%rax,8)
movq 0x50(%rbx), %rax
cmpq %rax, 0x48(%rbx)
jne 0x137a6c
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x50(%rbx)
movq 0x58(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
movq %r12, (%rcx,%rax,8)
movq $0x0, 0x60(%rbx)
movl $0x1, %eax
jmp 0x137a91
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq