// File: /workspace/github_c_makefile_star2_O3/aokad[P]sequeeze/seqtk.c
// Function: stk_cutN
int stk_cutN(int argc, char *argv[])
{
	int c, l, gap_only = 0;
	gzFile fp;
	kseq_t *ks;
	while ((c = getopt(argc, argv, "n:p:g")) >= 0) {
		switch (c) {
		case 'n': cutN_min_N_tract = atoi(optarg); break;
		case 'p': cutN_nonN_penalty = atoi(optarg); break;
		case 'g': gap_only = 1; break;
		default: return 1;
		}
	}
	if (argc == optind) {
		fprintf(stderr, "\n");
		fprintf(stderr, "Usage:   seqtk cutN [options] <in.fa>\n\n");
		fprintf(stderr, "Options: -n INT    min size of N tract [%d]\n", cutN_min_N_tract);
		fprintf(stderr, "         -p INT    penalty for a non-N [%d]\n", cutN_nonN_penalty);
		fprintf(stderr, "         -g        print gaps only, no sequence\n\n");
		return 1;
	}
	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;
	}
	ks = kseq_init(fp);
	while ((l = kseq_read(ks)) >= 0) {
		int k = 0, begin = 0, end = 0;
		while (find_next_cut(ks, k, &begin, &end) >= 0) {
			if (begin != 0) {
				if (gap_only) printf("%s\t%d\t%d\n", ks->name.s, begin, end);
				else print_seq(stdout, ks, k, begin);
			}
			k = end;
		}
		if (!gap_only) print_seq(stdout, ks, k, l);
	}
	kseq_destroy(ks);
	gzclose(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x5804(%rip), %rdx      # 0xba12
callq 0x2240
testl %eax, %eax
js 0x6279
xorl %r15d, %r15d
leaq 0x57f1(%rip), %r14      # 0xba12
movq 0x9db0(%rip), %r13      # 0xffd8
cmpl $0x67, %eax
je 0x6258
leaq 0xa22c(%rip), %r12      # 0x10460
cmpl $0x6e, %eax
je 0x6249
cmpl $0x70, %eax
jne 0x64b2
leaq 0xa21b(%rip), %r12      # 0x10464
movq (%r13), %rdi
callq 0x2250
movl %eax, (%r12)
jmp 0x625e
movl $0x1, %r15d
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2240
testl %eax, %eax
jns 0x6228
testl %r15d, %r15d
sete 0xf(%rsp)
jmp 0x627e
movb $0x1, 0xf(%rsp)
movq 0x9d4b(%rip), %rax      # 0xffd0
movslq (%rax), %rax
cmpl %ebp, %eax
je 0x64a6
movq (%rbx,%rax,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x62a3
cmpb $0x0, 0x1(%rdi)
je 0x6484
leaq 0x4efe(%rip), %rsi      # 0xb1a8
callq 0x2220
testq %rax, %rax
je 0x64ad
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x3edd
movq %rax, %r14
movq %rax, %rdi
callq 0x3f27
testl %eax, %eax
js 0x646e
movl %eax, %ebp
leaq 0x9e8f(%rip), %rbx      # 0x10170
movq 0x30(%r14), %r15
movl $0x0, %r12d
testq %r15, %r15
je 0x643e
movq 0x40(%r14), %r13
xorl %ecx, %ecx
xorl %edx, %edx
movl %edx, %r12d
xorl %eax, %eax
subl 0xa15d(%rip), %eax      # 0x10464
movl 0xa153(%rip), %esi      # 0x10460
movsbq (%r13,%rcx), %rcx
cmpb $0xf, (%rcx,%rbx)
jne 0x63b7
movslq %r12d, %rcx
cmpq %rcx, %r15
jbe 0x63bc
incq %rcx
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movsbq -0x1(%r13,%rcx), %r10
cmpb $0xf, (%r10,%rbx)
movl $0x1, %r10d
je 0x6350
movl %eax, %r10d
addl %r10d, %r8d
cmpl %r9d, %r8d
cmovgl %r12d, %edi
cmovgl %r8d, %r9d
cmpq %rcx, %r15
jbe 0x636e
incq %rcx
incl %r12d
testl %r8d, %r8d
jns 0x633a
testl %edi, %edi
js 0x63c6
xorl %r8d, %r8d
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %edi, %r10d
movl %r10d, %r11d
movsbq (%r13,%r11), %r11
cmpb $0xf, (%r11,%rbx)
movl $0x1, %r11d
je 0x639c
movl %eax, %r11d
addl %r11d, %r8d
cmpl %r9d, %r8d
cmovgl %r10d, %ecx
cmovgl %r8d, %r9d
decl %r10d
movl %r8d, %r11d
orl %r10d, %r11d
jns 0x6383
jmp 0x63cb
incl %r12d
jmp 0x63da
xorl %r12d, %r12d
cmpl $0x1, %esi
jg 0x63da
jmp 0x63e8
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leal 0x1(%rdi), %r12d
movl %r12d, %r8d
subl %ecx, %r8d
cmpl %esi, %r8d
jge 0x63ef
movslq %r12d, %rcx
cmpq %rcx, %r15
ja 0x630d
jmp 0x643b
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x63f8
cmpl $-0x1, %edi
jl 0x643b
testl %ecx, %ecx
je 0x642a
cmpb $0x0, 0xf(%rsp)
je 0x6413
movq 0x9bba(%rip), %rax      # 0xffc0
movq (%rax), %rdi
movq %r14, %rsi
callq 0x64c6
jmp 0x642a
movq 0x10(%r14), %rsi
leaq 0x56b7(%rip), %rdi      # 0xbad5
movl %ecx, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x20f0
movslq %r12d, %rcx
movl %r12d, %edx
cmpq %rcx, %r15
ja 0x62ff
jmp 0x643e
movl %edx, %r12d
cmpb $0x0, 0xf(%rsp)
je 0x645c
movq 0x9b74(%rip), %rax      # 0xffc0
movq (%rax), %rdi
movq %r14, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x64c6
movq %r14, %rdi
callq 0x3f27
movl %eax, %ebp
testl %eax, %eax
jns 0x62e1
movq %r14, %rdi
callq 0x428d
movq 0x10(%rsp), %rdi
callq 0x2040
xorl %eax, %eax
jmp 0x64b7
movq 0x9b3d(%rip), %rax      # 0xffc8
movq (%rax), %rdi
callq 0x21b0
leaq 0x4d0e(%rip), %rsi      # 0xb1a8
movl %eax, %edi
callq 0x20b0
jmp 0x62af
callq 0x27a5
jmp 0x64b2
callq 0x2786
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq