// File: /workspace/github_c_makefile_star2_O0/DReichLab[P]adna/trim.c
// Function: main
int main(int argc, char *argv[])
{
	int c;
	lt_global_t g;
	gzFile fp;
	char *p, *pe_prefix = 0, *fn_bc = 0;

	lt_global_init(&g);
	while ((c = getopt(argc, argv, "dt:b:l:o:p:B:T:P")) >= 0) {
		if (c == 't') g.opt.n_threads = atoi(optarg);
		else if (c == 'd') g.opt.tab_out = 1;
		else if (c == 'P') g.opt.retain_pe = 1;
		else if (c == 'l') g.opt.min_seq_len = atoi(optarg);
		else if (c == 'o') g.opt.min_ovlp_len = atoi(optarg);
		else if (c == 'p') pe_prefix = optarg;
		else if (c == 'b') fn_bc = optarg;
		else if (c == 'T') g.opt.trim_len = atoi(optarg);
		else if (c == 'B') {
			g.opt.bc_len[0] = g.opt.bc_len[1] = strtol(optarg, &p, 10);
			if (*p == ',') g.opt.bc_len[1] = strtol(p+1, &p, 10);
		}
	}
	if (argc - optind < 1) {
		fprintf(stderr, "Usage: seqtk mergepe <read1.fq> <read2.fq> | adna-trim [options] -\n");
		fprintf(stderr, "Options:\n");
		fprintf(stderr, "  -b FILE      barcode file (overriding -B) []\n");
		fprintf(stderr, "  -B INT[,INT] barcode length [%d,%d]\n", g.opt.bc_len[0], g.opt.bc_len[1]);
		fprintf(stderr, "  -t INT       number of threads [%d]\n", g.opt.n_threads);
		fprintf(stderr, "  -l INT       min read/fragment length to output [%d]\n", g.opt.min_seq_len);
		fprintf(stderr, "  -o INT       min overlap length [%d]\n", g.opt.min_ovlp_len);
		fprintf(stderr, "  -p STR       output PE reads to STR.R[12].fq.gz (overriding -P) [discard pe]\n");
		fprintf(stderr, "  -T INT       trim INT-bp [%d]\n", g.opt.trim_len);
		fprintf(stderr, "  -P           output paired reads also to stdout [discard pe]\n");
		fprintf(stderr, "  -d           tabular output for debugging\n");
		return 1;
	}

	fp = strcmp(argv[optind], "-")? gzopen(argv[optind], "r") : gzdopen(fileno(stdin), "r");
	g.ks = kseq_init(fp);
	if (fn_bc) g.bc = ad_bc_read(fn_bc), g.opt.bc_len[0] = g.opt.bc_len[1] = 0;
	if (pe_prefix) {
		kstring_t str = {0,0,0};
		for (c = 0; c < 2; ++c) {
			str.l = 0;
			ksprintf(&str, "%s.R%d.fq.gz", pe_prefix, c+1);
			g.fp_pe[c] = gzopen(str.s, "w1");
		}
		g.opt.retain_pe = 0;
	}

	kt_pipeline(2, worker_pipeline, &g, 3);
	for (c = 0; c <= AD_MAX_TYPE; ++c)
		if (g.types[c] > 0)
			fprintf(stderr, "[M::%s] %2d  %ld\n", __func__, c, (long)g.types[c]);

	if (g.fp_pe[0]) gzclose(g.fp_pe[0]);
	if (g.fp_pe[1]) gzclose(g.fp_pe[1]);
	kseq_destroy(g.ks);
	gzclose(fp);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x1d0(%rbp)
movq $0x0, -0x1d8(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x43a0
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x29c2(%rip), %rdx      # 0x80bb
callq 0x2230
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jl 0x585e
cmpl $0x74, -0x14(%rbp)
jne 0x572a
movq 0x48c1(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x2240
movl %eax, -0x1b8(%rbp)
jmp 0x5859
cmpl $0x64, -0x14(%rbp)
jne 0x573f
movl $0x1, -0x18c(%rbp)
jmp 0x5857
cmpl $0x50, -0x14(%rbp)
jne 0x5754
movl $0x1, -0x188(%rbp)
jmp 0x5855
cmpl $0x6c, -0x14(%rbp)
jne 0x5774
movq 0x4877(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x2240
movl %eax, -0x1b0(%rbp)
jmp 0x5853
cmpl $0x6f, -0x14(%rbp)
jne 0x5794
movq 0x4857(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x2240
movl %eax, -0x1a4(%rbp)
jmp 0x5851
cmpl $0x70, -0x14(%rbp)
jne 0x57b0
movq 0x4837(%rip), %rax      # 0x9fd8
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
jmp 0x584f
cmpl $0x62, -0x14(%rbp)
jne 0x57cc
movq 0x481b(%rip), %rax      # 0x9fd8
movq (%rax), %rax
movq %rax, -0x1d8(%rbp)
jmp 0x584d
cmpl $0x54, -0x14(%rbp)
jne 0x57e9
movq 0x47ff(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x2240
movl %eax, -0x190(%rbp)
jmp 0x584b
cmpl $0x42, -0x14(%rbp)
jne 0x5849
movq 0x47e2(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
leaq -0x1c8(%rbp), %rsi
movl $0xa, %edx
callq 0x2160
movl %eax, -0x194(%rbp)
movl %eax, -0x198(%rbp)
movq -0x1c8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x5847
movq -0x1c8(%rbp), %rdi
addq $0x1, %rdi
leaq -0x1c8(%rbp), %rsi
movl $0xa, %edx
callq 0x2160
movl %eax, -0x194(%rbp)
jmp 0x5849
jmp 0x584b
jmp 0x584d
jmp 0x584f
jmp 0x5851
jmp 0x5853
jmp 0x5855
jmp 0x5857
jmp 0x5859
jmp 0x56eb
movl -0x8(%rbp), %eax
movq 0x4768(%rip), %rcx      # 0x9fd0
subl (%rcx), %eax
cmpl $0x1, %eax
jge 0x59ab
movq 0x477e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2848(%rip), %rsi      # 0x80cc
movb $0x0, %al
callq 0x2150
movq 0x4766(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2874(%rip), %rsi      # 0x8110
movb $0x0, %al
callq 0x2150
movq 0x474e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2866(%rip), %rsi      # 0x811a
movb $0x0, %al
callq 0x2150
movq 0x4736(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x198(%rbp), %edx
movl -0x194(%rbp), %ecx
leaq 0x2872(%rip), %rsi      # 0x814a
movb $0x0, %al
callq 0x2150
movq 0x4712(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x1b8(%rbp), %edx
leaq 0x287b(%rip), %rsi      # 0x8171
movb $0x0, %al
callq 0x2150
movq 0x46f4(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x1b0(%rbp), %edx
leaq 0x2884(%rip), %rsi      # 0x8198
movb $0x0, %al
callq 0x2150
movq 0x46d6(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x1a4(%rbp), %edx
leaq 0x289e(%rip), %rsi      # 0x81d0
movb $0x0, %al
callq 0x2150
movq 0x46b8(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x28ae(%rip), %rsi      # 0x81f8
movb $0x0, %al
callq 0x2150
movq 0x46a0(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x190(%rbp), %edx
leaq 0x28e0(%rip), %rsi      # 0x8248
movb $0x0, %al
callq 0x2150
movq 0x4682(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x28e9(%rip), %rsi      # 0x8269
movb $0x0, %al
callq 0x2150
movq 0x466a(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2911(%rip), %rsi      # 0x82a9
movb $0x0, %al
callq 0x2150
movl $0x1, -0x4(%rbp)
jmp 0x5bb8
movq -0x10(%rbp), %rax
movq 0x461a(%rip), %rcx      # 0x9fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x2912(%rip), %rsi      # 0x82d6
callq 0x2130
cmpl $0x0, %eax
je 0x59f5
movq -0x10(%rbp), %rax
movq 0x45f7(%rip), %rcx      # 0x9fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x268f(%rip), %rsi      # 0x8076
callq 0x2210
movq %rax, -0x1f0(%rbp)
jmp 0x5a19
movq 0x45cc(%rip), %rax      # 0x9fc8
movq (%rax), %rdi
callq 0x2180
movl %eax, %edi
leaq 0x2669(%rip), %rsi      # 0x8076
callq 0x20b0
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rdi
callq 0x5bd0
movq %rax, -0x180(%rbp)
cmpq $0x0, -0x1d8(%rbp)
je 0x5a68
movq -0x1d8(%rbp), %rdi
callq 0x3e60
movq %rax, -0x20(%rbp)
movl $0x0, -0x194(%rbp)
movl $0x0, -0x198(%rbp)
cmpq $0x0, -0x1d0(%rbp)
je 0x5af9
leaq -0x1e8(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2110
movl $0x0, -0x14(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x5aef
movl $0x0, -0x1e8(%rbp)
movq -0x1d0(%rbp), %rdx
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
leaq -0x1e8(%rbp), %rdi
leaq 0x281d(%rip), %rsi      # 0x82d8
movb $0x0, %al
callq 0x5c10
movq -0x1e0(%rbp), %rdi
leaq 0x2815(%rip), %rsi      # 0x82e5
callq 0x2210
movq %rax, %rcx
movslq -0x14(%rbp), %rax
movq %rcx, -0x178(%rbp,%rax,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5a90
movl $0x0, -0x188(%rbp)
movl $0x2, %edi
leaq 0x30b(%rip), %rsi       # 0x5e10
leaq -0x1b8(%rbp), %rdx
movl $0x3, %ecx
callq 0x25a0
movl $0x0, -0x14(%rbp)
cmpl $0x28, -0x14(%rbp)
jg 0x5b6d
movslq -0x14(%rbp), %rax
cmpq $0x0, -0x168(%rbp,%rax,8)
jbe 0x5b60
movq 0x44bf(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x14(%rbp), %ecx
movslq -0x14(%rbp), %rax
movq -0x168(%rbp,%rax,8), %r8
leaq 0x2796(%rip), %rsi      # 0x82e8
leaq 0x27a1(%rip), %rdx      # 0x82fa
movb $0x0, %al
callq 0x2150
jmp 0x5b62
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5b1d
cmpq $0x0, -0x178(%rbp)
je 0x5b83
movq -0x178(%rbp), %rdi
callq 0x2030
cmpq $0x0, -0x170(%rbp)
je 0x5b99
movq -0x170(%rbp), %rdi
callq 0x2030
movq -0x180(%rbp), %rdi
callq 0x64a0
movq -0x1c0(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
nopw %cs:(%rax,%rax)