#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*/ printf(char *);
scalar_t__ realloc(char **, int);
char *speicher_reservieren_char_array_malloc(char *, int);
char **speicher_neu_reservieren_2dim_char_array_realloc(int alte_zeilen,
                                                        int neue_zeilen,
                                                        int spalten,
                                                        char **array) {
  array = (char **)realloc(array, (neue_zeilen + alte_zeilen) * sizeof(char *));
  if (NULL == array) {
    printf("Kein Speicher fuer die Zeilen...\n");
  } else {
    for (char **p = (array + alte_zeilen);
         p < array + (alte_zeilen + neue_zeilen); p++) {
      *p = speicher_reservieren_char_array_malloc(*p, spalten);
    }
  }
  return array;
}


x86 assembly (clang, -O0):
<speicher_neu_reservieren_2dim_char_array_realloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    117d <speicher_neu_reservieren_2dim_char_array_realloc+0x4d>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
jmp    11e0 <speicher_neu_reservieren_2dim_char_array_realloc+0xb0>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%edx
add    -0x8(%rbp),%edx
movslq %edx,%rdx
shl    $0x3,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    11db <speicher_neu_reservieren_2dim_char_array_realloc+0xab>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0xc(%rbp),%esi
call   1030 <speicher_reservieren_char_array_malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1190 <speicher_neu_reservieren_2dim_char_array_realloc+0x60>
jmp    11e0 <speicher_neu_reservieren_2dim_char_array_realloc+0xb0>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speicher_neu_reservieren_2dim_char_array_realloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %esi,%r12d
mov    %edi,%r15d
lea    (%r12,%r15,1),%ebx
lea    0x0(,%rbx,8),%esi
mov    %rcx,%rdi
call   1050 <realloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     119b <speicher_neu_reservieren_2dim_char_array_realloc+0x6b>
test   %r12d,%r12d
jle    11a7 <speicher_neu_reservieren_2dim_char_array_realloc+0x77>
movslq %ebx,%rax
lea    (%r14,%rax,8),%rbx
movslq %r15d,%rax
lea    (%r14,%rax,8),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%rbp),%rdi
mov    %r13d,%esi
call   1040 <speicher_reservieren_char_array_malloc@plt>
mov    %rax,0x0(%rbp)
add    $0x8,%rbp
cmp    %rbx,%rbp
jb     1180 <speicher_neu_reservieren_2dim_char_array_realloc+0x50>
jmp    11a7 <speicher_neu_reservieren_2dim_char_array_realloc+0x77>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Kein Speicher fuer die Zeilen...\0A\00"
define i8** @speicher_neu_reservieren_2dim_char_array_realloc(i32 %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8**
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
%10 = load i8**, i8*** %8
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = add nsw i32 %11, %12
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 8
%16 = trunc i64 %15 to i32
%17 = call i64 @realloc(i8** %10, i32 %16)
%18 = inttoptr i64 %17 to i8**
store i8** %18, i8*** %8
%19 = load i8**, i8*** %8
%20 = icmp eq i8** null, %19
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %47
23: ; preds = %4
%24 = load i8**, i8*** %8
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
store i8** %27, i8*** %9
br label %28
28: ; preds = %43, %23
%29 = load i8**, i8*** %9
%30 = load i8**, i8*** %8
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %30, i64 %34
%36 = icmp ult i8** %29, %35
br i1 %36, label %37, label %46
37: ; preds = %28
%38 = load i8**, i8*** %9
%39 = load i8*, i8** %38
%40 = load i32, i32* %7
%41 = call i8* @speicher_reservieren_char_array_malloc(i8* %39, i32 %40)
%42 = load i8**, i8*** %9
store i8* %41, i8** %42
br label %43
43: ; preds = %37
%44 = load i8**, i8*** %9
%45 = getelementptr inbounds i8*, i8** %44, i32 1
store i8** %45, i8*** %9
br label %28
46: ; preds = %28
br label %47
47: ; preds = %46, %21
%48 = load i8**, i8*** %8
ret i8** %48
}

LLVM IR (-O2):
@str = [33 x i8] c"Kein Speicher fuer die Zeilen...\00"
define i8** @speicher_neu_reservieren_2dim_char_array_realloc(i32 %0, i32 %1, i32 %2, i8** %3) {
%5 = add nsw i32 %1, %0
%6 = shl i32 %5, 3
%7 = tail call i64 @realloc(i8** %3, i32 %6)
%8 = inttoptr i64 %7 to i8**
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %25
12: ; preds = %4
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds i8*, i8** %8, i64 %13
%15 = icmp sgt i32 %1, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = sext i32 %0 to i64
%18 = getelementptr inbounds i8*, i8** %8, i64 %17
br label %19
19: ; preds = %16, %19
%20 = phi i8** [ %23, %19 ], [ %18, %16 ]
%21 = load i8*, i8** %20
%22 = tail call i8* @speicher_reservieren_char_array_malloc(i8* %21, i32 %2)
store i8* %22, i8** %20
%23 = getelementptr inbounds i8*, i8** %20, i64 1
%24 = icmp ult i8** %23, %14
br i1 %24, label %19, label %25
25: ; preds = %19, %12, %10
ret i8** %8
}