#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 *malloc(int);
int /*<<< orphan*/ printf(char *);
int **get2Dim(int zeile, int spalte) {
  int i;
  int **matrix;
  matrix = malloc(zeile * sizeof(int *));
  if (matrix == NULL) {
    printf("[get2Dim]: Keine Speicherallokierung mehr möglich \n");
    return NULL;
  }
  for (i = 0; i < zeile; i++) {
    *(matrix + i) = malloc(spalte * sizeof(int));
    if (*(matrix + i) == NULL) {
      printf("[get2Dim]: Keine Speicherallokierung mehr möglich \n");
      return NULL;
    }
  }
  return matrix;
}


x86 assembly (clang, -O0):
<get2Dim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1165 <get2Dim+0x45>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11dd <get2Dim+0xbd>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d5 <get2Dim+0xb5>
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11c2 <get2Dim+0xa2>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11dd <get2Dim+0xbd>
jmp    11c7 <get2Dim+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <get2Dim+0x4c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get2Dim>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     116c <get2Dim+0x4c>
mov    %rax,%rbx
test   %r14d,%r14d
jle    117a <get2Dim+0x5a>
shl    $0x2,%r15d
mov    %r14d,%r14d
xor    %ebp,%ebp
mov    %r15d,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
test   %rax,%rax
je     116c <get2Dim+0x4c>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1150 <get2Dim+0x30>
jmp    117a <get2Dim+0x5a>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@str.1 = [52 x i8] c"[get2Dim]: Keine Speicherallokierung mehr m\C3\B6glich \00"
define noalias i32** @get2Dim(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i8* @malloc(i32 %3)
%5 = bitcast i8* %4 to i32**
%6 = icmp eq i8* %4, null
br i1 %6, label %21, label %7
7: ; preds = %2
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %24
9: ; preds = %7
%10 = shl i32 %1, 2
%11 = zext i32 %0 to i64
br label %14
12: ; preds = %14
%13 = icmp eq i64 %20, %11
br i1 %13, label %24, label %14
14: ; preds = %9, %12
%15 = phi i64 [ 0, %9 ], [ %20, %12 ]
%16 = tail call i8* @malloc(i32 %10)
%17 = getelementptr inbounds i32*, i32** %5, i64 %15
%18 = bitcast i32** %17 to i8**
store i8* %16, i8** %18
%19 = icmp eq i8* %16, null
%20 = add nuw nsw i64 %15, 1
br i1 %19, label %21, label %12
21: ; preds = %14, %2
%22 = phi i8* [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.1, i64 0, i64 0), %14 ]
%23 = tail call i32 @puts(i8* dereferenceable(1) %22)
br label %24
24: ; preds = %12, %21, %7
%25 = phi i32** [ %5, %7 ], [ null, %21 ], [ %5, %12 ]
ret i32** %25
}