// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/vcf.c
// Function: bcf_hdr_add_sample_len
static int bcf_hdr_add_sample_len(bcf_hdr_t *h, const char *s, size_t len)
{
    const char *ss = s;
    while ( *ss && isspace_c(*ss) && ss - s < len) ss++;
    if ( !*ss || ss - s == len)
    {
        hts_log_error("Empty sample name: trailing spaces/tabs in the header line?");
        return -1;
    }

    vdict_t *d = (vdict_t*)h->dict[BCF_DT_SAMPLE];
    int ret;
    char *sdup = malloc(len + 1);
    if (!sdup) return -1;
    memcpy(sdup, s, len);
    sdup[len] = 0;

    // Ensure space is available in h->samples
    size_t n = kh_size(d);
    char **new_samples = realloc(h->samples, sizeof(char*) * (n + 1));
    if (!new_samples) {
        free(sdup);
        return -1;
    }
    h->samples = new_samples;

    int k = kh_put(vdict, d, sdup, &ret);
    if (ret < 0) {
        free(sdup);
        return -1;
    }
    if (ret) { // absent
        kh_val(d, k) = bcf_idinfo_def;
        kh_val(d, k).id = n;
    } else {
        hts_log_error("Duplicated sample name '%s'", sdup);
        free(sdup);
        return -1;
    }
    h->samples[n] = sdup;
    h->dirty = 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movzbl (%rsi), %r12d
testq %r12, %r12
sete %bpl
je 0x2ba29
callq 0x4510
testq %r14, %r14
je 0x2ba29
movq (%rax), %rcx
movzwl (%rcx,%r12,2), %edx
movq %r15, %rax
andl $0x2000, %edx           # imm = 0x2000
je 0x2ba2c
movl $0x1, %edx
movq %rdx, %rax
movzbl (%r15,%rdx), %edx
testq %rdx, %rdx
sete %bpl
je 0x2ba24
cmpq %r14, %rax
jae 0x2ba24
movzwl (%rcx,%rdx,2), %esi
andl $0x2000, %esi           # imm = 0x2000
leaq 0x1(%rax), %rdx
testw %si, %si
jne 0x2b9fb
addq %r15, %rax
jmp 0x2ba2c
movq %r15, %rax
subq %r15, %rax
cmpq %r14, %rax
setne %al
notb %bpl
testb %al, %bpl
jne 0x2ba61
leaq 0x83a49(%rip), %rsi     # 0xaf48d
leaq 0x83a59(%rip), %rdx     # 0xaf4a4
movl $0x1, %edi
xorl %eax, %eax
callq 0x9774
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x2bb47
movq 0x38(%rbx), %r13
leaq 0x1(%r14), %rdi
callq 0x46a0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x2bb47
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x43c0
movb $0x0, (%r12,%r14)
movl 0x4(%r13), %r15d
movq 0x40(%rbx), %rdi
leaq 0x8(,%r15,8), %rsi
callq 0x4860
testq %rax, %rax
je 0x2bb3f
movq %rax, 0x40(%rbx)
leaq 0x4(%rsp), %r14
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x3e804
cmpl $0x0, (%r14)
js 0x2bb3f
je 0x2bb22
movq 0x20(%r13), %rcx
cltq
imulq $0x38, %rax, %rax
movups 0x824f8(%rip), %xmm0    # 0xadfd8
movups %xmm0, 0x20(%rcx,%rax)
movups 0x824dc(%rip), %xmm0    # 0xadfc8
movups %xmm0, 0x10(%rcx,%rax)
movups 0x824c0(%rip), %xmm0    # 0xadfb8
movups %xmm0, (%rcx,%rax)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, 0x30(%rcx,%rax)
movq 0x20(%r13), %rcx
movl %r15d, 0x30(%rcx,%rax)
movq 0x40(%rbx), %rax
movq %r12, (%rax,%r15,8)
movl $0x1, 0x54(%rbx)
xorl %ebp, %ebp
jmp 0x2bb47
leaq 0x83964(%rip), %rsi     # 0xaf48d
leaq 0x839b0(%rip), %rdx     # 0xaf4e0
movl $0x1, %edi
movq %r12, %rcx
xorl %eax, %eax
callq 0x9774
movq %r12, %rdi
callq 0x45c0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq