#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*/ displayMatrix(size_t **, size_t);
int /*<<< orphan*/ fillMatrix(size_t **, size_t);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(size_t **);
int /*<<< orphan*/ freeMatrix(size_t **, size_t);
int initMatrix(size_t **, size_t);
size_t **malloc(int);
int /*<<< orphan*/ stderr;
void displayTriangleMatrix(size_t nbLines) {
  size_t **matrix;
  bool init;
  matrix = malloc(sizeof(size_t) * nbLines);
  if (!matrix) {
    fprintf(stderr, "Can not allocate memory for matrix\n");
    return;
  }
  init = initMatrix(matrix, nbLines);
  if (init) {
    fillMatrix(matrix, nbLines);
    displayMatrix(matrix, nbLines);
    freeMatrix(matrix, nbLines);
  }
  free(matrix);
}


x86 assembly (clang, -O0):
<displayTriangleMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b4 <displayTriangleMatrix+0x44>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11fe <displayTriangleMatrix+0x8e>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <initMatrix@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f5 <displayTriangleMatrix+0x85>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <fillMatrix@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <displayMatrix@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <freeMatrix@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayTriangleMatrix>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x0(,%rdi,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11ca <displayTriangleMatrix+0x5a>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1090 <initMatrix@plt>
test   %eax,%eax
je     11bb <displayTriangleMatrix+0x4b>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <fillMatrix@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <displayMatrix@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <freeMatrix@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Can not allocate memory for matrix\0A\00"
define void @displayTriangleMatrix(i64 %0) {
%2 = alloca i64
%3 = alloca i64**
%4 = alloca i32
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = mul i64 8, %5
%7 = trunc i64 %6 to i32
%8 = call i64** @malloc(i32 %7)
store i64** %8, i64*** %3
%9 = load i64**, i64*** %3
%10 = icmp ne i64** %9, null
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %33
14: ; preds = %1
%15 = load i64**, i64*** %3
%16 = load i64, i64* %2
%17 = call i32 @initMatrix(i64** %15, i64 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = load i64**, i64*** %3
%22 = load i64, i64* %2
%23 = call i32 @fillMatrix(i64** %21, i64 %22)
%24 = load i64**, i64*** %3
%25 = load i64, i64* %2
%26 = call i32 @displayMatrix(i64** %24, i64 %25)
%27 = load i64**, i64*** %3
%28 = load i64, i64* %2
%29 = call i32 @freeMatrix(i64** %27, i64 %28)
br label %30
30: ; preds = %20, %14
%31 = load i64**, i64*** %3
%32 = call i32 @free(i64** %31)
br label %33
33: ; preds = %30, %11
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Can not allocate memory for matrix\0A\00"
define void @displayTriangleMatrix(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = shl i32 %2, 3
%4 = tail call i64** @malloc(i32 %3)
%5 = icmp eq i64** %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %18
9: ; preds = %1
%10 = tail call i32 @initMatrix(i64** %4, i64 %0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 @fillMatrix(i64** %4, i64 %0)
%14 = tail call i32 @displayMatrix(i64** %4, i64 %0)
%15 = tail call i32 @freeMatrix(i64** %4, i64 %0)
br label %16
16: ; preds = %12, %9
%17 = tail call i32 @free(i64** %4)
br label %18
18: ; preds = %16, %6
ret void
}