// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: hts_resize_array_
int hts_resize_array_(size_t item_size, size_t num, size_t size_sz,
                      void *size_in_out, void **ptr_in_out, int flags,
                      const char *func) {
    /* If new_size and item_size are both below this limit, multiplying them
       together can't overflow */
    const size_t safe = (size_t) 1 << (sizeof(size_t) * 4);
    void *new_ptr;
    size_t bytes, new_size;

    new_size = num;
    kroundup_size_t(new_size);
    bytes = item_size * new_size;

    /* Check for overflow.  Both ensure that alloc will fit in alloc_in_out (we
       make the pessimistic assumption that *alloc_in_out is signed), and that
       bytes has not wrapped around. */

    if ((new_size > (((size_t) 1 << (size_sz * 8 - 1)) - 1))
        || (((item_size > safe) || (new_size > safe))
            && bytes / new_size != item_size)) {
        hts_log(HTS_LOG_ERROR, func, "Memory allocation too large");
        errno = ENOMEM;
        return -1;
    }

    new_ptr = realloc(*ptr_in_out, bytes);
    if (new_ptr == NULL) {
        int save_errno = errno;
        hts_log(HTS_LOG_ERROR, func, "%s", strerror(errno));
        errno = save_errno;
        return -1;
    }

    if (flags & HTS_RESIZE_CLEAR) {
        size_t old_size;
        switch (size_sz) {
        case 4: old_size = *((uint32_t *) size_in_out); break;
        case 8: old_size = *((uint64_t *) size_in_out); break;
        default: abort();
        }
        if (new_size > old_size) {
            memset((char *) new_ptr + old_size * item_size, 0,
                   (new_size - old_size) * item_size);
        }
    }

    switch (size_sz) {
    case 4: *((uint32_t *) size_in_out) = new_size; break;
    case 8: *((uint64_t *) size_in_out) = new_size; break;
    default: abort();
    }

    *ptr_in_out = new_ptr;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jbe 0x1e5a5
movq -0x58(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x2, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x4, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x8, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x10, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
shrq $0x20, %rax
orq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
imulq $0x0, -0x58(%rbp), %rdx
addq $0x1, %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
cmpq $0x0, %rcx
seta %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rdx
movl $0x3f, %ecx
subq %rdx, %rcx
shrq %cl, %rax
andq $0x1, %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
jmp 0x1e5a7
jmp 0x1e5a7
movq -0x10(%rbp), %rax
imulq -0x58(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rcx
shlq $0x3, %rcx
subq $0x1, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e60a
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, -0x10(%rbp)
ja 0x1e5f8
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, -0x58(%rbp)
jbe 0x1e638
movq -0x50(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x58(%rbp)
cmpq -0x10(%rbp), %rax
je 0x1e638
movq 0x10(%rbp), %rsi
movl $0x1, %edi
leaq 0xd261e(%rip), %rdx     # 0xf0c38
movb $0x0, %al
callq 0x1b030
callq 0x4050
movl $0xc, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e770
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x4820
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x1e6a7
callq 0x4050
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x4050
movl (%rax), %edi
callq 0x4130
movq -0x78(%rbp), %rsi
movq %rax, %rcx
movl $0x1, %edi
leaq 0xd4370(%rip), %rdx     # 0xf29f4
movb $0x0, %al
callq 0x1b030
movl -0x5c(%rbp), %eax
movl %eax, -0x6c(%rbp)
callq 0x4050
movl -0x6c(%rbp), %ecx
movl %ecx, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e770
movl -0x34(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1e71c
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
subq $0x4, %rax
je 0x1e6ce
jmp 0x1e6c2
movq -0x80(%rbp), %rax
subq $0x8, %rax
je 0x1e6da
jmp 0x1e6e7
movq -0x28(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x68(%rbp)
jmp 0x1e6ec
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x1e6ec
callq 0x4260
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
jbe 0x1e71a
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rax
imulq -0x10(%rbp), %rax
addq %rax, %rdi
movq -0x58(%rbp), %rdx
subq -0x68(%rbp), %rdx
imulq -0x10(%rbp), %rdx
xorl %esi, %esi
callq 0x4250
jmp 0x1e71c
movq -0x20(%rbp), %rax
movq %rax, -0x88(%rbp)
subq $0x4, %rax
je 0x1e73e
jmp 0x1e72f
movq -0x88(%rbp), %rax
subq $0x8, %rax
je 0x1e74c
jmp 0x1e759
movq -0x58(%rbp), %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1e75e
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x1e75e
callq 0x4260
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)