// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: bam_set_qname
int bam_set_qname(bam1_t *rec, const char *qname)
{
    if (!rec) return -1;
    if (!qname || !*qname) return -1;

    size_t old_len = rec->core.l_qname;
    size_t new_len = strlen(qname) + 1;
    if (new_len < 1 || new_len > 255) return -1;

    int extranul = (new_len%4 != 0) ? (4 - new_len%4) : 0;

    size_t new_data_len = rec->l_data - old_len + new_len + extranul;
    if (realloc_bam_data(rec, new_data_len) < 0) return -1;

    // Make room
    if (new_len + extranul != rec->core.l_qname)
        memmove(rec->data + new_len + extranul, rec->data + rec->core.l_qname, rec->l_data - rec->core.l_qname);
    // Copy in new name and pad if needed
    memcpy(rec->data, qname, new_len);
    int n;
    for (n = 0; n < extranul; n++) rec->data[new_len + n] = '\0';

    rec->l_data = new_data_len;
    rec->core.l_qname = new_len + extranul;
    rec->core.l_extranul = extranul;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x34bd3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x34d6a
cmpq $0x0, -0x18(%rbp)
je 0x34be3
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x34bef
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x34d6a
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x41b0
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x1, -0x28(%rbp)
jb 0x34c1d
cmpq $0xff, -0x28(%rbp)
jbe 0x34c29
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x34d6a
movq -0x28(%rbp), %rax
andq $0x3, %rax
cmpq $0x0, %rax
je 0x34c4d
movq -0x28(%rbp), %rcx
andq $0x3, %rcx
movl $0x4, %eax
subq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x34c55
xorl %eax, %eax
movq %rax, -0x48(%rbp)
jmp 0x34c55
movq -0x48(%rbp), %rax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movslq 0x40(%rax), %rax
subq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x33110
cmpl $0x0, %eax
jge 0x34c95
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x34d6a
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpq %rcx, %rax
je 0x34cee
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
addq -0x28(%rbp), %rdi
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %eax
cltq
addq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x10(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
subl %ecx, %eax
movslq %eax, %rdx
callq 0x4810
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x43b0
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x34d34
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
addq %rdx, %rcx
movb $0x0, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x34d0a
movq -0x38(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x12(%rax)
movl -0x2c(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0xf(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)