// File: /workspace/github_cpp_makefile_star2_O3/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/misc/wgsim.c
// Function: maq_print_mutref
void maq_print_mutref(const char *name, const seq_t *seq, mutseq_t *hap1, mutseq_t *hap2)
{
	int i;
	for (i = 0; i != seq->l; ++i) {
		int c[3];
		c[0] = nst_nt4_table[(int)seq->s[i]];
		c[1] = hap1->s[i]; c[2] = hap2->s[i];
		if (c[0] >= 4) continue;
		if ((c[1] & mutmsk) != NOCHANGE || (c[1] & 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]);
                        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]);
                        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 %rcx, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
cmpl $0x0, (%rsi)
je 0x2fc7
movq %rsi, %r15
leaq 0x131a(%rip), %r14      # 0x4090
xorl %ebp, %ebp
movq %rdx, (%rsp)
movq %rbp, %rax
movq 0x8(%r15), %rcx
movzbl (%rcx,%rbp), %ecx
movzbl (%rcx,%r14), %r12d
cmpq $0x4, %r12
setae %cl
movq 0x8(%rdx), %rsi
movzwl (%rsi,%rbp,2), %ebx
cmpl $0x1000, %ebx           # imm = 0x1000
setb %sil
orb %cl, %sil
incq %rbp
testb %sil, %sil
jne 0x2f12
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rcx
movzwl (%rcx,%rax,2), %r13d
leaq 0x142e(%rip), %rdi      # 0x41f7
movq 0x8(%rsp), %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10a0
movl %ebx, %eax
cmpw %r13w, %bx
jne 0x2e1a
notl %eax
testl $0xf000, %eax           # imm = 0xF000
je 0x2e7b
movl %ebx, %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xe000, %eax           # imm = 0xE000
jne 0x2e90
leaq 0x1402(%rip), %rax      # 0x4207
movsbl (%r12,%rax), %esi
andl $0xf, %ebx
movsbl (%rbx,%rax), %edx
leaq 0x13e6(%rip), %rdi      # 0x41fe
jmp 0x2e6f
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xe000, %eax           # imm = 0xE000
je 0x2e3b
movl %r13d, %ecx
andl $0xf000, %ecx           # imm = 0xF000
cmpl $0xe000, %ecx           # imm = 0xE000
jne 0x2ee5
andb $0x3, %r13b
movl $0x1, %eax
movl %r13d, %ecx
shlq %cl, %rax
leaq 0x13b6(%rip), %rcx      # 0x4207
movsbl (%r12,%rcx), %esi
andb $0x3, %bl
btsq %rbx, %rax
leaq 0x1412(%rip), %rcx      # 0x4276
movsbl (%rax,%rcx), %edx
leaq 0x13fe(%rip), %rdi      # 0x426d
xorl %eax, %eax
callq 0x10a0
jmp 0x2f0e
leaq 0x1385(%rip), %rax      # 0x4207
movsbl (%r12,%rax), %esi
leaq 0x137f(%rip), %rdi      # 0x420d
jmp 0x2f07
cmpl $0x5fff, %ebx           # imm = 0x5FFF
ja 0x2fd6
leaq 0x1372(%rip), %rdi      # 0x4215
xorl %eax, %eax
callq 0x10a0
movl %ebx, %r12d
shrl $0xc, %r12d
shrl $0x4, %ebx
andl $0x3, %ebx
leaq 0x1349(%rip), %rax      # 0x4207
movsbl (%rbx,%rax), %r13d
incl %r12d
movl %r13d, %edi
callq 0x1040
decl %r12d
cmpl $0x1, %r12d
ja 0x2ec6
leaq 0x1814(%rip), %rdi      # 0x46f2
callq 0x1060
jmp 0x2f0e
cmpl $0xf000, %eax           # imm = 0xF000
je 0x2ef4
cmpl $0xf000, %ecx           # imm = 0xF000
jne 0x2f23
leaq 0x130c(%rip), %rax      # 0x4207
movsbl (%r12,%rax), %esi
leaq 0x1380(%rip), %rdi      # 0x4287
xorl %eax, %eax
callq 0x10a0
movq (%rsp), %rdx
movl (%r15), %eax
cmpq %rax, %rbp
jne 0x2d7c
jmp 0x2fc7
cmpl $0x4fff, %ebx           # imm = 0x4FFF
ja 0x2f68
leaq 0x12e3(%rip), %rdi      # 0x4215
xorl %eax, %eax
callq 0x10a0
movl %ebx, %r12d
shrl $0xc, %r12d
shrl $0x4, %ebx
andl $0x3, %ebx
leaq 0x12ba(%rip), %rax      # 0x4207
movsbl (%rbx,%rax), %r13d
incl %r12d
movl %r13d, %edi
callq 0x1040
decl %r12d
cmpl $0x1, %r12d
ja 0x2f55
jmp 0x2fbb
cmpl $0x5fff, %r13d          # imm = 0x5FFF
ja 0x2ff5
leaq 0x1299(%rip), %rdi      # 0x4215
xorl %eax, %eax
callq 0x10a0
cmpl $0x1000, %r13d          # imm = 0x1000
leaq 0x1276(%rip), %r12      # 0x4207
jb 0x2fbb
movl %r13d, %ebx
shrl $0x4, %ebx
shrl $0xc, %r13d
incl %r13d
movl %ebx, %eax
andl $0x3, %eax
movsbl (%rax,%r12), %edi
callq 0x1040
shrl $0x2, %ebx
decl %r13d
cmpl $0x1, %r13d
ja 0x2fa0
leaq 0x172d(%rip), %rdi      # 0x46ef
jmp 0x2ede
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x123b(%rip), %rdi      # 0x4218
leaq 0x1236(%rip), %rsi      # 0x421a
leaq 0x1237(%rip), %rcx      # 0x4222
movl $0x100, %edx            # imm = 0x100
callq 0x10c0
leaq 0x121c(%rip), %rdi      # 0x4218
leaq 0x1217(%rip), %rsi      # 0x421a
leaq 0x1218(%rip), %rcx      # 0x4222
movl $0x119, %edx            # imm = 0x119
callq 0x10c0