#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
char *speicher_reservieren_char_array_malloc(char *, int);
char **speicher_reservieren_2dim_char_array_malloc(int zeilen, int spalten,
                                                   char **array) {
  array = (char **)malloc(zeilen * sizeof(char *));
  if (NULL == array) {
    printf("Kein Speicher fuer die Zeilen...\n");
  } else {
    for (int i = 0; i < zeilen; i++) {
      array[i] = speicher_reservieren_char_array_malloc(array[i], spalten);
    }
  }
  return array;
}


x86 assembly (clang, -O0):
<speicher_reservieren_2dim_char_array_malloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1172 <speicher_reservieren_2dim_char_array_malloc+0x42>
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
jmp    11bb <speicher_reservieren_2dim_char_array_malloc+0x8b>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b6 <speicher_reservieren_2dim_char_array_malloc+0x86>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%esi
call   1030 <speicher_reservieren_char_array_malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <speicher_reservieren_2dim_char_array_malloc+0x49>
jmp    11bb <speicher_reservieren_2dim_char_array_malloc+0x8b>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<speicher_reservieren_2dim_char_array_malloc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     117b <speicher_reservieren_2dim_char_array_malloc+0x4b>
test   %r14d,%r14d
jle    1187 <speicher_reservieren_2dim_char_array_malloc+0x57>
mov    %r14d,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%rbx,%rbp,8),%rdi
mov    %r15d,%esi
call   1040 <speicher_reservieren_char_array_malloc@plt>
mov    %rax,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1160 <speicher_reservieren_2dim_char_array_malloc+0x30>
jmp    1187 <speicher_reservieren_2dim_char_array_malloc+0x57>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
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_reservieren_2dim_char_array_malloc(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8**
store i8** %13, i8*** %6
%14 = load i8**, i8*** %6
%15 = icmp eq i8** null, %14
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %39
18: ; preds = %3
store i32 0, i32* %7
br label %19
19: ; preds = %35, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load i8**, i8*** %6
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* %5
%30 = call i8* @speicher_reservieren_char_array_malloc(i8* %28, i32 %29)
%31 = load i8**, i8*** %6
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
store i8* %30, i8** %34
br label %35
35: ; preds = %23
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %19
38: ; preds = %19
br label %39
39: ; preds = %38, %16
%40 = load i8**, i8*** %6
ret i8** %40
}

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