// File: /workspace/github_c_makefile_star2_O0/aokad[P]sequeeze/seqtk.c
// Function: stk_hety
int stk_hety(int argc, char *argv[])
{
	gzFile fp;
	kseq_t *seq;
	int l, c, win_size = 50000, n_start = 5, win_step, is_lower_mask = 0;
	char *buf;
	uint32_t cnt[3];
	if (argc == 1) {
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage:   seqtk hety [options] <in.fa>\n\n");
		fprintf(stderr, "Options: -w INT   window size [%d]\n", win_size);
		fprintf(stderr, "         -t INT   # start positions in a window [%d]\n", n_start);
		fprintf(stderr, "         -m       treat lowercases as masked\n");
		fprintf(stderr, "\n");
		return 1;
	}
	while ((c = getopt(argc, argv, "w:t:m")) >= 0) {
		switch (c) {
		case 'w': win_size = atoi(optarg); break;
		case 't': n_start = atoi(optarg); break;
		case 'm': is_lower_mask = 1; break;
		}
	}
	fp = (strcmp(argv[optind], "-") == 0)? gzdopen(fileno(stdin), "r") : gzopen(argv[optind], "r");
	if (fp == 0) {
		fprintf(stderr, "[E::%s] failed to open the input file/stream.\n", __func__);
		return 1;
	}
	seq = kseq_init(fp);
	win_step = win_size / n_start;
	buf = calloc(win_size, 1);
	while ((l = kseq_read(seq)) >= 0) {
		int x, i, y, z, next = 0;
		cnt[0] = cnt[1] = cnt[2] = 0;
		for (i = 0; i <= l; ++i) {
			if ((i >= win_size && i % win_step == 0) || i == l) {
				if (i == l && l >= win_size) {
					for (y = l - win_size; y < next; ++y) --cnt[(int)buf[y % win_size]];
				}
				if (cnt[1] + cnt[2] > 0)
					printf("%s\t%d\t%d\t%.2lf\t%d\t%d\n", seq->name.s, next, i,
						   (double)cnt[2] / (cnt[1] + cnt[2]) * win_size, cnt[1] + cnt[2], cnt[2]);
				next = i;
			}
			if (i < l) {
				y = i % win_size;
				c = seq->seq.s[i];
				if (is_lower_mask && islower(c)) c = 'N';
				c = seq_nt16_table[c];
				x = bitcnt_table[c];
				if (i >= win_size) --cnt[(int)buf[y]];
				buf[y] = z = x > 2? 0 : x == 2? 2 : 1;
				++cnt[z];
			}
		}
	}
	free(buf);
	kseq_destroy(seq);
	gzclose(fp);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xc350, -0x2c(%rbp)    # imm = 0xC350
movl $0x5, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x46f3
movq 0xc9a0(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x90d5(%rip), %rsi      # 0xd737
movb $0x0, %al
callq 0x2190
movq 0xc988(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x8f10(%rip), %rsi      # 0xd58a
movb $0x0, %al
callq 0x2190
movq 0xc970(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movl -0x2c(%rbp), %edx
leaq 0x8f1d(%rip), %rsi      # 0xd5b2
movb $0x0, %al
callq 0x2190
movq 0xc955(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
movl -0x30(%rbp), %edx
leaq 0x8f26(%rip), %rsi      # 0xd5d6
movb $0x0, %al
callq 0x2190
movq 0xc93a(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x8f44(%rip), %rsi      # 0xd60c
movb $0x0, %al
callq 0x2190
movq 0xc922(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x9057(%rip), %rsi      # 0xd737
movb $0x0, %al
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x4a54
jmp 0x46f5
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x8f37(%rip), %rdx      # 0xd63a
callq 0x2240
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jl 0x4762
movl -0x28(%rbp), %eax
movl %eax, -0x64(%rbp)
subl $0x6d, %eax
je 0x4759
jmp 0x471d
movl -0x64(%rbp), %eax
subl $0x74, %eax
je 0x4745
jmp 0x4727
movl -0x64(%rbp), %eax
subl $0x77, %eax
jne 0x4760
jmp 0x4731
movq 0xc8a0(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
callq 0x2250
movl %eax, -0x2c(%rbp)
jmp 0x4760
movq 0xc88c(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
callq 0x2250
movl %eax, -0x30(%rbp)
jmp 0x4760
movl $0x1, -0x38(%rbp)
jmp 0x46f5
movq -0x10(%rbp), %rax
movq 0xc863(%rip), %rcx      # 0x10fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x9d1b(%rip), %rsi      # 0xe496
callq 0x2170
cmpl $0x0, %eax
jne 0x47a8
movq 0xc83c(%rip), %rax      # 0x10fc8
movq (%rax), %rdi
callq 0x21b0
movl %eax, %edi
leaq 0x8ae3(%rip), %rsi      # 0xd280
callq 0x20b0
movq %rax, -0x70(%rbp)
jmp 0x47ca
movq -0x10(%rbp), %rax
movq 0xc81d(%rip), %rcx      # 0x10fd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x8abf(%rip), %rsi      # 0xd280
callq 0x2220
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4804
movq 0xc818(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x8c8f(%rip), %rsi      # 0xd479
leaq 0x8e4f(%rip), %rdx      # 0xd640
movb $0x0, %al
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x4a54
movq -0x18(%rbp), %rdi
callq 0x38f0
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
cltd
idivl -0x30(%rbp)
movl %eax, -0x34(%rbp)
movslq -0x2c(%rbp), %rdi
movl $0x1, %esi
callq 0x2160
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3930
movl %eax, -0x24(%rbp)
cmpl $0x0, %eax
jl 0x4a32
movl $0x0, -0x60(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x4a2d
movl -0x54(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jl 0x4885
movl -0x54(%rbp), %eax
cltd
idivl -0x34(%rbp)
cmpl $0x0, %edx
je 0x4891
movl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x4944
movl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x48e6
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jl 0x48e6
movl -0x24(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x48e4
movq -0x40(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x58(%rbp), %eax
cltd
idivl -0x2c(%rbp)
movq -0x78(%rbp), %rax
movslq %edx, %rcx
movsbl (%rax,%rcx), %eax
cltq
movl -0x4c(%rbp,%rax,4), %ecx
addl $-0x1, %ecx
movl %ecx, -0x4c(%rbp,%rax,4)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x48aa
jmp 0x48e6
movl -0x48(%rbp), %eax
addl -0x44(%rbp), %eax
cmpl $0x0, %eax
jbe 0x493e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x60(%rbp), %edx
movl -0x54(%rbp), %ecx
movl -0x48(%rbp), %eax
movl -0x44(%rbp), %edi
movl %edi, %r8d
movl %r8d, %edi
cvtsi2sd %r8, %xmm0
addl %edi, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
mulsd %xmm1, %xmm0
movl -0x48(%rbp), %r8d
addl -0x44(%rbp), %r8d
movl -0x44(%rbp), %r9d
leaq 0x8d12(%rip), %rdi      # 0xd649
movb $0x1, %al
callq 0x20f0
movl -0x54(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4a1d
movl -0x54(%rbp), %eax
cltd
idivl -0x2c(%rbp)
movl %edx, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x54(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x4994
callq 0x2280
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x4994
movl $0x4e, -0x28(%rbp)
movslq -0x28(%rbp), %rcx
leaq 0xc7c1(%rip), %rax      # 0x11160
movzbl (%rax,%rcx), %eax
movl %eax, -0x28(%rbp)
movslq -0x28(%rbp), %rcx
leaq 0xc9df(%rip), %rax      # 0x11390
movl (%rax,%rcx,4), %eax
movl %eax, -0x50(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jl 0x49d8
movq -0x40(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cltq
movl -0x4c(%rbp,%rax,4), %ecx
addl $-0x1, %ecx
movl %ecx, -0x4c(%rbp,%rax,4)
cmpl $0x2, -0x50(%rbp)
jle 0x49e5
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
jmp 0x49fb
movl -0x50(%rbp), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movb %al, %dl
movq -0x40(%rbp), %rax
movslq -0x58(%rbp), %rcx
movb %dl, (%rax,%rcx)
movslq -0x5c(%rbp), %rax
movl -0x4c(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x4c(%rbp,%rax,4)
jmp 0x4a1f
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4865
jmp 0x482d
movq -0x40(%rbp), %rdi
callq 0x2040
movq -0x20(%rbp), %rdi
callq 0x3d40
movq -0x18(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq