#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*/ javab_out(int, char *);
void *make_mem(int);
void *realloc(void *, int);
void *more_mem(void *p, int size) {
  if (p) {
    p = realloc(p, ((size > 0) ? size : 1));
    if (!p)
      javab_out(-1, "Out of Memory (re-allocation)");
    return p;
  } else
    return make_mem(size);
}


x86 assembly (clang, -O0):
<more_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ad <more_mem+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1167 <more_mem+0x37>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1174 <more_mem+0x44>
mov    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1174 <more_mem+0x44>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <realloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a0 <more_mem+0x70>
mov    $0xffffffff,%edi
lea    0xe65(%rip),%rsi
call   1030 <javab_out@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <more_mem+0x89>
mov    -0x14(%rbp),%edi
call   1040 <make_mem@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<more_mem>:
test   %rdi,%rdi
je     114e <more_mem+0x1e>
push   %rax
test   %esi,%esi
mov    $0x1,%eax
cmovg  %esi,%eax
mov    %eax,%esi
call   1050 <realloc@plt>
test   %rax,%rax
je     1155 <more_mem+0x25>
pop    %rcx
ret
mov    %esi,%edi
jmp    1040 <make_mem@plt>
lea    0xea4(%rip),%rsi
mov    $0xffffffff,%edi
call   1030 <javab_out@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Out of Memory (re-allocation)\00"
define i8* @more_mem(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = load i32, i32* %5
br label %15
14: ; preds = %8
br label %15
15: ; preds = %14, %12
%16 = phi i32 [ %13, %12 ], [ 1, %14 ]
%17 = call i8* @realloc(i8* %9, i32 %16)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = call i32 @javab_out(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
%23 = load i8*, i8** %4
store i8* %23, i8** %3
br label %27
24: ; preds = %2
%25 = load i32, i32* %5
%26 = call i8* @make_mem(i32 %25)
store i8* %26, i8** %3
br label %27
27: ; preds = %24, %22
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@.str = [30 x i8] c"Out of Memory (re-allocation)\00"
define i8* @more_mem(i8* %0, i32 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp sgt i32 %1, 1
%6 = select i1 %5, i32 %1, i32 1
%7 = tail call i8* @realloc(i8* %0, i32 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = tail call i32 @javab_out(i32 -1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %2
%12 = tail call i8* @make_mem(i32 %1)
br label %13
13: ; preds = %4, %9, %11
%14 = phi i8* [ %12, %11 ], [ null, %9 ], [ %7, %4 ]
ret i8* %14
}