// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/align.c
// Function: process
static void *process(void *shared, int step, void *_data) {
	ktp_aux_t *aux = (ktp_aux_t*)shared;
	ktp_data_t *data = (ktp_data_t*)_data;
	const mem_opt_t *opt = aux->opt;
	int i;

	if (step == 0) {
		ktp_data_t *ret;
		int64_t size = 0;
		ret = calloc(1, sizeof(ktp_data_t));
		ret->seqs = bseq_read(aux->actual_chunk_size, &ret->n_seqs, aux->ks, aux->ks2);
		if (ret->seqs == 0) {
			free(ret);
			return 0;
		}
		if (!aux->copy_comment)
			for (i = 0; i < ret->n_seqs; ++i) {
				free(ret->seqs[i].comment);
				ret->seqs[i].comment = 0;
			}
		for (i = 0; i < ret->n_seqs; ++i) size += ret->seqs[i].l_seq;

		logMessage(__func__, LOG_LEVEL_MESSAGE, "Read %d protein sequences (%ld AA)...\n", ret->n_seqs, (long)size);

		return ret;
	} else if (step == 1) {
		const bwaidx_t *idx = aux->idx;
		if (opt->flag & MEM_F_SMARTPE) {
			bseq1_t *sep[2];
			int n_sep[2];
			mem_opt_t tmp_opt = *opt;
			bseq_classify(data->n_seqs, data->seqs, n_sep, sep);

			logMessage(__func__, LOG_LEVEL_MESSAGE, "%d single-end sequences; %d paired-end sequences\n",  n_sep[0], n_sep[1]);

			if (n_sep[0]) {
				tmp_opt.flag &= ~MEM_F_PE;
				mem_process_seqs(&tmp_opt, idx->bwt, idx->bns, idx->pac, aux->n_processed, n_sep[0], sep[0], 0);
				for (i = 0; i < n_sep[0]; ++i)
					data->seqs[sep[0][i].id].sam = sep[0][i].sam;
			}
			if (n_sep[1]) {
				tmp_opt.flag |= MEM_F_PE;
				mem_process_seqs(&tmp_opt, idx->bwt, idx->bns, idx->pac, aux->n_processed + n_sep[0], n_sep[1], sep[1], aux->pes0);
				for (i = 0; i < n_sep[1]; ++i)
					data->seqs[sep[1][i].id].sam = sep[1][i].sam;
			}
			free(sep[0]); free(sep[1]);
		} else mem_process_seqs(opt, idx->bwt, idx->bns, idx->pac, aux->n_processed, data->n_seqs, data->seqs, aux->pes0);
		aux->n_processed += data->n_seqs;

		return data;
	} else if (step == 2) {
		for (i = 0; i < data->n_seqs; ++i) {
			if (data->seqs[i].sam) err_fputs(data->seqs[i].sam, opt->outputStream);
			free(data->seqs[i].name); free(data->seqs[i].comment);
			free(data->seqs[i].seq); free(data->seqs[i].qual); free(data->seqs[i].sam);
		}
		free(data->seqs); free(data);

		return 0;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x9e88
movq $0x0, -0x50(%rbp)
movl $0x1, %edi
movl $0x18, %esi
leaq 0x2dac1(%rip), %rdx     # 0x37816
movl $0x1b, %ecx
leaq 0x2ee57(%rip), %r8      # 0x38bb8
callq 0x31bf0
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movl 0x2c(%rax), %edi
movq -0x48(%rbp), %rsi
addq $0x8, %rsi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
callq 0x187d0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x9db9
movq -0x48(%rbp), %rdi
callq 0x3380
movq $0x0, -0x8(%rbp)
jmp 0xa212
movq -0x28(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x9e1a
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x9e18
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x3380
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x9dca
jmp 0x9e1a
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x9e56
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x9e21
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x50(%rbp), %r8
leaq 0x2ed50(%rip), %rdi     # 0x38bb8
movl $0x3, %esi
leaq 0x2ed4c(%rip), %rdx     # 0x38bc0
movb $0x0, %al
callq 0x12510
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa212
cmpl $0x1, -0x14(%rbp)
jne 0xa0ed
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movl 0x48(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xa083
movq -0x38(%rbp), %rsi
leaq -0x320(%rbp), %rdi
movl $0x2a8, %edx            # imm = 0x2A8
callq 0x3250
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x78(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x18b70
movl -0x78(%rbp), %ecx
movl -0x74(%rbp), %r8d
leaq 0x2ecc6(%rip), %rdi     # 0x38bb8
movl $0x3, %esi
leaq 0x2ece9(%rip), %rdx     # 0x38be7
movb $0x0, %al
callq 0x12510
cmpl $0x0, -0x78(%rbp)
je 0x9fb6
movl -0x2d8(%rbp), %eax
andl $-0x3, %eax
movl %eax, -0x2d8(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %r8
movl -0x78(%rbp), %r9d
movq -0x70(%rbp), %rax
leaq -0x320(%rbp), %rdi
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x2c280
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x78(%rbp), %eax
jge 0x9fb4
movq -0x70(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rcx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x70(%rbp), %rdx
movslq -0x3c(%rbp), %rsi
imulq $0x30, %rsi, %rsi
addq %rsi, %rdx
movslq 0x4(%rdx), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x28(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x9f68
jmp 0x9fb6
cmpl $0x0, -0x74(%rbp)
je 0xa06f
movl -0x2d8(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x2d8(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %r8
movslq -0x78(%rbp), %rax
addq %rax, %r8
movl -0x74(%rbp), %r9d
movq -0x68(%rbp), %r10
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
leaq -0x320(%rbp), %rdi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2c280
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0xa06d
movq -0x68(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rcx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x68(%rbp), %rdx
movslq -0x3c(%rbp), %rsi
imulq $0x30, %rsi, %rsi
addq %rsi, %rdx
movslq 0x4(%rdx), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x28(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa021
jmp 0xa06f
movq -0x70(%rbp), %rdi
callq 0x3380
movq -0x68(%rbp), %rdi
callq 0x3380
jmp 0xa0cc
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %r8
movq -0x30(%rbp), %rax
movl 0x8(%rax), %r9d
movq -0x30(%rbp), %rax
movq 0x10(%rax), %r10
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2c280
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa212
cmpl $0x2, -0x14(%rbp)
jne 0xa206
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xa1e6
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x28(%rax)
je 0xa14c
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x13040
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x3380
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x3380
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rdi
callq 0x3380
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
callq 0x3380
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rdi
callq 0x3380
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa0fe
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x3380
movq -0x30(%rbp), %rdi
callq 0x3380
movq $0x0, -0x8(%rbp)
jmp 0xa212
jmp 0xa208
jmp 0xa20a
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
nop