// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x14, -0x1c(%rbp)
movsd 0x4758(%rip), %xmm0     # 0xd040
movsd %xmm0, -0x28(%rbp)
movsd 0x471b(%rip), %xmm0     # 0xd010
movsd %xmm0, -0x30(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x5940(%rip), %rdx      # 0xe248
callq 0x2240
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jl 0x897f
cmpl $0x78, -0x14(%rbp)
jne 0x8931
movq 0x86b6(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
callq 0x20a0
movsd %xmm0, -0x30(%rbp)
jmp 0x897a
cmpl $0x77, -0x14(%rbp)
jne 0x8940
movl $0x1, -0x18(%rbp)
jmp 0x8978
cmpl $0x66, -0x14(%rbp)
jne 0x895c
movq 0x868b(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
callq 0x20a0
movsd %xmm0, -0x28(%rbp)
jmp 0x8976
cmpl $0x6c, -0x14(%rbp)
jne 0x8974
movq 0x866f(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
callq 0x2250
movl %eax, -0x1c(%rbp)
jmp 0x8976
jmp 0x8978
jmp 0x897a
jmp 0x88fa
movq 0x864a(%rip), %rax      # 0x10fd0
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jle 0x8a3d
movq 0x865d(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x58ab(%rip), %rsi      # 0xe250
movb $0x0, %al
callq 0x2190
movq 0x8645(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x58b6(%rip), %rsi      # 0xe273
movb $0x0, %al
callq 0x2190
movq 0x862d(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x58a8(%rip), %rsi      # 0xe27d
movb $0x0, %al
callq 0x2190
movq 0x8615(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movsd -0x28(%rbp), %xmm0
leaq 0x58b2(%rip), %rsi      # 0xe2a4
movb $0x1, %al
callq 0x2190
movq 0x85f8(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
leaq 0x58d4(%rip), %rsi      # 0xe2e1
movb $0x0, %al
callq 0x2190
movq 0x85dd(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movsd -0x30(%rbp), %xmm0
leaq 0x58e6(%rip), %rsi      # 0xe310
movb $0x1, %al
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x8d5c
movsd 0x45db(%rip), %xmm0     # 0xd020
subsd -0x28(%rbp), %xmm0
divsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8571(%rip), %rcx      # 0x10fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x5a29(%rip), %rsi      # 0xe496
callq 0x2170
cmpl $0x0, %eax
je 0x8a9b
movq -0x10(%rbp), %rax
movq 0x854e(%rip), %rcx      # 0x10fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x47f0(%rip), %rsi      # 0xd280
callq 0x2220
movq %rax, -0x80(%rbp)
jmp 0x8abc
movq 0x8526(%rip), %rax      # 0x10fc8
movq (%rax), %rdi
callq 0x21b0
movl %eax, %edi
leaq 0x47cd(%rip), %rsi      # 0xd280
callq 0x20b0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x8af6
movq 0x8526(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x499d(%rip), %rsi      # 0xd479
leaq 0x584c(%rip), %rdx      # 0xe32f
movb $0x0, %al
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x8d5c
movq -0x40(%rbp), %rdi
callq 0x38f0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3930
cmpl $0x0, %eax
jl 0x8d43
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x8cf7
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movslq %eax, %rcx
leaq 0x85e5(%rip), %rax      # 0x11160
movzbl (%rax,%rcx), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x8bc1
movb $0x1, %al
cmpl $0x1, -0x14(%rbp)
movb %al, -0x81(%rbp)
je 0x8bb1
movb $0x1, %al
cmpl $0x8, -0x14(%rbp)
movb %al, -0x81(%rbp)
je 0x8bb1
cmpl $0x9, -0x14(%rbp)
sete %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x74(%rbp)
jmp 0x8bf8
movb $0x1, %al
cmpl $0x2, -0x14(%rbp)
movb %al, -0x82(%rbp)
je 0x8bea
movb $0x1, %al
cmpl $0x4, -0x14(%rbp)
movb %al, -0x82(%rbp)
je 0x8bea
cmpl $0x6, -0x14(%rbp)
sete %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x74(%rbp)
je 0x8c59
movsd -0x68(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8c23
jp 0x8c23
movl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x5c(%rbp)
movsd -0x38(%rbp), %xmm0
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
ucomisd -0x70(%rbp), %xmm0
jbe 0x8c54
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x8ce7
movsd -0x68(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8ce5
movsd 0x43d9(%rip), %xmm0     # 0xd048
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x68(%rbp), %xmm0
ja 0x8c94
movsd -0x70(%rbp), %xmm0
subsd -0x68(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x8ce3
movl -0x54(%rbp), %eax
addl $0x1, %eax
subl -0x50(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x8ccd
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x50(%rbp), %edx
movl -0x54(%rbp), %ecx
addl $0x1, %ecx
movl -0x60(%rbp), %r8d
subl -0x5c(%rbp), %r8d
addl $0x1, %r8d
leaq 0x5670(%rip), %rdi      # 0xe336
movb $0x0, %al
callq 0x20f0
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x8ce5
jmp 0x8ce7
jmp 0x8ce9
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x8b4f
movsd -0x70(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8d3e
movl -0x54(%rbp), %eax
addl $0x1, %eax
subl -0x50(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x8d3e
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x50(%rbp), %edx
movl -0x54(%rbp), %ecx
addl $0x1, %ecx
movl -0x60(%rbp), %r8d
subl -0x5c(%rbp), %r8d
addl $0x1, %r8d
leaq 0x55ff(%rip), %rdi      # 0xe336
movb $0x0, %al
callq 0x20f0
jmp 0x8b03
movq -0x48(%rbp), %rdi
callq 0x3d40
movq -0x40(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)