#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
size_t _rndup2pow64(size_t);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
char *realloc(char *, size_t);
int /*<<< orphan*/ stderr;
void cbuf_capacity(char **buf, size_t *sizeptr, size_t len) {
  len++;
  if (*sizeptr < len) {
    *sizeptr = _rndup2pow64(len);
    if ((*buf = realloc(*buf, *sizeptr)) == NULL) {
      fprintf(stderr, "[%s:%i] Out of memory\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/mcveanlab/mccortex/refs/heads/master/"
              "libs/maximal_substrs/stream_buffer.h",
              38);
      exit(EXIT_FAILURE);
    }
  }
}


x86 assembly (clang, -O0):
<cbuf_capacity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmp    -0x18(%rbp),%rax
jae    11dc <cbuf_capacity+0x9c>
mov    -0x18(%rbp),%rdi
call   1040 <_rndup2pow64@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <realloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11d7 <cbuf_capacity+0x97>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
lea    0xe58(%rip),%rdx
mov    $0x26,%ecx
call   1030 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11dc <cbuf_capacity+0x9c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbuf_capacity>:
push   %r14
push   %rbx
push   %rax
add    $0x1,%rdx
cmp    %rdx,(%rsi)
jae    1171 <cbuf_capacity+0x31>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdx,%rdi
call   1040 <_rndup2pow64@plt>
mov    %rax,(%rbx)
mov    (%r14),%rdi
mov    %rax,%rsi
call   1050 <realloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1179 <cbuf_capacity+0x39>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
lea    0xe87(%rip),%rdx
mov    $0x26,%ecx
call   1030 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"[%s:%i] Out of memory\0A\00"
@.str.1 = [164 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mcveanlab/mccortex/refs/heads/master/libs/maximal_substrs/stream_buffer.h\00"
@EXIT_FAILURE = global i32 0
define void @cbuf_capacity(i8** %0, i64* %1, i64 %2) {
%4 = alloca i8**
%5 = alloca i64*
%6 = alloca i64
store i8** %0, i8*** %4
store i64* %1, i64** %5
store i64 %2, i64* %6
%7 = load i64, i64* %6
%8 = add i64 %7, 1
store i64 %8, i64* %6
%9 = load i64*, i64** %5
%10 = load i64, i64* %9
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %3
%14 = load i64, i64* %6
%15 = call i64 @_rndup2pow64(i64 %14)
%16 = load i64*, i64** %5
store i64 %15, i64* %16
%17 = load i8**, i8*** %4
%18 = load i8*, i8** %17
%19 = load i64*, i64** %5
%20 = load i64, i64* %19
%21 = call i8* @realloc(i8* %18, i64 %20)
%22 = load i8**, i8*** %4
store i8* %21, i8** %22
%23 = icmp eq i8* %21, null
br i1 %23, label %24, label %29
24: ; preds = %13
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([164 x i8], [164 x i8]* @.str.1, i64 0, i64 0), i32 38)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %13
br label %30
30: ; preds = %29, %3
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"[%s:%i] Out of memory\0A\00"
@.str.1 = [164 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mcveanlab/mccortex/refs/heads/master/libs/maximal_substrs/stream_buffer.h\00"
@EXIT_FAILURE = global i32 0
define void @cbuf_capacity(i8** nocapture %0, i64* nocapture %1, i64 %2) {
%4 = add i64 %2, 1
%5 = load i64, i64* %1
%6 = icmp ult i64 %5, %4
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = tail call i64 @_rndup2pow64(i64 %4)
store i64 %8, i64* %1
%9 = load i8*, i8** %0
%10 = tail call i8* @realloc(i8* %9, i64 %8)
store i8* %10, i8** %0
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([164 x i8], [164 x i8]* @.str.1, i64 0, i64 0), i32 38)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %7, %3
ret void
}