// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_process_seqs
void mem_process_seqs(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bns, const uint8_t *pac, int64_t n_processed, int n, bseq1_t *seqs, const mem_pestat_t *pes0)
{
	extern void kt_for(int n_threads, void (*func)(void*,int,int), void *data, int n);
	worker_t w;
	mem_pestat_t pes[VALUE_DOMAIN];
	double ctime, rtime;
	int i;

	ctime = cputime(); rtime = realtime();
	global_bns = bns;
	w.regs = malloc(n * sizeof(mem_alnreg_v));
	w.opt = opt; w.bwt = bwt; w.bns = bns; w.pac = pac;
	w.seqs = seqs; w.n_processed = n_processed;
	w.pes = &pes[0];
	w.aux = malloc(opt->n_threads * sizeof(smem_aux_t));
	for (i = 0; i < opt->n_threads; ++i)
		w.aux[i] = smem_aux_init();
	kt_for(opt->n_threads, worker1, &w, (opt->flag&MEM_F_PE)? n>>1 : n); // find mapping positions
	for (i = 0; i < opt->n_threads; ++i)
		smem_aux_destroy(w.aux[i]);
	free(w.aux);
	if (opt->flag&MEM_F_PE) { // infer insert sizes if not provided
		if (pes0) memcpy(pes, pes0, VALUE_DOMAIN * sizeof(mem_pestat_t)); // if pes0 != NULL, set the insert-size distribution as pes0
		else mem_pestat(opt, bns->l_pac, n, w.regs, pes); // otherwise, infer the insert size distribution from data
	}

	// Filter competing alignments from multi-frame encoding during ORF detection process
    filterCompetingAln(&w, n, opt->proteinFlag & ALIGN_FLAG_MANUAL_PRO);

	kt_for(opt->n_threads, worker2, &w, (opt->flag&MEM_F_PE)? n>>1 : n);

	// Prepare Uniprot data (fully if requested)
	addUniprotList(&w, n, opt->outputStream != stdout);

	logMessage(__func__, LOG_LEVEL_MESSAGE, "Processed %d protein sequences in %.3f CPU sec, %.3f real sec\n", n, cputime() - ctime, realtime() - rtime);

	for (i = 0 ; i < n ; i++) {
		free(w.regs[i].a);
	}

	free(w.regs);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movb $0x0, %al
callq 0x13260
movsd %xmm0, -0x488(%rbp)
movb $0x0, %al
callq 0x132c0
movsd %xmm0, -0x490(%rbp)
movq -0x18(%rbp), %rax
movq %rax, 0x14c9c(%rip)     # 0x40f70
movslq -0x2c(%rbp), %rdi
shlq $0x5, %rdi
leaq 0xe3d5(%rip), %rsi      # 0x3a6b8
movl $0x50b, %edx            # imm = 0x50B
leaq 0xec3d(%rip), %rcx      # 0x3af2c
callq 0x31ca0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x480(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movslq 0x94(%rax), %rdi
shlq $0x6, %rdi
leaq 0xe36f(%rip), %rsi      # 0x3a6b8
movl $0x50f, %edx            # imm = 0x50F
leaq 0xebd7(%rip), %rcx      # 0x3af2c
callq 0x31ca0
movq %rax, -0x50(%rbp)
movl $0x0, -0x494(%rbp)
movl -0x494(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x94(%rcx), %eax
jge 0x2c3a2
callq 0x2cb30
movq %rax, %rdx
movq -0x50(%rbp), %rax
movslq -0x494(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x494(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x494(%rbp)
jmp 0x2c368
movq -0x8(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x498(%rbp)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2c3ce
movl -0x2c(%rbp), %eax
sarl %eax
movl %eax, -0x49c(%rbp)
jmp 0x2c3d7
movl -0x2c(%rbp), %eax
movl %eax, -0x49c(%rbp)
movl -0x498(%rbp), %edi
movl -0x49c(%rbp), %ecx
leaq 0x1e6(%rip), %rsi       # 0x2c5d0
leaq -0x78(%rbp), %rdx
callq 0x13300
movl $0x0, -0x494(%rbp)
movl -0x494(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x94(%rcx), %eax
jge 0x2c434
movq -0x50(%rbp), %rax
movslq -0x494(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1e290
movl -0x494(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x494(%rbp)
jmp 0x2c3fd
movq -0x50(%rbp), %rdi
callq 0x3380
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2c48a
cmpq $0x0, 0x18(%rbp)
je 0x2c46a
leaq -0x480(%rbp), %rdi
movq 0x18(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x3250
jmp 0x2c488
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl -0x2c(%rbp), %edx
movq -0x40(%rbp), %rcx
leaq -0x480(%rbp), %r8
callq 0x2d1a0
jmp 0x2c48a
movl -0x2c(%rbp), %esi
movq -0x8(%rbp), %rax
movl 0x4c(%rax), %edx
andl $0x10, %edx
leaq -0x78(%rbp), %rdi
callq 0x1b0b0
movq -0x8(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x4a0(%rbp)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x2c4cc
movl -0x2c(%rbp), %eax
sarl %eax
movl %eax, -0x4a4(%rbp)
jmp 0x2c4d5
movl -0x2c(%rbp), %eax
movl %eax, -0x4a4(%rbp)
movl -0x4a0(%rbp), %edi
movl -0x4a4(%rbp), %ecx
leaq 0x3f8(%rip), %rsi       # 0x2c8e0
leaq -0x78(%rbp), %rdx
callq 0x13300
movl -0x2c(%rbp), %esi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x13aad(%rip), %rcx     # 0x3ffb0
cmpq (%rcx), %rax
setne %al
andb $0x1, %al
movzbl %al, %edx
leaq -0x78(%rbp), %rdi
callq 0xd7e0
movl -0x2c(%rbp), %eax
movl %eax, -0x4b4(%rbp)
movb $0x0, %al
callq 0x13260
subsd -0x488(%rbp), %xmm0
movsd %xmm0, -0x4b0(%rbp)
movb $0x0, %al
callq 0x132c0
movl -0x4b4(%rbp), %ecx
movaps %xmm0, %xmm1
movsd -0x4b0(%rbp), %xmm0
subsd -0x490(%rbp), %xmm1
leaq 0xe9ce(%rip), %rdi      # 0x3af2c
movl $0x3, %esi
leaq 0xe9d3(%rip), %rdx      # 0x3af3d
movb $0x2, %al
callq 0x12510
movl $0x0, -0x494(%rbp)
movl -0x494(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2c5b2
movq -0x40(%rbp), %rax
movslq -0x494(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x3380
movl -0x494(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x494(%rbp)
jmp 0x2c57b
movq -0x40(%rbp), %rdi
callq 0x3380
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
nopw %cs:(%rax,%rax)