#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 */
void __xassert_failed(char *, char *, int, char *);
char *slurm_xmalloc(int, char *, int, char *);
int /*<<< orphan*/ slurm_xrealloc(void **, int, char *, int, char *);
int slurm_xsize(void *, char *, int, char *);
int strlen(char *);
void makespace(char **str, int needed) {
  if (*str == NULL)
    *str =
        slurm_xmalloc(needed + 1,
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/"
                      "debian-slurm/refs/heads/master/src/common/xstring.c",
                      107, "");
  else {
    int actual_size;
    int used = strlen(*str) + 1;
    int min_new_size = used + needed;
    int cur_size =
        slurm_xsize((void *)*str,
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/"
                    "debian-slurm/refs/heads/master/src/common/xstring.c",
                    112, "");
    if (min_new_size > cur_size) {
      int new_size = min_new_size;
      if (new_size < (cur_size + 64))
        new_size = cur_size + 64;
      if (new_size < (cur_size * 2))
        new_size = cur_size * 2;
      slurm_xrealloc((void **)&(*str), new_size,
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/"
                     "debian-slurm/refs/heads/master/src/common/xstring.c",
                     120, "");
      actual_size =
          slurm_xsize((void *)*str,
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/"
                      "debian-slurm/refs/heads/master/src/common/xstring.c",
                      121, "");
      (void)({
        (actual_size == new_size)
            ? ((void)0)
            : __xassert_failed(
                  "actual_size == new_size",
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/"
                  "debian-slurm/refs/heads/master/src/common/xstring.c",
                  122, "");
      });
    }
  }
}


x86 assembly (clang, -O0):
<makespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    119a <makespace+0x4a>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
lea    0xe86(%rip),%rsi
mov    $0x6b,%edx
lea    0xf17(%rip),%rcx
call   1040 <slurm_xmalloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    1298 <makespace+0x148>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x70,%edx
lea    0xece(%rip),%rcx
call   1070 <slurm_xsize@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1293 <makespace+0x143>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x40,%ecx
cmp    %ecx,%eax
jge    1203 <makespace+0xb3>
mov    -0x1c(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    121d <makespace+0xcd>
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    0xdd5(%rip),%rdx
mov    $0x78,%ecx
lea    0xe66(%rip),%r8
call   1050 <slurm_xrealloc@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb6(%rip),%rsi
mov    $0x79,%edx
lea    0xe47(%rip),%rcx
call   1070 <slurm_xsize@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    126f <makespace+0x11f>
jmp    128e <makespace+0x13e>
lea    0xe28(%rip),%rdi
lea    0xd83(%rip),%rsi
mov    $0x7a,%edx
lea    0xe14(%rip),%rcx
call   1060 <__xassert_failed@plt>
jmp    1293 <makespace+0x143>
jmp    1298 <makespace+0x148>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makespace>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1209 <makespace+0xb9>
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%ebp
add    $0x1,%ebp
mov    (%r14),%rdi
lea    0xe82(%rip),%rsi
lea    0xf18(%rip),%rcx
mov    $0x70,%edx
call   1070 <slurm_xsize@plt>
cmp    %eax,%ebp
jle    1229 <makespace+0xd9>
mov    %eax,%ebx
lea    0x40(%rbx),%eax
cmp    %eax,%ebp
cmovl  %eax,%ebp
add    %ebx,%ebx
cmp    %ebx,%ebp
cmovge %ebp,%ebx
lea    0xe51(%rip),%r15
lea    0xee7(%rip),%r12
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    $0x78,%ecx
mov    %r12,%r8
call   1050 <slurm_xrealloc@plt>
mov    (%r14),%rdi
mov    %r15,%rsi
mov    $0x79,%edx
mov    %r12,%rcx
call   1070 <slurm_xsize@plt>
cmp    %ebx,%eax
je     1229 <makespace+0xd9>
lea    0xeb5(%rip),%rdi
lea    0xe10(%rip),%rsi
lea    0xea6(%rip),%rcx
mov    $0x7a,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <__xassert_failed@plt>
add    $0x1,%ebx
lea    0xded(%rip),%rsi
lea    0xe83(%rip),%rcx
mov    %ebx,%edi
mov    $0x6b,%edx
call   1040 <slurm_xmalloc@plt>
mov    %rax,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/src/common/xstring.c\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [24 x i8] c"actual_size == new_size\00"
define void @makespace(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
%16 = call i8* @slurm_xmalloc(i32 %15, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 107, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8**, i8*** %3
store i8* %16, i8** %17
br label %63
18: ; preds = %2
%19 = load i8**, i8*** %3
%20 = load i8*, i8** %19
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = add nsw i32 %23, %24
store i32 %25, i32* %7
%26 = load i8**, i8*** %3
%27 = load i8*, i8** %26
%28 = call i32 @slurm_xsize(i8* %27, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 112, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %62
32: ; preds = %18
%33 = load i32, i32* %7
store i32 %33, i32* %9
%34 = load i32, i32* %9
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 64
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 64
store i32 %40, i32* %9
br label %41
41: ; preds = %38, %32
%42 = load i32, i32* %9
%43 = load i32, i32* %8
%44 = mul nsw i32 %43, 2
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i32, i32* %8
%48 = mul nsw i32 %47, 2
store i32 %48, i32* %9
br label %49
49: ; preds = %46, %41
%50 = load i8**, i8*** %3
%51 = load i32, i32* %9
%52 = call i32 @slurm_xrealloc(i8** %50, i32 %51, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 120, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%53 = load i8**, i8*** %3
%54 = load i8*, i8** %53
%55 = call i32 @slurm_xsize(i8* %54, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 121, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %55, i32* %5
%56 = load i32, i32* %5
%57 = load i32, i32* %9
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %60
59: ; preds = %49
br label %61
60: ; preds = %49
br label %61
61: ; preds = %60, %59
br label %62
62: ; preds = %61, %18
br label %63
63: ; preds = %62, %13
ret void
}

LLVM IR (-O2):
@.str = [158 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Q-Leap-Networks/debian-slurm/refs/heads/master/src/common/xstring.c\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [24 x i8] c"actual_size == new_size\00"
define void @makespace(i8** %0, i32 %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = add nsw i32 %1, 1
%7 = tail call i8* @slurm_xmalloc(i32 %6, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 107, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i8* %7, i8** %0
br label %27
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %3)
%10 = add i32 %1, 1
%11 = add i32 %10, %9
%12 = load i8*, i8** %0
%13 = tail call i32 @slurm_xsize(i8* %12, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 112, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp sgt i32 %11, %13
br i1 %14, label %15, label %27
15: ; preds = %8
%16 = add nsw i32 %13, 64
%17 = icmp slt i32 %11, %16
%18 = select i1 %17, i32 %16, i32 %11
%19 = shl nsw i32 %13, 1
%20 = icmp slt i32 %18, %19
%21 = select i1 %20, i32 %19, i32 %18
%22 = tail call i32 @slurm_xrealloc(i8** %0, i32 %21, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 120, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%23 = load i8*, i8** %0
%24 = tail call i32 @slurm_xsize(i8* %23, i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 121, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32 %24, %21
br i1 %25, label %27, label %26
26: ; preds = %15
tail call void @__xassert_failed(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([158 x i8], [158 x i8]* @.str, i64 0, i64 0), i32 122, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %8, %15, %26, %5
ret void
}