// File: /workspace/github_c_makefile_star2_O1/xiongxu[P]bam2bedGraph2/samtools-0.1.19/misc/wgsim.c
// Function: wgsim_print_mutref
void wgsim_print_mutref(const char *name, const kseq_t *ks, mutseq_t *hap1, mutseq_t *hap2)
{
	int i;
	for (i = 0; i != ks->seq.l; ++i) {
		int c[3];
		c[0] = nst_nt4_table[(int)ks->seq.s[i]];
		c[1] = hap1->s[i]; c[2] = hap2->s[i];
		if (c[0] >= 4) continue;
		if ((c[1] & mutmsk) != NOCHANGE || (c[2] & mutmsk) != NOCHANGE) {
			printf("%s\t%d\t", name, i+1);
			if (c[1] == c[2]) { // hom
				if ((c[1]&mutmsk) == SUBSTITUTE) { // substitution
					printf("%c\t%c\t-\n", "ACGTN"[c[0]], "ACGTN"[c[1]&0xf]);
				} else if ((c[1]&mutmsk) == DELETE) { // del
					printf("%c\t-\t-\n", "ACGTN"[c[0]]);
				} else if (((c[1] & mutmsk) >> 12) <= 5) { // ins
					printf("-\t");
                    int n = (c[1]&mutmsk) >> 12, ins = c[1] >> 4;
                    while (n > 0) {
                        putchar("ACGTN"[ins & 0x3]);
						ins >>= 2;
                        n--;
                    }
                    printf("\t-\n");
				}  else assert(0);
			} else { // het
				if ((c[1]&mutmsk) == SUBSTITUTE || (c[2]&mutmsk) == SUBSTITUTE) { // substitution
					printf("%c\t%c\t+\n", "ACGTN"[c[0]], "XACMGRSVTWYHKDBN"[1<<(c[1]&0x3)|1<<(c[2]&0x3)]);
				} else if ((c[1]&mutmsk) == DELETE) {
					printf("%c\t-\t+\n", "ACGTN"[c[0]]);
				} else if ((c[2]&mutmsk) == DELETE) {
					printf("%c\t-\t+\n", "ACGTN"[c[0]]);
				} else if (((c[1] & mutmsk) >> 12) <= 4) { // ins1
					printf("-\t");
                    int n = (c[1]&mutmsk) >> 12, ins = c[1] >> 4;
                    while (n > 0) {
                        putchar("ACGTN"[ins & 0x3]);
						ins >>= 2;
                        n--;
                    }
                    printf("\t+\n");
				} else if (((c[2] & mutmsk) >> 12) <= 5) { // ins2
					printf("-\t");
                    int n = (c[2]&mutmsk) >> 12, ins = c[2] >> 4;
                    while (n > 0) {
                        putchar("ACGTN"[ins & 0x3]);
                        ins >>= 2;
                        n--;
                    }
                    printf("\t+\n");
				} else assert(0);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
cmpq $0x0, 0x30(%rsi)
je 0x251a
movq %rcx, %r14
movq %rsi, %r15
leaq 0xdc1(%rip), %rsi       # 0x3080
xorl %r13d, %r13d
movq %rdx, 0x8(%rsp)
movq 0x40(%r15), %rax
movsbq (%rax,%r13), %rax
movzbl (%rax,%rsi), %ebx
cmpq $0x3, %rbx
ja 0x2464
movq 0x8(%rdx), %rax
movzwl (%rax,%r13,2), %r12d
movq 0x8(%r14), %rax
movzwl (%rax,%r13,2), %ebp
cmpl $0xfff, %r12d           # imm = 0xFFF
ja 0x2307
movzwl %bp, %eax
cmpl $0x1000, %eax           # imm = 0x1000
jb 0x2464
leal 0x1(%r13), %edx
leaq 0xe6e(%rip), %rdi       # 0x3180
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x1090
movl %r12d, %eax
cmpw %bp, %r12w
jne 0x2364
notl %eax
testl $0xf000, %eax           # imm = 0xF000
je 0x23c3
movl %r12d, %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xe000, %eax           # imm = 0xE000
leaq 0xe48(%rip), %rbp       # 0x3190
jne 0x23d7
movsbl (%rbx,%rbp), %esi
andl $0xf, %r12d
movsbl (%r12,%rbp), %edx
leaq 0xe25(%rip), %rdi       # 0x3187
jmp 0x23b7
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xe000, %eax           # imm = 0xE000
je 0x2384
movl %ebp, %ecx
andl $0xf000, %ecx           # imm = 0xF000
cmpl $0xe000, %ecx           # imm = 0xE000
jne 0x2430
andb $0x3, %bpl
movl $0x1, %eax
movl %ebp, %ecx
shlq %cl, %rax
leaq 0xdf7(%rip), %rcx       # 0x3190
movsbl (%rbx,%rcx), %esi
andb $0x3, %r12b
btsq %r12, %rax
leaq 0xe54(%rip), %rcx       # 0x3200
movsbl (%rax,%rcx), %edx
leaq 0xe40(%rip), %rdi       # 0x31f7
xorl %eax, %eax
callq 0x1090
jmp 0x2458
leaq 0xdc6(%rip), %rax       # 0x3190
movsbl (%rbx,%rax), %esi
leaq 0xdc1(%rip), %rdi       # 0x3196
jmp 0x2451
cmpl $0x5fff, %r12d          # imm = 0x5FFF
ja 0x2529
leaq 0xdb3(%rip), %rdi       # 0x319e
xorl %eax, %eax
callq 0x1090
cmpl $0x1000, %r12d          # imm = 0x1000
jb 0x2422
movl %r12d, %ebx
shrl $0x4, %ebx
shrl $0xc, %r12d
incl %r12d
movl %ebx, %eax
andl $0x3, %eax
movsbl (%rax,%rbp), %edi
callq 0x1050
shrl $0x2, %ebx
decl %r12d
cmpl $0x1, %r12d
jg 0x2408
leaq 0x11e2(%rip), %rdi      # 0x360b
callq 0x1060
jmp 0x2458
cmpl $0xf000, %eax           # imm = 0xF000
je 0x243f
cmpl $0xf000, %ecx           # imm = 0xF000
jne 0x2476
leaq 0xd4a(%rip), %rax       # 0x3190
movsbl (%rbx,%rax), %esi
leaq 0xdc0(%rip), %rdi       # 0x3211
xorl %eax, %eax
callq 0x1090
movq 0x8(%rsp), %rdx
leaq 0xc1c(%rip), %rsi       # 0x3080
incq %r13
cmpq %r13, 0x30(%r15)
jne 0x22c7
jmp 0x251a
cmpl $0x4fff, %r12d          # imm = 0x4FFF
ja 0x24c6
leaq 0xd18(%rip), %rdi       # 0x319e
xorl %eax, %eax
callq 0x1090
cmpl $0x1000, %r12d          # imm = 0x1000
leaq 0xcf5(%rip), %rbp       # 0x3190
jb 0x250e
movl %r12d, %ebx
shrl $0x4, %ebx
shrl $0xc, %r12d
incl %r12d
movl %ebx, %eax
andl $0x3, %eax
movsbl (%rax,%rbp), %edi
callq 0x1050
shrl $0x2, %ebx
decl %r12d
cmpl $0x1, %r12d
jg 0x24aa
jmp 0x250e
cmpl $0x5fff, %ebp           # imm = 0x5FFF
ja 0x2548
leaq 0xcc9(%rip), %rdi       # 0x319e
xorl %eax, %eax
callq 0x1090
cmpl $0x1000, %ebp           # imm = 0x1000
leaq 0xca7(%rip), %r12       # 0x3190
jb 0x250e
movl %ebp, %ebx
shrl $0x4, %ebx
shrl $0xc, %ebp
incl %ebp
movl %ebx, %eax
andl $0x3, %eax
movsbl (%rax,%r12), %edi
callq 0x1050
shrl $0x2, %ebx
decl %ebp
cmpl $0x1, %ebp
jg 0x24f5
leaq 0x10f3(%rip), %rdi      # 0x3608
jmp 0x2429
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe25(%rip), %rdi       # 0x3355
leaq 0xc6a(%rip), %rsi       # 0x31a1
leaq 0xc6b(%rip), %rcx       # 0x31a9
movl $0xb7, %edx
callq 0x10a0
leaq 0xe06(%rip), %rdi       # 0x3355
leaq 0xc4b(%rip), %rsi       # 0x31a1
leaq 0xc4c(%rip), %rcx       # 0x31a9
movl $0xd1, %edx
callq 0x10a0