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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11d5 <main+0x95>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
mov    %rcx,-0x20(%rbp,%rax,8)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11c2 <main+0x82>
imul   $0xa,-0x24(%rbp),%edx
add    -0x28(%rbp),%edx
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1189 <main+0x49>
jmp    11c7 <main+0x87>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1156 <main+0x16>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1243 <main+0x103>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    122b <main+0xeb>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xde8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ed <main+0xad>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11dc <main+0x9c>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1270 <main+0x130>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124a <main+0x10a>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
movl   $0x0,(%rax)
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
movabs $0xb0000000a,%rax
mov    %rax,(%r15)
movl   $0xc,0x8(%r15)
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movaps 0xe6f(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x18,0x10(%rax)
mov    (%r14),%esi
lea    0xe6b(%rip),%r12
mov    %r12,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%r15),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x4(%r15),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x8(%r15),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%4d\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to i32*
store i32 0, i32* %2
%3 = tail call i64 @malloc(i32 12)
%4 = inttoptr i64 %3 to i32*
store i32 10, i32* %4
%5 = getelementptr inbounds i32, i32* %4, i64 1
store i32 11, i32* %5
%6 = getelementptr inbounds i32, i32* %4, i64 2
store i32 12, i32* %6
%7 = tail call i64 @malloc(i32 20)
%8 = inttoptr i64 %7 to i32*
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = getelementptr inbounds i32, i32* %8, i64 2
%11 = getelementptr inbounds i32, i32* %8, i64 3
%12 = inttoptr i64 %7 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %8, i64 4
store i32 24, i32* %13
%14 = load i32, i32* %2
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = tail call i32 @putchar(i8 signext 10)
%17 = load i32, i32* %4
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %6
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = tail call i32 @putchar(i8 signext 10)
%24 = load i32, i32* %8
%25 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %9
%27 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %10
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %11
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %13
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = tail call i32 @putchar(i8 signext 10)
%35 = tail call i32 @free(i32* %2)
%36 = tail call i32 @free(i32* %4)
%37 = tail call i32 @free(i32* %8)
ret i32 0
}