#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(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, char);
void thirteen() {
  int **values;
  int i, j;
  values = (int **)malloc(10 * sizeof(int *));
  for (i = 0; i < 10; i++) {
    values[i] = (int *)malloc(10 * sizeof(int));
    for (j = 0; j < 10; j++)
      values[i][j] = i * j;
  }
  for (i = 0; i < 10; i++)
    printf("%d%c", values[i][i], " \n"[i == 9]);
  for (i = 0; i < 10; ++i)
    free((void *)values[i]);
  free((void *)values);
}


x86 assembly (clang, -O0):
<thirteen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11bc <thirteen+0x8c>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    11a9 <thirteen+0x79>
mov    -0xc(%rbp),%edx
imul   -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <thirteen+0x47>
jmp    11ae <thirteen+0x7e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <thirteen+0x1d>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1214 <thirteen+0xe4>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
cmpl   $0x9,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
movslq %eax,%rcx
lea    0xe0a(%rip),%rdi
lea    0xe08(%rip),%rax
movsbl (%rax,%rcx,1),%edx
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c3 <thirteen+0x93>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1244 <thirteen+0x114>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    121b <thirteen+0xeb>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<thirteen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
xor    %ecx,%ecx
xor    %edx,%edx
xor    %esi,%esi
xor    %ebp,%ebp
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %r14d,%r14d
xor    %r12d,%r12d
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %esi,(%rsp)
mov    %edx,0x4(%rsp)
mov    %rcx,0x10(%rsp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx,%r12,1)
mov    0x10(%rsp),%rcx
movl   $0x0,(%rax)
mov    %ecx,0x4(%rax)
mov    %edx,0x8(%rax)
mov    %esi,0xc(%rax)
mov    %ebp,0x10(%rax)
mov    %ebx,0x14(%rax)
mov    %r15d,0x18(%rax)
mov    %r14d,0x1c(%rax)
mov    %r12d,0x20(%rax)
mov    %r13d,0x24(%rax)
add    $0x9,%r13d
add    $0x8,%r12
add    $0x7,%r14d
add    $0x6,%r15d
add    $0x5,%ebx
add    $0x4,%ebp
add    $0x3,%esi
add    $0x2,%edx
add    $0x1,%ecx
cmp    $0x50,%r12
jne    1170 <thirteen+0x40>
mov    0x8(%rsp),%rbx
mov    (%rbx),%rax
mov    (%rax),%esi
lea    0xe0a(%rip),%r14
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x8(%rbx),%rax
mov    0x4(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x10(%rbx),%rax
mov    0x8(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x18(%rbx),%rax
mov    0xc(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x20(%rbx),%rax
mov    0x10(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x28(%rbx),%rax
mov    0x14(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x30(%rbx),%rax
mov    0x18(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x38(%rbx),%rax
mov    0x1c(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x40(%rbx),%rax
mov    0x20(%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <printf@plt>
mov    0x48(%rbx),%rax
mov    0x24(%rax),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <printf@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
call   1030 <free@plt>
mov    0x18(%rbx),%rdi
call   1030 <free@plt>
mov    0x20(%rbx),%rdi
call   1030 <free@plt>
mov    0x28(%rbx),%rdi
call   1030 <free@plt>
mov    0x30(%rbx),%rdi
call   1030 <free@plt>
mov    0x38(%rbx),%rdi
call   1030 <free@plt>
mov    0x40(%rbx),%rdi
call   1030 <free@plt>
mov    0x48(%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d%c\00"
define void @thirteen() {
%1 = tail call i64 @malloc(i32 80)
%2 = inttoptr i64 %1 to i32**
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %34, %3 ]
%5 = tail call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to i32*
%7 = getelementptr inbounds i32*, i32** %2, i64 %4
store i32* %6, i32** %7
store i32 0, i32* %6
%8 = getelementptr inbounds i32, i32* %6, i64 1
%9 = trunc i64 %4 to i32
store i32 %9, i32* %8
%10 = getelementptr inbounds i32, i32* %6, i64 2
%11 = trunc i64 %4 to i32
%12 = shl i32 %11, 1
store i32 %12, i32* %10
%13 = getelementptr inbounds i32, i32* %6, i64 3
%14 = trunc i64 %4 to i32
%15 = mul i32 %14, 3
store i32 %15, i32* %13
%16 = getelementptr inbounds i32, i32* %6, i64 4
%17 = trunc i64 %4 to i32
%18 = shl i32 %17, 2
store i32 %18, i32* %16
%19 = getelementptr inbounds i32, i32* %6, i64 5
%20 = trunc i64 %4 to i32
%21 = mul i32 %20, 5
store i32 %21, i32* %19
%22 = getelementptr inbounds i32, i32* %6, i64 6
%23 = trunc i64 %4 to i32
%24 = mul i32 %23, 6
store i32 %24, i32* %22
%25 = getelementptr inbounds i32, i32* %6, i64 7
%26 = trunc i64 %4 to i32
%27 = mul i32 %26, 7
store i32 %27, i32* %25
%28 = getelementptr inbounds i32, i32* %6, i64 8
%29 = trunc i64 %4 to i32
%30 = shl i32 %29, 3
store i32 %30, i32* %28
%31 = getelementptr inbounds i32, i32* %6, i64 9
%32 = trunc i64 %4 to i32
%33 = mul i32 %32, 9
store i32 %33, i32* %31
%34 = add nuw nsw i64 %4, 1
%35 = icmp eq i64 %34, 10
br i1 %35, label %36, label %3
36: ; preds = %3
%37 = load i32*, i32** %2
%38 = load i32, i32* %37
%39 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %38, i8 signext 32)
%40 = getelementptr inbounds i32*, i32** %2, i64 1
%41 = load i32*, i32** %40
%42 = getelementptr inbounds i32, i32* %41, i64 1
%43 = load i32, i32* %42
%44 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %43, i8 signext 32)
%45 = getelementptr inbounds i32*, i32** %2, i64 2
%46 = load i32*, i32** %45
%47 = getelementptr inbounds i32, i32* %46, i64 2
%48 = load i32, i32* %47
%49 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %48, i8 signext 32)
%50 = getelementptr inbounds i32*, i32** %2, i64 3
%51 = load i32*, i32** %50
%52 = getelementptr inbounds i32, i32* %51, i64 3
%53 = load i32, i32* %52
%54 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %53, i8 signext 32)
%55 = getelementptr inbounds i32*, i32** %2, i64 4
%56 = load i32*, i32** %55
%57 = getelementptr inbounds i32, i32* %56, i64 4
%58 = load i32, i32* %57
%59 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %58, i8 signext 32)
%60 = getelementptr inbounds i32*, i32** %2, i64 5
%61 = load i32*, i32** %60
%62 = getelementptr inbounds i32, i32* %61, i64 5
%63 = load i32, i32* %62
%64 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %63, i8 signext 32)
%65 = getelementptr inbounds i32*, i32** %2, i64 6
%66 = load i32*, i32** %65
%67 = getelementptr inbounds i32, i32* %66, i64 6
%68 = load i32, i32* %67
%69 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %68, i8 signext 32)
%70 = getelementptr inbounds i32*, i32** %2, i64 7
%71 = load i32*, i32** %70
%72 = getelementptr inbounds i32, i32* %71, i64 7
%73 = load i32, i32* %72
%74 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %73, i8 signext 32)
%75 = getelementptr inbounds i32*, i32** %2, i64 8
%76 = load i32*, i32** %75
%77 = getelementptr inbounds i32, i32* %76, i64 8
%78 = load i32, i32* %77
%79 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %78, i8 signext 32)
%80 = getelementptr inbounds i32*, i32** %2, i64 9
%81 = load i32*, i32** %80
%82 = getelementptr inbounds i32, i32* %81, i64 9
%83 = load i32, i32* %82
%84 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %83, i8 signext 10)
%85 = inttoptr i64 %1 to i8**
%86 = load i8*, i8** %85
%87 = tail call i32 @free(i8* %86)
%88 = bitcast i32** %40 to i8**
%89 = load i8*, i8** %88
%90 = tail call i32 @free(i8* %89)
%91 = bitcast i32** %45 to i8**
%92 = load i8*, i8** %91
%93 = tail call i32 @free(i8* %92)
%94 = bitcast i32** %50 to i8**
%95 = load i8*, i8** %94
%96 = tail call i32 @free(i8* %95)
%97 = bitcast i32** %55 to i8**
%98 = load i8*, i8** %97
%99 = tail call i32 @free(i8* %98)
%100 = bitcast i32** %60 to i8**
%101 = load i8*, i8** %100
%102 = tail call i32 @free(i8* %101)
%103 = bitcast i32** %65 to i8**
%104 = load i8*, i8** %103
%105 = tail call i32 @free(i8* %104)
%106 = bitcast i32** %70 to i8**
%107 = load i8*, i8** %106
%108 = tail call i32 @free(i8* %107)
%109 = bitcast i32** %75 to i8**
%110 = load i8*, i8** %109
%111 = tail call i32 @free(i8* %110)
%112 = bitcast i32** %80 to i8**
%113 = load i8*, i8** %112
%114 = tail call i32 @free(i8* %113)
%115 = inttoptr i64 %1 to i8*
%116 = tail call i32 @free(i8* %115)
ret void
}