void thirteen(int a) {
  int **values;
  int i, j;
  values = malloc(10 * sizeof(*values));
  for (i = 0; i < 10; i++) {
    values[i] = malloc(10 * sizeof(**values));
    for (j = 0; j < 10; j++)
      values[i][j] = i * j * a;
  }
  for (i = 0; i < 10; i++) {
    printf("%d ", values[i][i]);
    free(values[i]);
  }
  printf("\n");
  free(values);
}


x86 assembly (clang, -O0):
<thirteen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11c3 <thirteen+0x93>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    11b0 <thirteen+0x80>
mov    -0x14(%rbp),%edx
imul   -0x18(%rbp),%edx
imul   -0x4(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117a <thirteen+0x4a>
jmp    11b5 <thirteen+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <thirteen+0x20>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1214 <thirteen+0xe4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <thirteen+0x9a>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thirteen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ebx
mov    $0x50,%edi
call   1060 <malloc@plt>
mov    %rax,0x28(%rsp)
lea    0x0(,%rbx,8),%eax
lea    0x0(,%rbx,4),%ecx
mov    %ecx,0x14(%rsp)
lea    (%rbx,%rbx,1),%ecx
lea    (%rbx,%rbx,8),%edx
mov    %edx,0x10(%rsp)
mov    %eax,0x18(%rsp)
sub    %ebx,%eax
mov    %eax,0xc(%rsp)
mov    %rcx,0x30(%rsp)
lea    (%rcx,%rcx,2),%eax
mov    %eax,0x8(%rsp)
lea    (%rbx,%rbx,4),%eax
mov    %eax,0x4(%rsp)
mov    %rbx,0x38(%rsp)
lea    (%rbx,%rbx,2),%eax
mov    %eax,(%rsp)
xor    %ecx,%ecx
xor    %edx,%edx
xor    %esi,%esi
xor    %edi,%edi
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %edi,0x1c(%rsp)
mov    %esi,0x20(%rsp)
mov    %edx,0x24(%rsp)
mov    %rcx,0x40(%rsp)
mov    $0x28,%edi
call   1060 <malloc@plt>
mov    0x1c(%rsp),%edi
mov    0x20(%rsp),%esi
mov    0x24(%rsp),%edx
mov    0x28(%rsp),%rcx
mov    %rax,(%rcx,%r13,8)
mov    0x40(%rsp),%rcx
movl   $0x0,(%rax)
mov    %r12d,0x4(%rax)
mov    %ebp,0x8(%rax)
mov    %ecx,0xc(%rax)
mov    %r14d,0x10(%rax)
mov    %edx,0x14(%rax)
mov    %esi,0x18(%rax)
mov    %edi,0x1c(%rax)
mov    %r15d,0x20(%rax)
mov    %ebx,0x24(%rax)
add    $0x1,%r13
add    0x18(%rsp),%r15d
add    0x14(%rsp),%r14d
add    0x30(%rsp),%ebp
add    0x38(%rsp),%r12d
add    0x10(%rsp),%ebx
add    0xc(%rsp),%edi
add    0x8(%rsp),%esi
add    0x4(%rsp),%edx
add    (%rsp),%ecx
cmp    $0xa,%r13
jne    11c0 <thirteen+0x80>
mov    0x28(%rsp),%rbp
mov    0x0(%rbp),%rbx
mov    (%rbx),%esi
lea    0xda1(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rbp),%rbx
mov    0x4(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x10(%rbp),%rbx
mov    0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x18(%rbp),%rbx
mov    0xc(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x20(%rbp),%rbx
mov    0x10(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x28(%rbp),%rbx
mov    0x14(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x30(%rbp),%rbx
mov    0x18(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x38(%rbp),%rbx
mov    0x1c(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x40(%rbp),%rbx
mov    0x20(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x48(%rbp),%rbx
mov    0x24(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbp,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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