// File: /workspace/github_cpp_makefile_star2_O3/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 %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 0x13d7d5
movq %rsi, %rbp
xorl %r15d, %r15d
movl $0x2, %r13d
xorl %r14d, %r14d
xorl %r12d, %r12d
movq %rsi, (%rsp)
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %r15
jge 0x13d7b2
movq 0x10(%rbp), %rax
movq (%rax,%r15,8), %rdi
leaq 0x1021f5(%rip), %rsi    # 0x23f7f7
callq 0x22d0
testq %rax, %rax
je 0x13d857
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x13d88c
movq %rax, %rbp
movq %rax, %rdi
callq 0x13d8d6
testl %eax, %eax
js 0x13d78c
movq 0x18(%rbx), %rcx
movq 0x28(%rbx), %rax
cmpq 0x20(%rbx), %rcx
jne 0x13d661
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %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 %r14, (%rax,%rcx,8)
movq (%rbp), %rdx
leaq (%rdx,%r14), %rax
movq 0x10(%rbx), %rdi
cmpq %rax, 0x8(%rbx)
jae 0x13d6ca
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 %r14, %rdi
movq 0x10(%rbp), %rsi
callq 0x2160
addq (%rbp), %r14
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rax
cmpq 0x50(%rbx), %rcx
jne 0x13d70b
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r13, %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 0x13d774
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
movq %rbp, %rdi
jmp 0x13d623
movq %rbp, %rdi
callq 0x13dc3f
movq 0x10(%rsp), %rdi
callq 0x2390
incq %r15
movq (%rsp), %rbp
movslq 0x8(%rbp), %rax
cmpq %rax, %r15
jl 0x13d5e1
movq 0x18(%rbx), %rcx
movq 0x20(%rbx), %rdx
movq 0x28(%rbx), %rax
cmpq %rdx, %rcx
jne 0x13d7fa
leaq (%rdx,%rdx), %rcx
testq %rdx, %rdx
movl $0x2, %esi
cmovneq %rcx, %rsi
jmp 0x13d7e2
movl $0x2, %esi
xorl %eax, %eax
xorl %r12d, %r12d
xorl %r14d, %r14d
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 %r14, (%rax,%rcx,8)
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rax
cmpq 0x50(%rbx), %rcx
jne 0x13d83c
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rdx, %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 $0x0, 0x60(%rbx)
movl $0x1, %eax
jmp 0x13d87d
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