// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/sam_header.c
// Function: sam_hdr_add_PG
int sam_hdr_add_PG(SAM_hdr *sh, const char *name, ...) {
    va_list args;

    if (sh->npg_end) {
	/* Copy ends array to avoid us looping while modifying it */
	int *end = malloc(sh->npg_end * sizeof(int));
	int i, nends = sh->npg_end;

	if (!end)
	    return -1;

	memcpy(end, sh->pg_end, nends * sizeof(*end));

	for (i = 0; i < nends; i++) {
	    va_start(args, name);
	    if (-1 == sam_hdr_vadd(sh, "PG", args,
				   "ID", sam_hdr_PG_ID(sh, name),
				   "PN", name,
				   "PP", sh->pg[end[i]].name,
				   NULL)) {
		free(end);
		return  -1;
	    }
	    va_end(args);
	}

	free(end);
    } else {
	va_start(args, name);
	if (-1 == sam_hdr_vadd(sh, "PG", args,
			       "ID", sam_hdr_PG_ID(sh, name),
			       "PN", name,
			       NULL))
	    return -1;
	va_end(args);
    }

    //sam_hdr_dump(sh);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
testb %al, %al
je 0x96e5f
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
movaps %xmm2, -0xb0(%rbp)
movaps %xmm3, -0xa0(%rbp)
movaps %xmm4, -0x90(%rbp)
movaps %xmm5, -0x80(%rbp)
movaps %xmm6, -0x70(%rbp)
movaps %xmm7, -0x60(%rbp)
movq %r9, -0xd8(%rbp)
movq %r8, -0xe0(%rbp)
movq %rcx, -0xe8(%rbp)
movq %rdx, -0xf0(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x6c(%rax)
je 0x96fe8
movq -0x18(%rbp), %rax
movslq 0x6c(%rax), %rdi
shlq $0x2, %rdi
callq 0x69c0
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl 0x6c(%rax), %eax
movl %eax, -0x50(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x96ec3
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
jmp 0x9708f
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rsi
movslq -0x50(%rbp), %rdx
shlq $0x2, %rdx
callq 0x6570
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x96fda
leaq -0x40(%rbp), %rax
leaq -0x100(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x96d60
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rdx
movq %rax, %r8
movq -0x20(%rbp), %r11
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x4c(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
leaq 0x4c99e(%rip), %rsi     # 0xe3911
leaq 0x4c03a(%rip), %rcx     # 0xe2fb4
leaq 0x4c993(%rip), %r9      # 0xe3914
leaq 0x4c98f(%rip), %r10     # 0xe3917
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, %al
callq 0x94810
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x96fc8
movq -0x48(%rbp), %rdi
callq 0x6880
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
jmp 0x9708f
leaq -0x40(%rbp), %rax
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x96ee6
movq -0x48(%rbp), %rdi
callq 0x6880
jmp 0x97088
leaq -0x40(%rbp), %rax
leaq -0x100(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x96d60
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rdx
movq %rax, %r8
movq -0x20(%rbp), %rax
leaq 0x4c8c6(%rip), %rsi     # 0xe3911
leaq 0x4bf62(%rip), %rcx     # 0xe2fb4
leaq 0x4c8bb(%rip), %r9      # 0xe3914
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, %al
callq 0x94810
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x97084
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
jmp 0x9708f
leaq -0x40(%rbp), %rax
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %rbp
retq
nopl (%rax)