int main(int argc, char *argv[]) {
  int i;
  int asz = 12;
  int *a = calloc(asz, sizeof(int));
  int **ap = malloc(asz * sizeof(int *));
  for (i = 0; i < asz; ++i) {
    a[i] = (i + 1) * 3;
    ap[i] = a + i;
  }
  for (i = 0; i < asz; ++i)
    printf("%i ", *ap[i]);
  printf("\n");
  free(ap);
  free(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc,-0x18(%rbp)
movslq -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x18(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d0 <main+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   $0x3,%eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rdx
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <main+0x47>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    120d <main+0xcd>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d7 <main+0x97>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0xc,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    $0x60,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
movq   %rbx,%xmm0
pshufd $0x44,%xmm0,%xmm0
paddq  0xe7a(%rip),%xmm0
mov    %rbx,(%rax)
movdqu %xmm0,0x8(%rax)
lea    0xc(%rbx),%rax
movaps 0xe77(%rip),%xmm0
movups %xmm0,(%rbx)
mov    %rax,0x18(%r14)
lea    0x10(%rbx),%rax
mov    %rax,0x20(%r14)
lea    0x14(%rbx),%rax
mov    %rax,0x28(%r14)
lea    0x18(%rbx),%rax
mov    %rax,0x30(%r14)
movaps 0xe61(%rip),%xmm0
movups %xmm0,0x10(%rbx)
movaps 0xe66(%rip),%xmm0
movups %xmm0,0x20(%rbx)
lea    0xe6b(%rip),%r15
mov    %r15,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r14),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%r14),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%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 = [4 x i8] c"%i \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12, i32* %7
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = call i8* @calloc(i64 %11, i64 4)
%13 = bitcast i8* %12 to i32*
store i32* %13, i32** %8
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = call i8* @malloc(i64 %16)
%18 = bitcast i8* %17 to i32**
store i32** %18, i32*** %9
store i32 0, i32* %6
br label %19
19: ; preds = %39, %2
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %42
23: ; preds = %19
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
%26 = mul nsw i32 %25, 3
%27 = load i32*, i32** %8
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %26, i32* %30
%31 = load i32*, i32** %8
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32**, i32*** %9
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32*, i32** %35, i64 %37
store i32* %34, i32** %38
br label %39
39: ; preds = %23
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %19
42: ; preds = %19
store i32 0, i32* %6
br label %43
43: ; preds = %55, %42
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %58
47: ; preds = %43
%48 = load i32**, i32*** %9
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32*, i32** %48, i64 %50
%52 = load i32*, i32** %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %47
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %43
58: ; preds = %43
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%60 = load i32**, i32*** %9
%61 = bitcast i32** %60 to i8*
%62 = load i32*, i32** %8
%63 = bitcast i32* %62 to i8*
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%i \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(48) i8* @calloc(i64 12, i64 4)
%4 = bitcast i8* %3 to i32*
%5 = tail call dereferenceable_or_null(96) i8* @malloc(i64 96)
%6 = bitcast i8* %5 to i32**
%7 = bitcast i8* %5 to i8**
store i8* %3, i8** %7
%8 = getelementptr inbounds i32*, i32** %6, i64 1
%9 = insertelement <2 x i32*> poison, i32* %4, i64 0
%10 = shufflevector <2 x i32*> %9, <2 x i32*> poison, <2 x i32> zeroinitializer
%11 = getelementptr i32, <2 x i32*> %10, <2 x i64> <i64 1, i64 2>
%12 = getelementptr inbounds i32*, i32** %6, i64 2
%13 = bitcast i32** %8 to <2 x i32*>*
store <2 x i32*> %11, <2 x i32*>* %13
%14 = getelementptr inbounds i32, i32* %4, i64 3
%15 = bitcast i8* %3 to <4 x i32>*
store <4 x i32> <i32 3, i32 6, i32 9, i32 12>, <4 x i32>* %15
%16 = getelementptr inbounds i32*, i32** %6, i64 3
store i32* %14, i32** %16
%17 = getelementptr inbounds i32, i32* %4, i64 4
%18 = getelementptr inbounds i32*, i32** %6, i64 4
store i32* %17, i32** %18
%19 = getelementptr inbounds i32, i32* %4, i64 5
%20 = getelementptr inbounds i32*, i32** %6, i64 5
store i32* %19, i32** %20
%21 = getelementptr inbounds i32, i32* %4, i64 6
%22 = getelementptr inbounds i32*, i32** %6, i64 6
store i32* %21, i32** %22
%23 = getelementptr inbounds i32, i32* %4, i64 7
%24 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 15, i32 18, i32 21, i32 24>, <4 x i32>* %24
%25 = getelementptr inbounds i32, i32* %4, i64 8
%26 = getelementptr inbounds i32, i32* %4, i64 9
%27 = getelementptr inbounds i32, i32* %4, i64 10
%28 = getelementptr inbounds i32, i32* %4, i64 11
%29 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 27, i32 30, i32 33, i32 36>, <4 x i32>* %29
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%31 = load i32*, i32** %8
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %12
%35 = load i32, i32* %34
%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 = load i32, i32* %14
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %17
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %19
%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 i32, i32* %21
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %23
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %25
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %26
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %27
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %28
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = tail call i32 @putchar(i32 10)
tail call void @free(i8* %5)
tail call void @free(i8* %3)
ret i32 0
}