#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(float *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    11b7 <printtrmatrix+0x97>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1194 <printtrmatrix+0x74>
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
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe81(%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    0xe6c(%rip),%rdi
lea    0xe68(%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    11ab <printtrmatrix+0x7b>
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>
movss  (%r12,%rax,4),%xmm0
cvtss2sd %xmm0,%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(float* %0, i32 %1) {
%3 = alloca float*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store float* %0, float** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %33
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %25, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load float*, float** %3
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i64 @trmIndex(i32 %18, i32 %19)
%21 = getelementptr inbounds float, float* %17, i64 %20
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %23)
br label %25
25: ; preds = %16
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %12
28: ; preds = %12
%29 = 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 %30
30: ; preds = %28
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %7
33: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%1.2f\09\00"
define void @printtrmatrix(float* 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 ], [ %20, %13 ]
%15 = tail call i64 @trmIndex(i32 %6, i32 %14)
%16 = getelementptr inbounds float, float* %0, i64 %15
%17 = load float, float* %16
%18 = fpext float %17 to double
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %18)
%20 = add nuw nsw i32 %14, 1
%21 = icmp eq i32 %20, %5
br i1 %21, label %8, label %13
}