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

	char base_quality[] = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ";
	//char bin_quality[] = "!!''''''''000000000077777<<<<<BBBBBFFFFFII";

	seq = kseq_init(fp);

	memset(&last, 0, sizeof(kseq_t));
	while (kseq_read(seq) >= 0) {
		int i;
		for (i = 0; i < seq->qual.l; ++i) {
			char *p = strchr(base_quality, seq->qual.s[i]);
			int pos = 42;
			if (p != NULL) {
				pos = p - base_quality;
			}
			seq->qual.s[i] = bin_quality[pos];
		}
		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 $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x1, -0x98(%rbp)
leaq -0xd0(%rbp), %rdi
leaq 0x45b0(%rip), %rsi      # 0xea50
movl $0x2b, %edx
callq 0x21a0
movq -0x8(%rbp), %rdi
callq 0x38f0
movq %rax, -0x20(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x2120
movq -0x20(%rbp), %rdi
callq 0x3930
cmpl $0x0, %eax
jl 0xa79c
movl $0x0, -0xd4(%rbp)
movslq -0xd4(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0xa580
leaq -0xd0(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xd4(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x20e0
movq %rax, -0xe0(%rbp)
movl $0x2a, -0xe4(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0xa54c
movq -0xe0(%rbp), %rax
leaq -0xd0(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0xe4(%rbp)
movq -0x10(%rbp), %rax
movslq -0xe4(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0xd4(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0xa4e6
cmpq $0x0, -0x90(%rbp)
je 0xa787
leaq -0x90(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf0(%rbp), %rax
movq (%rax), %rax
movq -0xf8(%rbp), %rcx
cmpq (%rcx), %rax
jne 0xa6e9
movq -0xf0(%rbp), %rax
cmpq $0x2, (%rax)
jbe 0xa6a1
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movq (%rcx), %rcx
subq $0x2, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xa6a1
movq -0xf8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf8(%rbp), %rcx
movq (%rcx), %rcx
subq $0x2, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xa6a1
callq 0x2280
movq (%rax), %rax
movq -0xf0(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xf0(%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 0xa6a1
callq 0x2280
movq (%rax), %rax
movq -0xf8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0xf8(%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 0xa6a1
movq -0xf0(%rbp), %rax
movq (%rax), %rax
subq $0x2, %rax
movq %rax, -0x108(%rbp)
jmp 0xa6b2
movq -0xf0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movl %eax, -0x100(%rbp)
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0xf8(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x100(%rbp), %rdx
callq 0x2060
movl %eax, -0xfc(%rbp)
jmp 0xa6f3
movl $0x1, -0xfc(%rbp)
cmpl $0x0, -0xfc(%rbp)
jne 0xa74a
movq -0x18(%rbp), %rdx
movq -0x98(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x9660
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x98(%rbp), %rcx
xorl %esi, %esi
callq 0x9660
movq $0x0, -0x90(%rbp)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0xa785
movq -0x18(%rbp), %rdx
movq -0x98(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x9660
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x73d0
jmp 0xa797
movq -0x20(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x73d0
jmp 0xa4ca
cmpq $0x0, -0x90(%rbp)
je 0xa7bf
movq -0x18(%rbp), %rdx
movq -0x98(%rbp), %rcx
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x9660
movq -0x20(%rbp), %rdi
callq 0x3d40
movq -0x8(%rbp), %rdi
callq 0x2030
xorl %eax, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax)