// File: chhylp123[P]hifiasm/htab.cpp
// Function: debug_adapter(hifiasm_opt_t const*, All_reads*)
void debug_adapter(const hifiasm_opt_t *asm_opt, All_reads *rs)
{
	int ret;
    uint32_t i, m, pass, unpass;
    gzFile fp = 0;
    kseq_t *ks = NULL;
	UC_Read ucr;
	init_UC_Read(&ucr);

    for (i = m = pass = unpass = 0; i < (uint32_t)asm_opt->num_reads; ++i)
    {
		if ((fp = gzopen(asm_opt->read_file_names[i], "r")) == 0) continue;
		ks = kseq_init(fp);
		while ((ret = kseq_read(ks)) >= 0) 
		{
			int l = ks->seq.l;
			if((l - asm_opt->adapterLen*2) <= 0) continue;
			recover_UC_Read(&ucr, rs, m);
			fprintf(stderr, "l: %d, ucr.length: %lld, asm_opt->adapterLen: %d\n", 
			l, ucr.length, asm_opt->adapterLen);
			if(memcmp(ucr.seq, ks->seq.s+asm_opt->adapterLen, ucr.length) == 0)
			{
				pass++;
			}
			else
			{
				unpass++;
			}
			m++;
		}
        kseq_destroy(ks);
        gzclose(fp);
		ks = NULL;
		fp = 0;
    }

	destory_UC_Read(&ucr);

	fprintf(stderr, "[M::%s::# reads: %u, # pass: %u, # unpass: %u\n]", __func__, m, pass, unpass);
	exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x9850
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x18820a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x18(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x2082db(%rip), %rsi    # 0x3903d6
callq 0x22c0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x18810f
jmp 0x1881fc
movq -0x30(%rbp), %rdi
callq 0x188250
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x188290
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jl 0x1881da
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x100(%rcx), %ecx
shll %ecx
subl %ecx, %eax
cmpl $0x0, %eax
jg 0x188154
jmp 0x18811c
movq -0x10(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
leaq -0x58(%rbp), %rdi
callq 0xa380
movq 0x23be73(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x5c(%rbp), %edx
movq -0x50(%rbp), %rcx
movq -0x8(%rbp), %rax
movl 0x100(%rax), %r8d
leaq 0x202898(%rip), %rsi    # 0x38aa21
movb $0x0, %al
callq 0x22a0
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x8(%rbp), %rax
movslq 0x100(%rax), %rax
addq %rax, %rsi
movq -0x50(%rbp), %rdx
callq 0x20b0
cmpl $0x0, %eax
jne 0x1881c3
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1881cc
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x18811c
movq -0x38(%rbp), %rdi
callq 0x188680
movq -0x30(%rbp), %rdi
callq 0x2380
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1880d5
leaq -0x58(%rbp), %rdi
callq 0x9670
movq 0x23bdc6(%rip), %rax    # 0x3c3fe0
movq (%rax), %rdi
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
leaq 0x202824(%rip), %rsi    # 0x38aa53
leaq 0x20284d(%rip), %rdx    # 0x38aa83
movb $0x0, %al
callq 0x22a0
movl $0x1, %edi
callq 0x2240
nopw (%rax,%rax)