#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 main(int argc, const char *argv[]) {
  int **a = (int **)malloc(sizeof(int *) * 5);
  int i;
  for (i = 0; i < 5; ++i) {
    a[i] = (int *)malloc(sizeof(int) * 3);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x28,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    116c <main+0x5c>
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x28,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,(%rbx)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,0x18(%rbx)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,0x20(%rbx)
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32**
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @malloc(i32 40)
%9 = inttoptr i64 %8 to i32**
store i32** %9, i32*** %6
store i32 0, i32* %7
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = call i64 @malloc(i32 12)
%15 = inttoptr i64 %14 to i32*
%16 = load i32**, i32*** %6
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32*, i32** %16, i64 %18
store i32* %15, i32** %19
br label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %10
23: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 40)
%4 = inttoptr i64 %3 to i32**
%5 = tail call i64 @malloc(i32 12)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %4
%7 = tail call i64 @malloc(i32 12)
%8 = inttoptr i64 %7 to i32*
%9 = getelementptr inbounds i32*, i32** %4, i64 1
store i32* %8, i32** %9
%10 = tail call i64 @malloc(i32 12)
%11 = inttoptr i64 %10 to i32*
%12 = getelementptr inbounds i32*, i32** %4, i64 2
store i32* %11, i32** %12
%13 = tail call i64 @malloc(i32 12)
%14 = inttoptr i64 %13 to i32*
%15 = getelementptr inbounds i32*, i32** %4, i64 3
store i32* %14, i32** %15
%16 = tail call i64 @malloc(i32 12)
%17 = inttoptr i64 %16 to i32*
%18 = getelementptr inbounds i32*, i32** %4, i64 4
store i32* %17, i32** %18
ret i32 0
}