// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: sam_realloc_bam_data
int sam_realloc_bam_data(bam1_t *b, size_t desired)
{
    uint32_t new_m_data;
    uint8_t *new_data;
    new_m_data = desired;
    kroundup32(new_m_data); // next power of 2
    new_m_data += 32; // reduces malloc arena migrations?
    if (new_m_data < desired) {
        errno = ENOMEM; // Not strictly true but we can't store the size
        return -1;
    }
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    if (new_m_data > FUZZ_ALLOC_LIMIT) {
        errno = ENOMEM;
        return -1;
    }
#endif
    if ((bam_get_mempolicy(b) & BAM_USER_OWNS_DATA) == 0) {
        new_data = realloc(b->data, new_m_data);
    } else {
        if ((new_data = malloc(new_m_data)) != NULL) {
            if (b->l_data > 0)
                memcpy(new_data, b->data,
                       b->l_data < b->m_data ? b->l_data : b->m_data);
            bam_set_mempolicy(b, bam_get_mempolicy(b) & (~BAM_USER_OWNS_DATA));
        }
    }
    if (!new_data) return -1;
    b->data = new_data;
    b->m_data = new_m_data;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jbe 0x32e86
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x0, %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x2, %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x4, %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x8, %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shrl $0x10, %eax
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
imull $0x0, -0x1c(%rbp), %edx
addl $0x1, %edx
xorl %ecx, %ecx
subl %edx, %ecx
cmpl $0x0, %ecx
seta %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rdx
movl $0x1f, %ecx
subq %rdx, %rcx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
jmp 0x32e88
jmp 0x32e88
movl -0x1c(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpq -0x18(%rbp), %rax
jae 0x32eb1
callq 0x4050
movl $0xc, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x32f97
movq -0x10(%rbp), %rdi
callq 0x32fa0
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x32edd
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x4820
movq %rax, -0x28(%rbp)
jmp 0x32f6a
movl -0x1c(%rbp), %eax
movl %eax, %edi
callq 0x4650
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x32f68
movq -0x10(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jle 0x32f49
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x44(%rcx), %eax
jae 0x32f2b
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x3c(%rbp)
jmp 0x32f35
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x43b0
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x32fa0
movq -0x48(%rbp), %rdi
movl %eax, %esi
andl $-0x3, %esi
callq 0x32fc0
jmp 0x32f6a
cmpq $0x0, -0x28(%rbp)
jne 0x32f7a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x32f97
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x44(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq