#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*/ free(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char **a;
  char i;
  char j;
  int m = 3;
  int n = 4;
  a = (char **)malloc(m * sizeof(char *));
  for (i = 0; i < m; ++i) {
    a[i] = (char *)malloc(n * sizeof(char));
  }
  for (i = 0; i < m; ++i) {
    for (j = 0; j < n; ++j) {
      a[i][j] = i + j;
      printf("%2d", a[i][j]);
    }
    printf("\n");
  }
  for (i = 0; i < m; ++i) {
    free((void *)a[i]);
  }
  free((void *)a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x18(%rbp)
movl   $0x4,-0x1c(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119d <main+0x6d>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movsbq -0x11(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1164 <main+0x34>
movb   $0x0,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122c <main+0xfc>
movb   $0x0,-0x12(%rbp)
movsbl -0x12(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1211 <main+0xe1>
movsbl -0x11(%rbp),%eax
movsbl -0x12(%rbp),%ecx
add    %ecx,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movsbq -0x11(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbq -0x12(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
movsbq -0x11(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbq -0x12(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x12(%rbp),%al
add    $0x1,%al
mov    %al,-0x12(%rbp)
jmp    11b2 <main+0x82>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    11a1 <main+0x71>
movb   $0x0,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    125c <main+0x12c>
mov    -0x10(%rbp),%rax
movsbq -0x11(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1230 <main+0x100>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    (%rbx),%rax
movb   $0x0,(%rax)
mov    (%rbx),%rax
movsbl (%rax),%esi
lea    0xe73(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rax
movb   $0x1,0x1(%rax)
mov    (%rbx),%rax
movsbl 0x1(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rax
movb   $0x2,0x2(%rax)
mov    (%rbx),%rax
movsbl 0x2(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rax
movb   $0x3,0x3(%rax)
mov    (%rbx),%rax
movsbl 0x3(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x8(%rbx),%rax
movb   $0x1,(%rax)
mov    0x8(%rbx),%rax
movsbl (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rax
movb   $0x2,0x1(%rax)
mov    0x8(%rbx),%rax
movsbl 0x1(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rax
movb   $0x3,0x2(%rax)
mov    0x8(%rbx),%rax
movsbl 0x2(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rax
movb   $0x4,0x3(%rax)
mov    0x8(%rbx),%rax
movsbl 0x3(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x10(%rbx),%rax
movb   $0x2,(%rax)
mov    0x10(%rbx),%rax
movsbl (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%rax
movb   $0x3,0x1(%rax)
mov    0x10(%rbx),%rax
movsbl 0x1(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%rax
movb   $0x4,0x2(%rax)
mov    0x10(%rbx),%rax
movsbl 0x2(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%rax
movb   $0x5,0x3(%rax)
mov    0x10(%rbx),%rax
movsbl 0x3(%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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