// File: /workspace/github_c_makefile_star2_O3/aokad[P]sequeeze/seqtk.c
// Function: stk_rename
int stk_rename(int argc, char *argv[])
{
	gzFile fp;
	kseq_t *seq, last;
	char *prefix = 0;
	uint64_t n = 1;

	if (argc == 1 && isatty(fileno(stdin))) {
		fprintf(stderr, "Usage: seqtk rename <in.fq> [prefix]\n");
		return 1;
	}
	fp = argc > 1 && strcmp(argv[1], "-")? gzopen(argv[1], "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);
	if (argc > 2) prefix = argv[2];

	memset(&last, 0, sizeof(kseq_t));
	while (kseq_read(seq) >= 0) {
		if (last.name.l) {
			kstring_t *p = &last.name, *q = &seq->name;
			int is_diff;
			if (p->l == q->l) {
				int l = (p->l > 2 && p->s[p->l-2] == '/' && q->s[q->l-2] == '/' && isdigit(p->s[p->l-1]) && isdigit(q->s[q->l-1]))? p->l - 2 : p->l;
				is_diff = strncmp(p->s, q->s, l);
			} else is_diff = 1;
			if (!is_diff) {
				stk_printseq_renamed(&last, 0, prefix, n);
				stk_printseq_renamed(seq,   0, prefix, n);
				last.name.l = 0;
				++n;
			} else {
				stk_printseq_renamed(&last, 0, prefix, n);
				++n;
				cpy_kseq(&last, seq);
			}
		} else cpy_kseq(&last, seq);
	}
	if (last.name.l) stk_printseq_renamed(&last, 0, prefix, n);

	kseq_destroy(seq);
	gzclose(fp);
	// free last!
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movl %edi, %ebp
cmpl $0x1, %edi
jne 0x8595
movq 0x7a50(%rip), %rax      # 0xffc8
movq (%rax), %rdi
callq 0x21b0
movl %eax, %edi
callq 0x2090
testl %eax, %eax
je 0x85b4
callq 0x2ce8
jmp 0x8975
jle 0x85b4
movq 0x8(%rbx), %rdi
cmpb $0x2d, (%rdi)
jne 0x85a6
cmpb $0x0, 0x1(%rdi)
je 0x85b4
leaq 0x2bfb(%rip), %rsi      # 0xb1a8
callq 0x2220
jmp 0x85d1
movq 0x7a0d(%rip), %rax      # 0xffc8
movq (%rax), %rdi
callq 0x21b0
leaq 0x2bde(%rip), %rsi      # 0xb1a8
movl %eax, %edi
callq 0x20b0
movq %rax, %r15
testq %rax, %rax
je 0x8970
movq %r15, %rdi
callq 0x3edd
movq %rax, %r14
cmpl $0x3, %ebp
movq %r15, 0x8(%rsp)
jl 0x85f8
movq 0x10(%rbx), %r15
jmp 0x85fb
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq %r14, %rdi
callq 0x3f27
testl %eax, %eax
js 0x894a
movl $0x1, %r12d
leaq 0x10(%rsp), %rbx
movq 0x10(%rsp), %r13
testq %r13, %r13
je 0x8692
cmpq (%r14), %r13
jne 0x86a2
movq 0x20(%rsp), %rbp
cmpq $0x2, %r13
jbe 0x86a9
cmpb $0x2f, -0x2(%rbp,%r13)
movq 0x10(%r14), %rbx
jne 0x86ad
cmpb $0x2f, -0x2(%rbx,%r13)
jne 0x86ad
callq 0x2290
movq (%rax), %rax
movsbq -0x1(%rbp,%r13), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x86ad
movsbq -0x1(%rbx,%r13), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x86ad
addq $-0x2, %r13
jmp 0x86ad
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71ec
jmp 0x8769
movq 0x58(%rsp), %r13
jmp 0x86cd
movq 0x10(%r14), %rbx
movslq %r13d, %rdx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2070
movq 0x58(%rsp), %r13
testl %eax, %eax
je 0x877e
leaq 0x10(%rsp), %rbx
xorl %eax, %eax
testq %r13, %r13
setne %al
leal 0x3e(,%rax,2), %edi
callq 0x2060
testq %r12, %r12
js 0x8710
testq %r15, %r15
je 0x86fd
movq 0x78ce(%rip), %rax      # 0xffc0
movq (%rax), %rsi
movq %r15, %rdi
callq 0x2110
leaq 0x3e7f(%rip), %rdi      # 0xc583
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x8724
movq 0x20(%rsp), %rdi
movq 0x78a4(%rip), %rax      # 0xffc0
movq (%rax), %rsi
callq 0x2110
movl $0xa, %edi
callq 0x2060
movq 0x50(%rsp), %rdi
callq 0x2080
testq %r13, %r13
je 0x875b
movl $0x2b, %edi
callq 0x2060
movl $0xa, %edi
callq 0x2060
movq 0x68(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71ec
incq %r12
movq %r14, %rdi
callq 0x3f27
testl %eax, %eax
jns 0x863c
jmp 0x88ab
xorl %eax, %eax
testq %r13, %r13
setne %al
leal 0x3e(,%rax,2), %edi
callq 0x2060
testq %r12, %r12
js 0x87c1
testq %r15, %r15
je 0x87ae
movq 0x781d(%rip), %rax      # 0xffc0
movq (%rax), %rsi
movq %r15, %rdi
callq 0x2110
leaq 0x3dce(%rip), %rdi      # 0xc583
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x87d3
movq 0x77f8(%rip), %rax      # 0xffc0
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x2110
movl $0xa, %edi
callq 0x2060
movq 0x50(%rsp), %rdi
callq 0x2080
testq %r13, %r13
je 0x880a
movl $0x2b, %edi
callq 0x2060
movl $0xa, %edi
callq 0x2060
movq 0x68(%rsp), %rdi
callq 0x2080
movq 0x48(%r14), %r13
xorl %eax, %eax
testq %r13, %r13
setne %al
leal 0x3e(,%rax,2), %edi
callq 0x2060
testq %r12, %r12
js 0x8851
testq %r15, %r15
je 0x883e
movq 0x778d(%rip), %rax      # 0xffc0
movq (%rax), %rsi
movq %r15, %rdi
callq 0x2110
leaq 0x3d3e(%rip), %rdi      # 0xc583
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x8863
movq 0x7768(%rip), %rax      # 0xffc0
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2110
leaq 0x10(%rsp), %rbx
movl $0xa, %edi
callq 0x2060
movq 0x40(%r14), %rdi
callq 0x2080
testq %r13, %r13
je 0x889d
movl $0x2b, %edi
callq 0x2060
movl $0xa, %edi
callq 0x2060
movq 0x58(%r14), %rdi
callq 0x2080
movq $0x0, 0x10(%rsp)
jmp 0x8766
cmpq $0x0, 0x10(%rsp)
je 0x894a
movq 0x58(%rsp), %rbx
xorl %eax, %eax
testq %rbx, %rbx
setne %al
leal 0x3e(,%rax,2), %edi
callq 0x2060
testq %r12, %r12
js 0x88ff
testq %r15, %r15
je 0x88ec
movq 0x76df(%rip), %rax      # 0xffc0
movq (%rax), %rsi
movq %r15, %rdi
callq 0x2110
leaq 0x3c90(%rip), %rdi      # 0xc583
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x8913
movq 0x20(%rsp), %rdi
movq 0x76b5(%rip), %rax      # 0xffc0
movq (%rax), %rsi
callq 0x2110
movl $0xa, %edi
callq 0x2060
movq 0x50(%rsp), %rdi
callq 0x2080
testq %rbx, %rbx
je 0x894a
movl $0x2b, %edi
callq 0x2060
movl $0xa, %edi
callq 0x2060
movq 0x68(%rsp), %rdi
callq 0x2080
movq %r14, %rdi
callq 0x428d
movq 0x8(%rsp), %rdi
callq 0x2040
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2d04
movl $0x1, %eax
jmp 0x895e