int main() {
  int i, j;
  int **pnumbers;
  pnumbers = (int **)malloc(3 * sizeof(int *));
  pnumbers[0] = (int *)malloc(1 * sizeof(int));
  pnumbers[1] = (int *)malloc(2 * sizeof(int));
  pnumbers[2] = (int *)malloc(3 * sizeof(int));
  pnumbers[0][0] = 1;
  pnumbers[1][0] = 1;
  pnumbers[1][1] = 1;
  pnumbers[2][0] = 1;
  pnumbers[2][1] = 2;
  pnumbers[2][2] = 1;
  for (i = 0; i < 3; i++) {
    for (j = 0; j <= i; j++) {
      printf("%d", pnumbers[i][j]);
    }
    printf("\n");
  }
  for (i = 0; i < 3; i++) {
    free(pnumbers[i]);
  }
  free(pnumbers);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x2,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,0x8(%rax)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1250 <main+0x120>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1234 <main+0x104>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f9 <main+0xc9>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e8 <main+0xb8>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1280 <main+0x150>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1257 <main+0x127>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x8,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0xc,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movabs $0x100000001,%rax
mov    %rax,(%r14)
movabs $0x200000001,%rax
mov    %rax,(%rbx)
movl   $0x1,0x8(%rbx)
lea    0xe79(%rip),%r15
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%r14),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(8) i8* @malloc(i64 8)
%2 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%3 = bitcast i8* %1 to i32*
store i32 1, i32* %3
%4 = getelementptr inbounds i32, i32* %3, i64 1
store i32 1, i32* %4
%5 = bitcast i8* %2 to i32*
store i32 1, i32* %5
%6 = getelementptr inbounds i32, i32* %5, i64 1
store i32 2, i32* %6
%7 = getelementptr inbounds i32, i32* %5, i64 2
store i32 1, i32* %7
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = tail call i32 @putchar(i32 10)
%10 = load i32, i32* %3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %4
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @putchar(i32 10)
%15 = load i32, i32* %5
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %6
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %7
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = tail call i32 @putchar(i32 10)
tail call void @free(i8* %1)
tail call void @free(i8* %2)
ret i32 0
}