#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(double *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    11b6 <printsqmatrix+0x96>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1193 <printsqmatrix+0x73>
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
movsd  (%rax,%rcx,8),%xmm0
lea    0xe82(%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    0xe6d(%rip),%rdi
lea    0xe69(%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    1196 <printsqmatrix+0x66>
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>
movsd  (%r14,%rax,8),%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(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 = %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* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %28
16: ; preds = %12
%17 = load double*, double** %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 double, double* %17, i64 %21
%23 = load double, double* %22
%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 @printsqmatrix(double* 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 [ %17, %11 ], [ 0, %4 ]
%13 = tail call i64 @sqmIndex(i32 %1, i32 %5, i32 %12)
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %15)
%17 = add nuw nsw i32 %12, 1
%18 = icmp eq i32 %17, %1
br i1 %18, label %7, label %11
}