#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 EXIT_FAILURE;
int EXIT_SUCCESS;
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i, j, zeile, spalte;
  int **matrix;
  for (i = 0; i < 100; i++) {
    zeile = i;
    spalte = i;
    matrix = malloc(zeile * sizeof(int *));
    if (matrix == NULL) {
      printf("Error in 1\n");
      return EXIT_FAILURE;
    }
    for (i = 0; i < zeile; i++) {
      matrix[i] = malloc(spalte * sizeof(int));
      if (matrix[i] == NULL) {
        printf("Error in 2\n");
        return EXIT_FAILURE;
      }
    }
    printf("Hier NR a\n");
    for (i = 0; i < zeile; i++)
      for (j = 0; j < spalte; j++) {
        printf("i = %d, j = %d\n", i, j);
        matrix[i][j] = i + j;
      }
    printf("Hier NR b\n");
    for (i = 0; i < zeile; i++) {
      for (j = 0; j < spalte; j++)
        printf("%d ", matrix[i][j]);
      printf("\n");
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    1313 <main+0x1f3>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1189 <main+0x69>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    131f <main+0x1ff>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ff <main+0xdf>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11ec <main+0xcc>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    131f <main+0x1ff>
jmp    11f1 <main+0xd1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x70>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1281 <main+0x161>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126e <main+0x14e>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edx
add    -0xc(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1227 <main+0x107>
jmp    1273 <main+0x153>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1214 <main+0xf4>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1300 <main+0x1e0>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12e4 <main+0x1c4>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12a9 <main+0x189>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1296 <main+0x176>
jmp    1305 <main+0x1e5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
mov    0x2cbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed6(%rip),%r12
mov    0x2e7f(%rip),%rbp
xor    %ebx,%ebx
lea    0x0(,%rbx,8),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     12cf <main+0x18f>
mov    %ebx,%r15d
test   %r15d,%r15d
jle    1270 <main+0x130>
mov    %rax,%r13
lea    0x0(,%r15,4),%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14d,%edi
call   1060 <malloc@plt>
mov    %rax,0x0(%r13,%rbx,8)
test   %rax,%rax
je     12ae <main+0x16e>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <main+0x50>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
test   %r15d,%r15d
jle    127c <main+0x13c>
xor    %r14d,%r14d
lea    0xe32(%rip),%rbx
xchg   %ax,%ax
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%r13,%r14,8),%rax
lea    (%r14,%r12,1),%ecx
mov    %ecx,(%rax,%r12,4)
add    $0x1,%r12
cmp    %r12,%r15
jne    11e0 <main+0xa0>
add    $0x1,%r14
cmp    %r15,%r14
jne    11d0 <main+0x90>
lea    0xe08(%rip),%rdi
call   1040 <puts@plt>
test   %r15d,%r15d
jle    128d <main+0x14d>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%r14,8),%rbx
xor    %ebp,%ebp
lea    0xdd2(%rip),%r12
xchg   %ax,%ax
mov    (%rbx,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1240 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r15,%r14
jne    1230 <main+0xf0>
jmp    1290 <main+0x150>
nopl   0x0(%rax,%rax,1)
lea    0xd9d(%rip),%rdi
call   1040 <puts@plt>
lea    0xd9b(%rip),%rdi
call   1040 <puts@plt>
xor    %r15d,%r15d
jmp    129e <main+0x15e>
xor    %r15d,%r15d
lea    0xd91(%rip),%r12
mov    0x2d3a(%rip),%rbp
lea    0x1(%r15),%ebx
cmp    $0x63,%r15d
jl     115b <main+0x1b>
jmp    12bd <main+0x17d>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    0x2d23(%rip),%rbp
mov    0x0(%rbp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd5d(%rip),%rdi
jmp    12b1 <main+0x171>

LLVM IR (-O0):
@.str = [12 x i8] c"Error in 1\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"Error in 2\0A\00"
@.str.2 = [11 x i8] c"Hier NR a\0A\00"
@.str.3 = [16 x i8] c"i = %d, j = %d\0A\00"
@.str.4 = [11 x i8] c"Hier NR b\0A\00"
@.str.5 = [4 x i8] c"%d \00"
@.str.6 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32**
store i32 0, i32* %1
store i32 0, i32* %2
br label %7
7: ; preds = %117, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %120
10: ; preds = %7
%11 = load i32, i32* %2
store i32 %11, i32* %4
%12 = load i32, i32* %2
store i32 %12, i32* %5
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 8
%16 = trunc i64 %15 to i32
%17 = call i8* @malloc(i32 %16)
%18 = bitcast i8* %17 to i32**
store i32** %18, i32*** %6
%19 = load i32**, i32*** %6
%20 = icmp eq i32** %19, null
br i1 %20, label %21, label %24
21: ; preds = %10
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %1
br label %122
24: ; preds = %10
store i32 0, i32* %2
br label %25
25: ; preds = %50, %24
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %53
29: ; preds = %25
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 4
%33 = trunc i64 %32 to i32
%34 = call i8* @malloc(i32 %33)
%35 = bitcast i8* %34 to i32*
%36 = load i32**, i32*** %6
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
store i32* %35, i32** %39
%40 = load i32**, i32*** %6
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32*, i32** %40, i64 %42
%44 = load i32*, i32** %43
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %49
46: ; preds = %29
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
store i32 %48, i32* %1
br label %122
49: ; preds = %29
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %25
53: ; preds = %25
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %55
55: ; preds = %83, %53
%56 = load i32, i32* %2
%57 = load i32, i32* %4
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %86
59: ; preds = %55
store i32 0, i32* %3
br label %60
60: ; preds = %79, %59
%61 = load i32, i32* %3
%62 = load i32, i32* %5
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %82
64: ; preds = %60
%65 = load i32, i32* %2
%66 = load i32, i32* %3
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %66)
%68 = load i32, i32* %2
%69 = load i32, i32* %3
%70 = add nsw i32 %68, %69
%71 = load i32**, i32*** %6
%72 = load i32, i32* %2
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32*, i32** %71, i64 %73
%75 = load i32*, i32** %74
%76 = load i32, i32* %3
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %75, i64 %77
store i32 %70, i32* %78
br label %79
79: ; preds = %64
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 1
store i32 %81, i32* %3
br label %60
82: ; preds = %60
br label %83
83: ; preds = %82
%84 = load i32, i32* %2
%85 = add nsw i32 %84, 1
store i32 %85, i32* %2
br label %55
86: ; preds = %55
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %88
88: ; preds = %113, %86
%89 = load i32, i32* %2
%90 = load i32, i32* %4
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %116
92: ; preds = %88
store i32 0, i32* %3
br label %93
93: ; preds = %108, %92
%94 = load i32, i32* %3
%95 = load i32, i32* %5
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %111
97: ; preds = %93
%98 = load i32**, i32*** %6
%99 = load i32, i32* %2
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i32*, i32** %98, i64 %100
%102 = load i32*, i32** %101
%103 = load i32, i32* %3
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32, i32* %102, i64 %104
%106 = load i32, i32* %105
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %106)
br label %108
108: ; preds = %97
%109 = load i32, i32* %3
%110 = add nsw i32 %109, 1
store i32 %110, i32* %3
br label %93
111: ; preds = %93
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %113
113: ; preds = %111
%114 = load i32, i32* %2
%115 = add nsw i32 %114, 1
store i32 %115, i32* %2
br label %88
116: ; preds = %88
br label %117
117: ; preds = %116
%118 = load i32, i32* %2
%119 = add nsw i32 %118, 1
store i32 %119, i32* %2
br label %7
120: ; preds = %7
%121 = load i32, i32* @EXIT_SUCCESS
store i32 %121, i32* %1
br label %122
122: ; preds = %120, %46, %21
%123 = load i32, i32* %1
ret i32 %123
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.3 = [16 x i8] c"i = %d, j = %d\0A\00"
@.str.5 = [4 x i8] c"%d \00"
@EXIT_SUCCESS = global i32 0
@str = [10 x i8] c"Hier NR a\00"
@str.7 = [10 x i8] c"Hier NR b\00"
@str.8 = [11 x i8] c"Error in 2\00"
@str.9 = [11 x i8] c"Error in 1\00"
define i32 @main() {
br label %1
1: ; preds = %0, %65
%2 = phi i32 [ 0, %0 ], [ %67, %65 ]
%3 = shl i32 %2, 3
%4 = tail call i8* @malloc(i32 %3)
%5 = bitcast i8* %4 to i32**
%6 = icmp eq i8* %4, null
br i1 %6, label %69, label %7
7: ; preds = %1
%8 = icmp sgt i32 %2, 0
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %44
11: ; preds = %7
%12 = shl i32 %2, 2
%13 = zext i32 %2 to i64
br label %16
14: ; preds = %16
%15 = icmp eq i64 %22, %13
br i1 %15, label %23, label %16
16: ; preds = %11, %14
%17 = phi i64 [ 0, %11 ], [ %22, %14 ]
%18 = tail call i8* @malloc(i32 %12)
%19 = getelementptr inbounds i32*, i32** %5, i64 %17
%20 = bitcast i32** %19 to i8**
store i8* %18, i8** %20
%21 = icmp eq i8* %18, null
%22 = add nuw nsw i64 %17, 1
br i1 %21, label %69, label %14
23: ; preds = %14
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br i1 %8, label %25, label %44
25: ; preds = %23
%26 = zext i32 %2 to i64
br label %27
27: ; preds = %41, %25
%28 = phi i64 [ 0, %25 ], [ %42, %41 ]
%29 = getelementptr inbounds i32*, i32** %5, i64 %28
%30 = trunc i64 %28 to i32
br label %31
31: ; preds = %27, %31
%32 = phi i64 [ 0, %27 ], [ %39, %31 ]
%33 = trunc i64 %32 to i32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %33)
%35 = add nuw nsw i64 %32, %28
%36 = load i32*, i32** %29
%37 = getelementptr inbounds i32, i32* %36, i64 %32
%38 = trunc i64 %35 to i32
store i32 %38, i32* %37
%39 = add nuw nsw i64 %32, 1
%40 = icmp eq i64 %39, %26
br i1 %40, label %41, label %31
41: ; preds = %31
%42 = add nuw nsw i64 %28, 1
%43 = icmp eq i64 %42, %26
br i1 %43, label %46, label %27
44: ; preds = %9, %23
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0))
br label %65
46: ; preds = %41
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0))
br i1 %8, label %48, label %65
48: ; preds = %46
%49 = zext i32 %2 to i64
br label %50
50: ; preds = %61, %48
%51 = phi i64 [ 0, %48 ], [ %63, %61 ]
%52 = getelementptr inbounds i32*, i32** %5, i64 %51
%53 = load i32*, i32** %52
br label %54
54: ; preds = %50, %54
%55 = phi i64 [ 0, %50 ], [ %59, %54 ]
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = load i32, i32* %56
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %57)
%59 = add nuw nsw i64 %55, 1
%60 = icmp eq i64 %59, %49
br i1 %60, label %61, label %54
61: ; preds = %54
%62 = tail call i32 @putchar(i32 10)
%63 = add nuw nsw i64 %51, 1
%64 = icmp eq i64 %63, %49
br i1 %64, label %65, label %50
65: ; preds = %61, %44, %46
%66 = phi i32 [ 0, %46 ], [ 0, %44 ], [ %2, %61 ]
%67 = add nuw nsw i32 %66, 1
%68 = icmp slt i32 %66, 99
br i1 %68, label %1, label %72
69: ; preds = %1, %16
%70 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0), %16 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.9, i64 0, i64 0), %1 ]
%71 = tail call i32 @puts(i8* dereferenceable(1) %70)
br label %72
72: ; preds = %65, %69
%73 = phi i32* [ @EXIT_FAILURE, %69 ], [ @EXIT_SUCCESS, %65 ]
%74 = load i32, i32* %73
ret i32 %74
}