#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 sqmIndex(int, int, int);
void printsqmatrix(float *array, int lenarray) {
  for (int i = 0; i < lenarray; i++) {
    for (int j = 0; j < lenarray; j++) {
      printf("%1.2f\t", array[sqmIndex(lenarray, i, j)]);
    }
    printf("%s", "\n");
  }
}


x86 assembly (clang, -O0):
<printsqmatrix>:
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    11ba <printsqmatrix+0x9a>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1197 <printsqmatrix+0x77>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <sqmIndex@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <printsqmatrix+0x29>
lea    0xe69(%rip),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <printsqmatrix+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printsqmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    119a <printsqmatrix+0x6a>
mov    %esi,%ebx
mov    %rdi,%r14
xor    %r12d,%r12d
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r12d,%esi
mov    %ebp,%edx
call   1040 <sqmIndex@plt>
movss  (%r14,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1160 <printsqmatrix+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    %ebx,%r12d
jne    1150 <printsqmatrix+0x20>
pop    %rbx
pop    %r12
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 @printsqmatrix(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 = %31, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
store i32 0, i32* %6
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load float*, float** %3
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i64 @sqmIndex(i32 %18, i32 %19, i32 %20)
%22 = getelementptr inbounds float, float* %17, i64 %21
%23 = load float, float* %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %24)
br label %26
26: ; preds = %16
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %12
29: ; preds = %12
%30 = 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 %31
31: ; preds = %29
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %7
34: ; preds = %7
ret void
}

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