// File: /workspace/github_c_makefile_star2_O1/aokad[P]sequeeze/seqtk.c
// Function: stk_gc
int stk_gc(int argc, char *argv[])
{
	int c, is_at = 0, min_l = 20;
	double frac = 0.6f, xdropoff = 10.0f, q;
	gzFile fp;
	kseq_t *seq;

	while ((c = getopt(argc, argv, "wx:f:l:")) >= 0) {
		if (c == 'x') xdropoff = atof(optarg);
		else if (c == 'w') is_at = 1;
		else if (c == 'f') frac = atof(optarg);
		else if (c == 'l') min_l = atoi(optarg);
	}
	if (optind + 1 > argc) {
		fprintf(stderr, "Usage: seqtk gc [options] <in.fa>\n");
		fprintf(stderr, "Options:\n");
		fprintf(stderr, "  -w         identify high-AT regions\n");
		fprintf(stderr, "  -f FLOAT   min GC fraction (or AT fraction for -w) [%.2f]\n", frac);
		fprintf(stderr, "  -l INT     min region length to output [%d]\n", min_l);
		fprintf(stderr, "  -x FLOAT   X-dropoff [%.1f]\n", xdropoff);
		return 1;
	}
	q = (1.0f - frac) / frac;

	fp = strcmp(argv[optind], "-")? gzopen(argv[optind], "r") : gzdopen(fileno(stdin), "r");
	if (fp == 0) {
		fprintf(stderr, "[E::%s] failed to open the input file/stream.\n", __func__);
		return 1;
	}
	seq = kseq_init(fp);
	while (kseq_read(seq) >= 0) {
		int i, start = 0, max_i = 0, n_hits = 0, start_hits = 0, max_hits = 0;
		double sc = 0., max = 0.;
		for (i = 0; i < seq->seq.l; ++i) {
			int hit;
			c = seq_nt16_table[(int)seq->seq.s[i]];
			if (is_at) hit = (c == 1 || c == 8 || c == 9);
			else hit = (c == 2 || c == 4 || c == 6);
			n_hits += hit;
			if (hit) {
				if (sc == 0) start = i, start_hits = n_hits;
				sc += q;
				if (sc > max) max = sc, max_i = i, max_hits = n_hits;
			} else if (sc > 0) {
				sc += -1.0f;
				if (sc < 0 || max - sc > xdropoff) {
					if (max_i + 1 - start >= min_l)
						printf("%s\t%d\t%d\t%d\n", seq->name.s, start, max_i + 1, max_hits - start_hits + 1);
					sc = max = 0;
					i = max_i;
				}
			}
		}
		if (max > 0. && max_i + 1 - start >= min_l)
			printf("%s\t%d\t%d\t%d\n", seq->name.s, start, max_i + 1, max_hits - start_hits + 1);
	}
	kseq_destroy(seq);
	gzclose(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %ebp
leaq 0x4670(%rip), %rdx      # 0xc160
callq 0x2240
testl %eax, %eax
js 0x7b99
movl $0x14, 0xc(%rsp)
movsd 0x357b(%rip), %xmm0     # 0xb088
movsd %xmm0, 0x10(%rsp)
movsd 0x353d(%rip), %xmm0     # 0xb058
movsd %xmm0, 0x18(%rsp)
xorl %ebx, %ebx
movq 0x84ae(%rip), %r12      # 0xffd8
leaq 0x462f(%rip), %r15      # 0xc160
cmpl $0x76, %eax
jg 0x7b4f
cmpl $0x66, %eax
je 0x7b6a
cmpl $0x6c, %eax
jne 0x7b80
movq (%r12), %rdi
callq 0x2250
movl %eax, 0xc(%rsp)
jmp 0x7b80
cmpl $0x77, %eax
je 0x7b7b
cmpl $0x78, %eax
jne 0x7b80
movq (%r12), %rdi
callq 0x20a0
movsd %xmm0, 0x18(%rsp)
jmp 0x7b80
movq (%r12), %rdi
callq 0x20a0
movsd %xmm0, 0x10(%rsp)
jmp 0x7b80
movl $0x1, %ebx
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2240
testl %eax, %eax
jns 0x7b31
testl %ebx, %ebx
sete %r12b
jmp 0x7bc0
movb $0x1, %r12b
movsd 0x34b4(%rip), %xmm0     # 0xb058
movsd %xmm0, 0x18(%rsp)
movsd 0x34d6(%rip), %xmm0     # 0xb088
movsd %xmm0, 0x10(%rsp)
movl $0x14, 0xc(%rsp)
movq 0x8409(%rip), %rax      # 0xffd0
movslq (%rax), %rax
cmpl %ebp, %eax
jge 0x7e34
movq (%r14,%rax,8), %r14
leaq 0x47d1(%rip), %rsi      # 0xc3ae
movq %r14, %rdi
callq 0x2170
testl %eax, %eax
je 0x7bfa
leaq 0x35a8(%rip), %rsi      # 0xb198
movq %r14, %rdi
callq 0x2220
jmp 0x7c17
movq 0x83c7(%rip), %rax      # 0xffc8
movq (%rax), %rdi
callq 0x21b0
leaq 0x3588(%rip), %rsi      # 0xb198
movl %eax, %edi
callq 0x20b0
testq %rax, %rax
je 0x7e4b
movq %rax, 0x20(%rsp)
movq %rax, %rdi
callq 0x3e57
movq %rax, %r15
movq %rax, %rdi
callq 0x3ea1
testl %eax, %eax
js 0x7e11
movsd 0x3420(%rip), %xmm2     # 0xb068
movsd 0x10(%rsp), %xmm0
subsd %xmm0, %xmm2
divsd %xmm0, %xmm2
leaq 0x8513(%rip), %rdi      # 0x10170
xorpd %xmm3, %xmm3
movsd 0x3427(%rip), %xmm4     # 0xb090
movsd %xmm2, 0x10(%rsp)
movb %r12b, 0xb(%rsp)
cmpq $0x0, 0x30(%r15)
je 0x7dac
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
xorl %edx, %edx
xorpd %xmm5, %xmm5
xorl %r9d, %r9d
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %eax, %eax
movq 0x40(%r15), %rsi
movsbq (%rsi,%rcx), %rcx
movb (%rcx,%rdi), %cl
testb %r12b, %r12b
je 0x7cb8
cmpb $0x7, %cl
jae 0x7cc6
movb $0x54, %sil
shrb %cl, %sil
jmp 0x7cc8
cmpb $0xa, %cl
jae 0x7cc6
movl $0x302, %esi            # imm = 0x302
shrl %cl, %esi
jmp 0x7cc8
xorl %esi, %esi
movzbl %sil, %ecx
movl %ecx, %esi
andl $0x1, %esi
addl %esi, %r14d
testb $0x1, %cl
je 0x7d08
ucomisd %xmm3, %xmm5
movl %eax, %ecx
cmovnel %ebp, %ecx
cmovnpl %ecx, %ebp
movl %r14d, %ecx
cmovnel %ebx, %ecx
cmovnpl %ecx, %ebx
addsd %xmm2, %xmm5
ucomisd %xmm0, %xmm5
jbe 0x7d84
movl %eax, %r13d
movl %r14d, %r9d
movapd %xmm5, %xmm0
jmp 0x7d84
ucomisd %xmm3, %xmm5
jbe 0x7d84
addsd %xmm4, %xmm5
ucomisd %xmm5, %xmm3
ja 0x7d28
movapd %xmm0, %xmm1
subsd %xmm5, %xmm1
ucomisd 0x18(%rsp), %xmm1
jbe 0x7d84
leal 0x1(%r13), %ecx
movl %ecx, %eax
subl %ebp, %eax
xorpd %xmm5, %xmm5
cmpl 0xc(%rsp), %eax
jl 0x7d7d
movq 0x10(%r15), %rsi
leal (%rdx,%r9), %r8d
incl %r8d
leaq 0x4502(%rip), %rdi      # 0xc24e
movl %ebp, %edx
xorl %eax, %eax
movq %r9, %r12
callq 0x20f0
xorpd %xmm5, %xmm5
movq %r12, %r9
movb 0xb(%rsp), %r12b
movsd 0x3324(%rip), %xmm4     # 0xb090
xorpd %xmm3, %xmm3
leaq 0x83f9(%rip), %rdi      # 0x10170
movsd 0x10(%rsp), %xmm2
movl %r13d, %eax
xorpd %xmm0, %xmm0
incl %eax
movl %ebx, %edx
negl %edx
movslq %eax, %rcx
cmpq %rcx, 0x30(%r15)
ja 0x7c9a
ucomisd %xmm3, %xmm0
setbe %al
incl %r13d
movl $0x1, %r8d
subl %ebx, %r8d
jmp 0x7dbf
movb $0x1, %al
xorl %ebp, %ebp
movl $0x1, %r13d
xorl %r9d, %r9d
movl $0x1, %r8d
testb %al, %al
jne 0x7de8
movl %r13d, %eax
subl %ebp, %eax
cmpl 0xc(%rsp), %eax
jl 0x7de8
movq 0x10(%r15), %rsi
addl %r9d, %r8d
leaq 0x4472(%rip), %rdi      # 0xc24e
movl %ebp, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x20f0
movq %r15, %rdi
callq 0x3ea1
testl %eax, %eax
movsd 0x10(%rsp), %xmm2
leaq 0x8371(%rip), %rdi      # 0x10170
xorpd %xmm3, %xmm3
movsd 0x3285(%rip), %xmm4     # 0xb090
jns 0x7c74
movq %r15, %rdi
callq 0x4229
movq 0x20(%rsp), %rdi
callq 0x2040
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x10(%rsp), %xmm0
movl 0xc(%rsp), %edi
movsd 0x18(%rsp), %xmm1
callq 0x2b6c
jmp 0x7e50
callq 0x2c15
movl $0x1, %eax
jmp 0x7e25