// File: /workspace/github_c_makefile_star2_O0/DReichLab[P]adna/trim.c
// Function: ad_bc_read
ad_barcode_t *ad_bc_read(const char *fn)
{
	gzFile fp;
	kstream_t *ks;
	kstring_t s = {0,0,0};
	ad_barcode_t *bc = 0;
	int dret, i, len[2];
	kvec_t(cstr_t) x[2];

	fp = gzopen(fn, "r");
	if (fp == 0) return 0;
	ks = ks_init(fp);
	kv_init(x[0]); kv_init(x[1]);
	len[0] = len[1] = 0;
	for (i = 0; i < 2; ++i) {
		int j, j0;
		if (ks_getuntil(ks, KS_SEP_LINE, &s, &dret) < 0) break;
		for (j = j0 = 0; j <= s.l; ++j) {
			if (j == s.l || ispunct(s.s[j])) {
				s.s[j] = 0;
				if (len[i] == 0) len[i] = j - j0;
				else if (len[i] != j - j0) {
					j0 = j + 1;
					continue;
				}
				if (len[i] > 0) kv_push(cstr_t, x[i], strdup(&s.s[j0]));
				j0 = j + 1;
			}
		}
	}
	free(s.s);
	ks_destroy(ks);
	gzclose(fp);

	fprintf(stderr, "[M::%s] read %ld read1 barcodes and %ld read2 barcodes\n", __func__, x[0].n, x[1].n);

	bc = (ad_barcode_t*)calloc(1, sizeof(ad_barcode_t));
	for (i = 0; i < 2; ++i) {
		int j;
		bc->n[i] = x[i].n, bc->len[i] = len[i];
		bc->bc[i] = (lt_seqcloud_t**)calloc(bc->n[i], sizeof(lt_seqcloud_t*));
		for (j = 0; j < x[i].n; ++j)
			bc->bc[i][j] = lt_sc_gen(x[i].a[j]);
		bc->seq[i] = x[i].a;
	}
	return bc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2110
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x41e4(%rip), %rsi      # 0x8076
callq 0x2210
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3eaf
movq $0x0, -0x8(%rbp)
jmp 0x42a8
movq -0x18(%rbp), %rdi
callq 0x42c0
movq %rax, -0x20(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x58(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x2, -0x40(%rbp)
jge 0x413f
movq -0x20(%rbp), %rdi
movl $0x2, %esi
leaq -0x30(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0x4320
cmpl $0x0, %eax
jge 0x3f2b
jmp 0x413f
movl $0x0, -0x88(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x30(%rbp), %eax
ja 0x412f
movl -0x84(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x3f83
callq 0x2290
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x84(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4119
movq -0x28(%rbp), %rax
movslq -0x84(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movslq -0x40(%rbp), %rax
cmpl $0x0, -0x48(%rbp,%rax,4)
jne 0x3fb3
movl -0x84(%rbp), %ecx
subl -0x88(%rbp), %ecx
movslq -0x40(%rbp), %rax
movl %ecx, -0x48(%rbp,%rax,4)
jmp 0x3fe1
movslq -0x40(%rbp), %rax
movl -0x48(%rbp,%rax,4), %eax
movl -0x84(%rbp), %ecx
subl -0x88(%rbp), %ecx
cmpl %ecx, %eax
je 0x3fdf
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x411b
jmp 0x3fe1
movslq -0x40(%rbp), %rax
cmpl $0x0, -0x48(%rbp,%rax,4)
jle 0x410a
jmp 0x3ff2
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x40(%rbp), %rdx
leaq -0x80(%rbp), %rcx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jne 0x40bf
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x4052
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x98(%rbp)
jmp 0x4060
movl $0x2, %eax
movq %rax, -0x98(%rbp)
jmp 0x4060
movq -0x98(%rbp), %rcx
movslq -0x40(%rbp), %rdx
leaq -0x80(%rbp), %rax
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x21e0
movq %rax, %rcx
movslq -0x40(%rbp), %rdx
leaq -0x80(%rbp), %rax
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rdi
movslq -0x88(%rbp), %rax
addq %rax, %rdi
callq 0x2260
movq %rax, %rdx
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rsi
imulq $0x18, %rcx, %rcx
addq %rcx, %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x410a
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x411b
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x3f3f
jmp 0x4131
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x3f01
movq -0x28(%rbp), %rdi
callq 0x2040
movq -0x20(%rbp), %rdi
callq 0x4360
movq -0x18(%rbp), %rdi
callq 0x2030
movq 0x5e97(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x80(%rbp), %rcx
movq -0x68(%rbp), %r8
leaq 0x3f05(%rip), %rsi      # 0x8078
leaq 0x3f36(%rip), %rdx      # 0x80b0
movb $0x0, %al
callq 0x2150
movl $0x1, %edi
movl $0x30, %esi
callq 0x2120
movq %rax, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
cmpl $0x2, -0x40(%rbp)
jge 0x42a0
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movslq -0x40(%rbp), %rax
movl -0x48(%rbp,%rax,4), %edx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl %edx, 0x8(%rax,%rcx,4)
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movslq (%rax,%rcx,4), %rdi
movl $0x8, %esi
callq 0x2120
movq %rax, %rdx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movl $0x0, -0x8c(%rbp)
movslq -0x8c(%rbp), %rax
movslq -0x40(%rbp), %rdx
leaq -0x80(%rbp), %rcx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jae 0x4272
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x8c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2ef0
movq %rax, %rdx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movslq -0x8c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x4208
movslq -0x40(%rbp), %rcx
leaq -0x80(%rbp), %rax
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movq -0x38(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x419b
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)