#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 */
void *malloc(int);
int **new_matrix() {
  int i, **a;
  a = malloc(sizeof(int *) * 9);
  for (i = 0; i < 9; i++) {
    a[i] = malloc(sizeof(int) * 9);
  }
  return a;
}


x86 assembly (clang, -O0):
<new_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x48,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x9,-0x4(%rbp)
jge    115e <new_matrix+0x4e>
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112d <new_matrix+0x1d>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_matrix>:
push   %rbx
mov    $0x48,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x18(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x20(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x28(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x30(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x38(%rbx)
mov    $0x24,%edi
call   1030 <malloc@plt>
mov    %rax,0x40(%rbx)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i32** @new_matrix() {
%1 = alloca i32
%2 = alloca i32**
%3 = call i8* @malloc(i32 72)
%4 = bitcast i8* %3 to i32**
store i32** %4, i32*** %2
store i32 0, i32* %1
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 9
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i8* @malloc(i32 36)
%10 = bitcast i8* %9 to i32*
%11 = load i32**, i32*** %2
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32*, i32** %11, i64 %13
store i32* %10, i32** %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %5
18: ; preds = %5
%19 = load i32**, i32*** %2
ret i32** %19
}

LLVM IR (-O2):
define noalias i32** @new_matrix() {
%1 = tail call dereferenceable_or_null(72) i8* @malloc(i32 72)
%2 = bitcast i8* %1 to i32**
%3 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%4 = bitcast i8* %1 to i8**
store i8* %3, i8** %4
%5 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%6 = getelementptr inbounds i32*, i32** %2, i64 1
%7 = bitcast i32** %6 to i8**
store i8* %5, i8** %7
%8 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%9 = getelementptr inbounds i32*, i32** %2, i64 2
%10 = bitcast i32** %9 to i8**
store i8* %8, i8** %10
%11 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%12 = getelementptr inbounds i32*, i32** %2, i64 3
%13 = bitcast i32** %12 to i8**
store i8* %11, i8** %13
%14 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%15 = getelementptr inbounds i32*, i32** %2, i64 4
%16 = bitcast i32** %15 to i8**
store i8* %14, i8** %16
%17 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%18 = getelementptr inbounds i32*, i32** %2, i64 5
%19 = bitcast i32** %18 to i8**
store i8* %17, i8** %19
%20 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%21 = getelementptr inbounds i32*, i32** %2, i64 6
%22 = bitcast i32** %21 to i8**
store i8* %20, i8** %22
%23 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%24 = getelementptr inbounds i32*, i32** %2, i64 7
%25 = bitcast i32** %24 to i8**
store i8* %23, i8** %25
%26 = tail call dereferenceable_or_null(36) i8* @malloc(i32 36)
%27 = getelementptr inbounds i32*, i32** %2, i64 8
%28 = bitcast i32** %27 to i8**
store i8* %26, i8** %28
ret i32** %2
}