// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: hts_realloc_or_die
HTSLIB_EXPORT
size_t hts_realloc_or_die(size_t n, size_t m, size_t m_sz, size_t size,
                          int clear, void **ptr, const char *func) {
    /* If new_m and 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_m;

    new_m = n;
    kroundup_size_t(new_m);

    bytes = size * new_m;

    /* Check for overflow.  Both ensure that new_m will fit in m (we make the
       pessimistic assumption that m is signed), and that bytes has not
       wrapped around. */
    if (new_m > (((size_t) 1 << (m_sz * 8 - 1)) - 1)
        || ((size > safe || new_m > safe)
            && bytes / new_m != size)) {
        errno = ENOMEM;
        goto die;
    }

    new_ptr = realloc(*ptr, bytes);
    if (new_ptr == NULL) goto die;

    if (clear) {
        if (new_m > m) {
            memset((char *) new_ptr + m * size, 0, (new_m - m) * size);
        }
    }

    *ptr = new_ptr;

    return new_m;

 die:
    hts_log_error("%s", strerror(errno));
    exit(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jbe 0x26b22
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x2, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x4, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x8, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x10, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
shrq $0x20, %rax
orq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
imulq $0x0, -0x50(%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 -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
jmp 0x26b24
jmp 0x26b24
movq -0x20(%rbp), %rax
imulq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
shlq $0x3, %rcx
subq $0x1, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
ja 0x26b87
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, -0x20(%rbp)
ja 0x26b75
movabsq $0x100000000, %rax      # imm = 0x100000000
cmpq %rax, -0x50(%rbp)
jbe 0x26b94
movq -0x48(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x50(%rbp)
cmpq -0x20(%rbp), %rax
je 0x26b94
callq 0x4050
movl $0xc, (%rax)
jmp 0x26bfc
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x4820
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x26bb1
jmp 0x26bfc
cmpl $0x0, -0x24(%rbp)
je 0x26be7
movq -0x50(%rbp), %rax
cmpq -0x10(%rbp), %rax
jbe 0x26be5
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
imulq -0x20(%rbp), %rax
addq %rax, %rdi
movq -0x50(%rbp), %rdx
subq -0x10(%rbp), %rdx
imulq -0x20(%rbp), %rdx
xorl %esi, %esi
callq 0x4250
jmp 0x26be7
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
callq 0x4050
movl (%rax), %edi
callq 0x4130
movq %rax, %rcx
movl $0x1, %edi
leaq 0xca00e(%rip), %rsi     # 0xf0c25
leaq 0xcbdd6(%rip), %rdx     # 0xf29f4
movb $0x0, %al
callq 0x1b030
movl $0x1, %edi
callq 0x45c0
nop