#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*/ memoryInit(char **, unsigned int);
scalar_t__ realloc(char **, unsigned int);
bool reallocate2D(char ***values, unsigned int *memory) {
  *values = (char **)realloc(*values, (*memory + *memory) * sizeof(char *));
  if (!*values) {
    return false;
  }
  memoryInit(*values, *memory);
  *memory += *memory;
  return true;
}


x86 assembly (clang, -O0):
<reallocate2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
add    (%rcx),%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1174 <reallocate2D+0x54>
movl   $0x0,-0x4(%rbp)
jmp    119b <reallocate2D+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1040 <memoryInit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reallocate2D>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    (%rsi),%esi
shl    $0x4,%esi
call   1030 <realloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1154 <reallocate2D+0x34>
mov    (%r14),%esi
mov    %rax,%rdi
call   1040 <memoryInit@plt>
shll   (%r14)
mov    $0x1,%eax
jmp    1156 <reallocate2D+0x36>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @reallocate2D(i8*** %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8***
%5 = alloca i32*
store i8*** %0, i8**** %4
store i32* %1, i32** %5
%6 = load i8***, i8**** %4
%7 = load i8**, i8*** %6
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = add i32 %9, %11
%13 = zext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call i64 @realloc(i8** %7, i32 %15)
%17 = inttoptr i64 %16 to i8**
%18 = load i8***, i8**** %4
store i8** %17, i8*** %18
%19 = load i8***, i8**** %4
%20 = load i8**, i8*** %19
%21 = icmp ne i8** %20, null
br i1 %21, label %23, label %22
22: ; preds = %2
store i32 0, i32* %3
br label %34
23: ; preds = %2
%24 = load i8***, i8**** %4
%25 = load i8**, i8*** %24
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = call i32 @memoryInit(i8** %25, i32 %27)
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = load i32*, i32** %5
%32 = load i32, i32* %31
%33 = add i32 %32, %30
store i32 %33, i32* %31
store i32 1, i32* %3
br label %34
34: ; preds = %23, %22
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @reallocate2D(i8*** nocapture %0, i32* nocapture %1) {
%3 = load i8**, i8*** %0
%4 = load i32, i32* %1
%5 = shl i32 %4, 4
%6 = tail call i64 @realloc(i8** %3, i32 %5)
%7 = inttoptr i64 %6 to i8**
store i8** %7, i8*** %0
%8 = icmp eq i64 %6, 0
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = load i32, i32* %1
%11 = tail call i32 @memoryInit(i8** %7, i32 %10)
%12 = load i32, i32* %1
%13 = shl i32 %12, 1
store i32 %13, i32* %1
br label %14
14: ; preds = %2, %9
%15 = phi i32 [ 1, %9 ], [ 0, %2 ]
ret i32 %15
}