// File: /workspace/github_c_makefile_star2_O2/aokad[P]sequeeze/seqtk.c
// Function: stk_randbase
int stk_randbase(int argc, char *argv[])
{
	gzFile fp;
	kseq_t *seq;
	int l;
	if (argc == 1) {
		fprintf(stderr, "Usage: seqtk randbase <in.fa>\n");
		return 1;
	}
	fp = (strcmp(argv[1], "-") == 0)? gzdopen(fileno(stdin), "r") : gzopen(argv[1], "r");
	if (fp == 0) {
		fprintf(stderr, "[E::%s] failed to open the input file/stream.\n", __func__);
		return 1;
	}
	seq = kseq_init(fp);
	while ((l = kseq_read(seq)) >= 0) {
		int i;
		printf(">%s", seq->name.s);
		for (i = 0; i < l; ++i) {
			int c, b, a, j, k, m;
			b = seq->seq.s[i];
			c = seq_nt16_table[b];
			a = bitcnt_table[c];
			if (a == 2) {
				m = (drand48() < 0.5);
				for (j = k = 0; j < 4; ++j) {
					if ((1<<j & c) == 0) continue;
					if (k == m) break;
					++k;
				}
				seq->seq.s[i] = islower(b)? "acgt"[j] : "ACGT"[j];
			}
			if (i%60 == 0) putchar('\n');
			putchar(seq->seq.s[i]);
		}
		putchar('\n');
	}
	kseq_destroy(seq);
	gzclose(fp);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0x1, %edi
je 0x3949
movq 0x8(%rsi), %rdi
cmpb $0x2d, (%rdi)
jne 0x37d8
cmpb $0x0, 0x1(%rdi)
je 0x3927
leaq 0x59c9(%rip), %rsi      # 0x91a8
callq 0x2220
testq %rax, %rax
je 0x3967
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x3102
movq %rax, %r14
leaq 0xa96c(%rip), %r15      # 0xe170
movq %r14, %rdi
callq 0x312e
testl %eax, %eax
js 0x3904
movl %eax, %r12d
movq 0x10(%r14), %rsi
leaq 0x5c82(%rip), %rdi      # 0x94a4
xorl %eax, %eax
callq 0x20f0
movl %r12d, %eax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
cmpq 0x10(%rsp), %r12
je 0x38f7
movq 0x40(%r14), %r13
movb (%r13,%r12), %cl
movsbq %cl, %rbx
movzbl (%rbx,%r15), %ebp
leaq 0xab48(%rip), %rax      # 0xe3a0
cmpl $0x2, (%rax,%rbp,4)
jne 0x38cc
movq %r14, %r15
callq 0x22a0
xorl %eax, %eax
movsd 0x5800(%rip), %xmm1     # 0x9070
ucomisd %xmm0, %xmm1
seta %al
xorl %r14d, %r14d
xorl %ecx, %ecx
xorl %edx, %edx
cmpl $-0x4, %r14d
je 0x3896
btl %ecx, %ebp
jae 0x388f
cmpl %eax, %edx
je 0x3896
incl %edx
incl %ecx
decq %r14
jmp 0x387e
callq 0x2290
movq (%rax), %rax
movzwl (%rax,%rbx,2), %eax
btl $0x9, %eax
leaq 0x5bfb(%rip), %rax      # 0x94a8
leaq 0x5bf9(%rip), %rcx      # 0x94ad
cmovaeq %rcx, %rax
subq %r14, %rax
movb (%rax), %cl
movb %cl, (%r13,%r12)
movq %r15, %r14
leaq 0xa8a4(%rip), %r15      # 0xe170
movl %r12d, %eax
xorl %edx, %edx
pushq $0x3c
popq %rsi
divl %esi
testl %edx, %edx
jne 0x38e7
pushq $0xa
popq %rdi
callq 0x2060
movb (%r13,%r12), %cl
movsbl %cl, %edi
callq 0x2060
incq %r12
jmp 0x3834
pushq $0xa
popq %rdi
callq 0x2060
jmp 0x3804
movq %r14, %rdi
callq 0x3329
movq 0x8(%rsp), %rdi
callq 0x2040
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa69a(%rip), %rax      # 0xdfc8
movq (%rax), %rdi
callq 0x21b0
leaq 0x586b(%rip), %rsi      # 0x91a8
movl %eax, %edi
callq 0x20b0
jmp 0x37e4
movq 0xa6a8(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x5b1e(%rip), %rdi      # 0x9478
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x2260
jmp 0x3986
movq 0xa68a(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x5a29(%rip), %rsi      # 0x93a1
leaq 0x5b18(%rip), %rdx      # 0x9497
xorl %eax, %eax
callq 0x2190
pushq $0x1
popq %rax
jmp 0x3918