// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x1, -0xa0(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x92fd
movq 0x7d03(%rip), %rax      # 0x10fc8
movq (%rax), %rdi
callq 0x21b0
movl %eax, %edi
callq 0x2090
cmpl $0x0, %eax
je 0x92fd
movq 0x7d18(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x5107(%rip), %rsi      # 0xe3f1
movb $0x0, %al
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x9645
cmpl $0x1, -0x8(%rbp)
jle 0x9339
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x5184(%rip), %rsi      # 0xe496
callq 0x2170
cmpl $0x0, %eax
je 0x9339
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x3f55(%rip), %rsi      # 0xd280
callq 0x2220
movq %rax, -0xc0(%rbp)
jmp 0x935d
movq 0x7c88(%rip), %rax      # 0x10fc8
movq (%rax), %rdi
callq 0x21b0
movl %eax, %edi
leaq 0x3f2f(%rip), %rsi      # 0xd280
callq 0x20b0
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x939a
movq 0x7c82(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x40f9(%rip), %rsi      # 0xd479
leaq 0x5090(%rip), %rdx      # 0xe417
movb $0x0, %al
callq 0x2190
movl $0x1, -0x4(%rbp)
jmp 0x9645
movq -0x18(%rbp), %rdi
callq 0x38f0
movq %rax, -0x20(%rbp)
cmpl $0x2, -0x8(%rbp)
jle 0x93bc
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x2120
movq -0x20(%rbp), %rdi
callq 0x3930
cmpl $0x0, %eax
jl 0x9606
cmpq $0x0, -0x90(%rbp)
je 0x95f1
leaq -0x90(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq -0xb0(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x954a
movq -0xa8(%rbp), %rax
cmpq $0x2, (%rax)
jbe 0x9502
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xa8(%rbp), %rcx
movq (%rcx), %rcx
subq $0x2, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x9502
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xb0(%rbp), %rcx
movq (%rcx), %rcx
subq $0x2, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x9502
callq 0x2280
movq (%rax), %rax
movq -0xa8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xa8(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x9502
callq 0x2280
movq (%rax), %rax
movq -0xb0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xb0(%rbp), %rdx
movq (%rdx), %rdx
subq $0x1, %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x9502
movq -0xa8(%rbp), %rax
movq (%rax), %rax
subq $0x2, %rax
movq %rax, -0xc8(%rbp)
jmp 0x9513
movq -0xa8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movl %eax, -0xb8(%rbp)
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0xb8(%rbp), %rdx
callq 0x2060
movl %eax, -0xb4(%rbp)
jmp 0x9554
movl $0x1, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
jne 0x95b1
movq -0x98(%rbp), %rdx
movq -0xa0(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x9660
movq -0x20(%rbp), %rdi
movq -0x98(%rbp), %rdx
movq -0xa0(%rbp), %rcx
xorl %esi, %esi
callq 0x9660
movq $0x0, -0x90(%rbp)
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x95ef
movq -0x98(%rbp), %rdx
movq -0xa0(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x9660
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x73d0
jmp 0x9601
movq -0x20(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x73d0
jmp 0x93cf
cmpq $0x0, -0x90(%rbp)
je 0x962c
movq -0x98(%rbp), %rdx
movq -0xa0(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x9660
movq -0x20(%rbp), %rdi
callq 0x3d40
movq -0x18(%rbp), %rdi
callq 0x2030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)