#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*/ printf(char *, ...);
size_t trmIndex(int, int);
void printtrmatrix(double *array, int lenarray) {
  for (int i = 0; i < lenarray; i++) {
    for (int j = 0; j <= i; j++) {
      printf("%1.2f\t", array[trmIndex(i, j)]);
    }
    printf("%s", "\n");
  }
}


x86 assembly (clang, -O0):
<printtrmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b3 <printtrmatrix+0x93>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1190 <printtrmatrix+0x70>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <trmIndex@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
lea    0xe85(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <printtrmatrix+0x29>
lea    0xe70(%rip),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <printtrmatrix+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printtrmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11a7 <printtrmatrix+0x77>
mov    %esi,%r14d
mov    %rdi,%r12
xor    %ebp,%ebp
mov    $0x1,%r13d
lea    0xeac(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <trmIndex@plt>
movsd  (%r12,%rax,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    1170 <printtrmatrix+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
add    $0x1,%r13d
cmp    %r14d,%ebp
jne    1160 <printtrmatrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%1.2f\09\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printtrmatrix(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %32
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %24, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load double*, double** %3
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i64 @trmIndex(i32 %18, i32 %19)
%21 = getelementptr inbounds double, double* %17, i64 %20
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %12
27: ; preds = %12
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %7
32: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%1.2f\09\00"
define void @printtrmatrix(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %7
4: ; preds = %2, %8
%5 = phi i32 [ %11, %8 ], [ 1, %2 ]
%6 = phi i32 [ %10, %8 ], [ 0, %2 ]
br label %13
7: ; preds = %8, %2
ret void
8: ; preds = %13
%9 = tail call i32 @putchar(i32 10)
%10 = add nuw nsw i32 %6, 1
%11 = add nuw i32 %5, 1
%12 = icmp eq i32 %10, %1
br i1 %12, label %7, label %4
13: ; preds = %4, %13
%14 = phi i32 [ 0, %4 ], [ %19, %13 ]
%15 = tail call i64 @trmIndex(i32 %6, i32 %14)
%16 = getelementptr inbounds double, double* %0, i64 %15
%17 = load double, double* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %17)
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, %5
br i1 %20, label %8, label %13
}