#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*/ malloc2dint(int ***, int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int **mat = NULL;
  malloc2dint(&mat, 5, 5);
  mat[0][0] = 1;
  mat[1][0] = 2;
  mat[2][0] = 3;
  mat[3][0] = 4;
  mat[4][0] = 6;
  int *element = &mat[0][0];
  int cnt = 0;
  while (cnt < 25) {
    printf("%d\n", *element);
    element++;
    cnt++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x5,%edx
mov    %edx,%esi
call   1040 <malloc2dint@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x6,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x19,-0x1c(%rbp)
jge    11d4 <main+0xb4>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119e <main+0x7e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x5,%edx
call   1040 <malloc2dint@plt>
mov    (%rsp),%rax
mov    (%rax),%rbx
movl   $0x1,(%rbx)
mov    0x8(%rax),%rcx
movl   $0x2,(%rcx)
mov    0x10(%rax),%rcx
movl   $0x3,(%rcx)
mov    0x18(%rax),%rcx
movl   $0x4,(%rcx)
mov    0x20(%rax),%rax
movl   $0x6,(%rax)
mov    (%rbx),%esi
lea    0xe84(%rip),%r14
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x28(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x2c(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x30(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x34(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x38(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x3c(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x40(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x44(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x48(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x4c(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x50(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x54(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x58(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x5c(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x60(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32** null, i32*** %2
%5 = call i32 @malloc2dint(i32*** %2, i32 5, i32 5)
%6 = load i32**, i32*** %2
%7 = getelementptr inbounds i32*, i32** %6, i64 0
%8 = load i32*, i32** %7
%9 = getelementptr inbounds i32, i32* %8, i64 0
store i32 1, i32* %9
%10 = load i32**, i32*** %2
%11 = getelementptr inbounds i32*, i32** %10, i64 1
%12 = load i32*, i32** %11
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 2, i32* %13
%14 = load i32**, i32*** %2
%15 = getelementptr inbounds i32*, i32** %14, i64 2
%16 = load i32*, i32** %15
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 3, i32* %17
%18 = load i32**, i32*** %2
%19 = getelementptr inbounds i32*, i32** %18, i64 3
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 0
store i32 4, i32* %21
%22 = load i32**, i32*** %2
%23 = getelementptr inbounds i32*, i32** %22, i64 4
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 6, i32* %25
%26 = load i32**, i32*** %2
%27 = getelementptr inbounds i32*, i32** %26, i64 0
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 0
store i32* %29, i32** %3
store i32 0, i32* %4
br label %30
30: ; preds = %33, %0
%31 = load i32, i32* %4
%32 = icmp slt i32 %31, 25
br i1 %32, label %33, label %41
33: ; preds = %30
%34 = load i32*, i32** %3
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i32 1
store i32* %38, i32** %3
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %30
41: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32**
%2 = bitcast i32*** %1 to i8*
store i32** null, i32*** %1
%3 = call i32 @malloc2dint(i32*** %1, i32 5, i32 5)
%4 = load i32**, i32*** %1
%5 = load i32*, i32** %4
store i32 1, i32* %5
%6 = getelementptr inbounds i32*, i32** %4, i64 1
%7 = load i32*, i32** %6
store i32 2, i32* %7
%8 = getelementptr inbounds i32*, i32** %4, i64 2
%9 = load i32*, i32** %8
store i32 3, i32* %9
%10 = getelementptr inbounds i32*, i32** %4, i64 3
%11 = load i32*, i32** %10
store i32 4, i32* %11
%12 = getelementptr inbounds i32*, i32** %4, i64 4
%13 = load i32*, i32** %12
store i32 6, i32* %13
%14 = load i32, i32* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i32, i32* %5, i64 1
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds i32, i32* %5, i64 2
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds i32, i32* %5, i64 3
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds i32, i32* %5, i64 4
%26 = load i32, i32* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds i32, i32* %5, i64 5
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds i32, i32* %5, i64 6
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds i32, i32* %5, i64 7
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds i32, i32* %5, i64 8
%38 = load i32, i32* %37
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds i32, i32* %5, i64 9
%41 = load i32, i32* %40
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds i32, i32* %5, i64 10
%44 = load i32, i32* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds i32, i32* %5, i64 11
%47 = load i32, i32* %46
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds i32, i32* %5, i64 12
%50 = load i32, i32* %49
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds i32, i32* %5, i64 13
%53 = load i32, i32* %52
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds i32, i32* %5, i64 14
%56 = load i32, i32* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds i32, i32* %5, i64 15
%59 = load i32, i32* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds i32, i32* %5, i64 16
%62 = load i32, i32* %61
%63 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %62)
%64 = getelementptr inbounds i32, i32* %5, i64 17
%65 = load i32, i32* %64
%66 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds i32, i32* %5, i64 18
%68 = load i32, i32* %67
%69 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds i32, i32* %5, i64 19
%71 = load i32, i32* %70
%72 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds i32, i32* %5, i64 20
%74 = load i32, i32* %73
%75 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds i32, i32* %5, i64 21
%77 = load i32, i32* %76
%78 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %77)
%79 = getelementptr inbounds i32, i32* %5, i64 22
%80 = load i32, i32* %79
%81 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %80)
%82 = getelementptr inbounds i32, i32* %5, i64 23
%83 = load i32, i32* %82
%84 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %83)
%85 = getelementptr inbounds i32, i32* %5, i64 24
%86 = load i32, i32* %85
%87 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %86)
ret i32 0
}