// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/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 0x386c3(%rip), %rdi     # 0x99bb0
callq 0x6bb0
movq 0x18(%rbx), %rax
movl (%rax), %edx
testl %edx, %edx
je 0x615c0
leaq 0x384f5(%rip), %r13     # 0x999fc
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 0x615b6
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 0x3848d(%rip), %rdi     # 0x999e0
leaq 0x6(%rsp), %rsi
xorl %eax, %eax
callq 0x6070
movq %r15, %r14
movl 0x18(%r14), %esi
leaq 0x38488(%rip), %rdi     # 0x999f5
xorl %eax, %eax
callq 0x6070
movq 0x10(%r14), %r12
testq %r12, %r12
je 0x6159e
movq 0x8(%r12), %rsi
movl 0x10(%r12), %edx
addl $-0x3, %edx
leaq 0x3(%rsi), %rcx
movq %r13, %rdi
xorl %eax, %eax
callq 0x6070
movq (%r12), %r12
jmp 0x61578
movl $0xa, %edi
callq 0x6a40
movq (%r14), %r14
cmpq %r15, %r14
jne 0x61562
movq 0x18(%rbx), %rax
movl (%rax), %edx
incl %ebp
cmpl %edx, %ebp
jne 0x61509
leaq 0x385f4(%rip), %rdi     # 0x99bbb
callq 0x6bb0
cmpl $0x0, 0x6c(%rbx)
jle 0x6166b
leaq 0x2ce55(%rip), %r13     # 0x8e432
leaq 0x362fe(%rip), %rbp     # 0x978e2
leaq 0x38426(%rip), %r15     # 0x99a11
xorl %r12d, %r12d
leaq 0x38416(%rip), %rdi     # 0x99a0b
movl %r12d, %esi
xorl %eax, %eax
callq 0x6070
movq 0x88(%rbx), %rax
movl (%rax,%r12,4), %ecx
cmpl $-0x1, %ecx
je 0x61655
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 0x6070
movq 0x78(%rbx), %rax
movl 0x20(%rax,%r14), %ecx
cmpl $-0x1, %ecx
jne 0x61613
movl $0xa, %edi
callq 0x6a40
incq %r12
movslq 0x6c(%rbx), %rax
cmpq %rax, %r12
jl 0x615ee
leaq 0x383aa(%rip), %rdi     # 0x99a1c
callq 0x6bb0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq