// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/htslib/cram/sam_header.c
// Function: sam_hdr_dump
void sam_hdr_dump(SAM_hdr *hdr) {
    khint_t k;
    int i;

    printf("===DUMP===\n");
    for (k = kh_begin(hdr->h); k != kh_end(hdr->h); k++) {
	SAM_hdr_type *t1, *t2;
	char c[2];

	if (!kh_exist(hdr->h, k))
	    continue;

	t1 = t2 = kh_val(hdr->h, k);
	c[0] = kh_key(hdr->h, k)>>8;
	c[1] = kh_key(hdr->h, k)&0xff;
	printf("Type %.2s, count %d\n", c, t1->prev->order+1);

	do {
	    SAM_hdr_tag *tag;
	    printf(">>>%d ", t1->order);
	    for (tag = t1->tag; tag; tag=tag->next) {
		printf("\"%.2s\":\"%.*s\"\t",
		       tag->str, tag->len-3, tag->str+3);
	    }
	    putchar('\n');
	    t1 = t1->next;
	} while (t1 != t2);
    }

    /* Dump out PG chains */
    printf("\n@PG chains:\n");
    for (i = 0; i < hdr->npg_end; i++) {
	int j;
	printf("  %d:", i);
	for (j = hdr->pg_end[i]; j != -1; j = hdr->pg[j].prev_id) {
	    printf("%s%d(%.*s)", 
		   j == hdr->pg_end[i] ? " " : "->",
		   j, hdr->pg[j].name_len, hdr->pg[j].name);
	}
	printf("\n");
    }

    puts("===END DUMP===");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x169ca(%rip), %rdi     # 0x53ab3
callq 0x4810
movq 0x18(%rbx), %rax
movl (%rax), %edx
testl %edx, %edx
je 0x3d1bc
leaq 0x167f9(%rip), %r13     # 0x538fc
xorl %ebp, %ebp
movq 0x10(%rax), %rcx
movl %ebp, %esi
shrl $0x4, %esi
movl (%rcx,%rsi,4), %esi
leal (,%rbp,2), %ecx
shrl %cl, %esi
testb $0x3, %sil
jne 0x3d1b2
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rax
movl %ebp, %edx
movq (%rax,%rdx,8), %r15
movzwl (%rcx,%rdx,4), %eax
rolw $0x8, %ax
movw %ax, 0x6(%rsp)
movq 0x8(%r15), %rax
movl 0x18(%rax), %edx
incl %edx
leaq 0x16791(%rip), %rdi     # 0x538e0
leaq 0x6(%rsp), %rsi
xorl %eax, %eax
callq 0x4080
movq %r15, %r14
movl 0x18(%r14), %esi
leaq 0x1678c(%rip), %rdi     # 0x538f5
xorl %eax, %eax
callq 0x4080
movq 0x10(%r14), %r12
testq %r12, %r12
je 0x3d19a
movq 0x8(%r12), %rsi
movl 0x10(%r12), %edx
addl $-0x3, %edx
leaq 0x3(%rsi), %rcx
movq %r13, %rdi
xorl %eax, %eax
callq 0x4080
movq (%r12), %r12
jmp 0x3d174
movl $0xa, %edi
callq 0x4740
movq (%r14), %r14
cmpq %r15, %r14
jne 0x3d15e
movq 0x18(%rbx), %rax
movl (%rax), %edx
incl %ebp
cmpl %edx, %ebp
jne 0x3d105
leaq 0x168fb(%rip), %rdi     # 0x53abe
callq 0x4810
cmpl $0x0, 0x6c(%rbx)
jle 0x3d267
leaq 0x12a80(%rip), %r13     # 0x4fc59
leaq 0x1673c(%rip), %rbp     # 0x5391c
leaq 0x1672a(%rip), %r15     # 0x53911
xorl %r12d, %r12d
leaq 0x1671a(%rip), %rdi     # 0x5390b
movl %r12d, %esi
xorl %eax, %eax
callq 0x4080
movq 0x88(%rbx), %rax
movl (%rax,%r12,4), %ecx
cmpl $-0x1, %ecx
je 0x3d251
movq 0x78(%rbx), %rax
movq 0x88(%rbx), %rdx
cmpl (%rdx,%r12,4), %ecx
movq %rbp, %rsi
cmoveq %r13, %rsi
movslq %ecx, %rdx
leaq (,%rdx,8), %rcx
leaq (%rcx,%rcx,4), %r14
movl 0x18(%rax,%r14), %ecx
movq (%rax,%r14), %r8
movq %r15, %rdi
xorl %eax, %eax
callq 0x4080
movq 0x78(%rbx), %rax
movl 0x20(%rax,%r14), %ecx
cmpl $-0x1, %ecx
jne 0x3d20f
movl $0xa, %edi
callq 0x4740
incq %r12
movslq 0x6c(%rbx), %rax
cmpq %rax, %r12
jl 0x3d1ea
leaq 0x166b1(%rip), %rdi     # 0x5391f
callq 0x4810
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq