// File: /workspace/github_c_makefile_star2_O0/rikuu[P]kermit/miniasm/hit.c
// Function: ma_hit_read
ma_hit_t *ma_hit_read(const char *fn, int min_span, int min_match, sdict_t *d, size_t *n, int bi_dir, const sdict_t *excl)
{
	paf_file_t *fp;
	paf_rec_t r;
	ma_hit_v h = {0,0,0};
	size_t i, tot = 0, tot_len = 0;

	fp = paf_open(fn);
	if (!fp) {
		fprintf(stderr, "[E::%s] could not open PAF file %s\n", __func__, fn);
		exit(1);
	}
	while (paf_read(fp, &r) >= 0) {
		ma_hit_t *p;
		++tot;
		if (r.qe - r.qs < min_span || r.te - r.ts < min_span || r.ml < min_match) continue;
		if (excl && (sd_get(excl, r.qn) >= 0 || sd_get(excl, r.tn) >= 0)) continue;
		kv_pushp(ma_hit_t, h, &p);
		p->qns = (uint64_t)sd_put(d, r.qn, r.ql)<<32 | r.qs;
		p->qe = r.qe;
		p->tn = sd_put(d, r.tn, r.tl);
		p->ts = r.ts, p->te = r.te, p->rev = r.rev, p->ml = r.ml, p->bl = r.bl;
		if (bi_dir && p->qns>>32 != p->tn) {
			kv_pushp(ma_hit_t, h, &p);
			p->qns = (uint64_t)sd_put(d, r.tn, r.tl)<<32 | r.ts;
			p->qe = r.te;
			p->tn = sd_put(d, r.qn, r.ql);
			p->ts = r.qs, p->te = r.qe, p->rev = r.rev, p->ml = r.ml, p->bl = r.bl;
		}
	}
	paf_close(fp);
	for (i = 0; i < d->n_seq; ++i)
		tot_len += d->seq[i].len;
	if (ma_verbose >= 3) fprintf(stderr, "[M::%s::%s] read %ld hits; stored %ld hits and %d sequences (%ld bp)\n", __func__, sys_timestamp(), tot, h.n, d->n_seq, tot_len);
	ma_hit_sort(h.n, h.a);
	*n = h.n;
	return h.a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x10c0
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x8(%rbp), %rdi
callq 0x22e0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x649c
movq 0xcb82(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rcx
leaq 0x8e5c(%rip), %rsi      # 0xf2e0
leaq 0x8eb0(%rip), %rdx      # 0xf33b
movb $0x0, %al
callq 0x1110
movl $0x1, %edi
callq 0x11f0
jmp 0x649e
movq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x2720
cmpl $0x0, %eax
jl 0x681e
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movl -0x48(%rbp), %eax
subl -0x4c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jb 0x64e9
movl -0x3c(%rbp), %eax
subl -0x40(%rbp), %eax
cmpl -0xc(%rbp), %eax
jb 0x64e9
movl -0x38(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl -0x10(%rbp), %eax
jge 0x64eb
jmp 0x649e
cmpq $0x0, 0x10(%rbp)
je 0x6518
movq 0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x1a60
cmpl $0x0, %eax
jge 0x6516
movq 0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1a60
cmpl $0x0, %eax
jl 0x6518
jmp 0x649e
jmp 0x651a
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jne 0x6569
cmpq $0x0, -0x70(%rbp)
je 0x653b
movq -0x70(%rbp), %rax
shlq %rax
movq %rax, -0xa0(%rbp)
jmp 0x6549
movl $0x2, %eax
movq %rax, -0xa0(%rbp)
jmp 0x6549
movq -0xa0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
shlq $0x5, %rsi
callq 0x1170
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x78(%rbp)
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x50(%rbp), %edx
callq 0x15c0
movslq %eax, %rcx
shlq $0x20, %rcx
movl -0x4c(%rbp), %eax
orq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, (%rax)
movl -0x48(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x15c0
movl %eax, %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x40(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x3c(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x38(%rbp), %ecx
shrl $0x1f, %ecx
movq -0x98(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x38(%rbp), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x98(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
andq $-0x80000000, %rcx      # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x34(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movabsq $-0x7fffffff00000001, %rsi # imm = 0x80000000FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
cmpl $0x0, -0x24(%rbp)
je 0x6819
movq -0x98(%rbp), %rax
movq (%rax), %rax
shrq $0x20, %rax
movq -0x98(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
je 0x6819
jmp 0x66b0
movq -0x78(%rbp), %rax
cmpq -0x70(%rbp), %rax
jne 0x66ff
cmpq $0x0, -0x70(%rbp)
je 0x66d1
movq -0x70(%rbp), %rax
shlq %rax
movq %rax, -0xa8(%rbp)
jmp 0x66df
movl $0x2, %eax
movq %rax, -0xa8(%rbp)
jmp 0x66df
movq -0xa8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
shlq $0x5, %rsi
callq 0x1170
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x78(%rbp)
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl -0x44(%rbp), %edx
callq 0x15c0
movslq %eax, %rcx
shlq $0x20, %rcx
movl -0x40(%rbp), %eax
orq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x50(%rbp), %edx
callq 0x15c0
movl %eax, %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x4c(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x48(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x38(%rbp), %ecx
shrl $0x1f, %ecx
movq -0x98(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x38(%rbp), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq -0x98(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
andq $-0x80000000, %rcx      # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x34(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, %ecx
movl %ecx, %edx
movq 0x18(%rax), %rcx
andq $0x7fffffff, %rdx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movabsq $-0x7fffffff00000001, %rsi # imm = 0x80000000FFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x18(%rax)
jmp 0x649e
movq -0x30(%rbp), %rdi
callq 0x2400
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jae 0x6870
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x80(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addq -0x90(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x682f
leaq 0xc8b9(%rip), %rax      # 0x13130
cmpl $0x3, (%rax)
jl 0x68d5
movq 0xc775(%rip), %rax      # 0x12ff8
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movb $0x0, %al
callq 0x1430
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movq -0x88(%rbp), %r8
movq -0x78(%rbp), %r9
movq -0x18(%rbp), %rax
movl (%rax), %r10d
movq -0x90(%rbp), %rax
leaq 0x8a89(%rip), %rsi      # 0xf347
leaq 0x8a76(%rip), %rdx      # 0xf33b
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x1110
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x6030
movq -0x78(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)