#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 *, char *, int, int, double);
void print_matrix_canonical(char *name, int m, int n, double *A, int lda) {
  int i;
  for (i = 0; i < m; i++) {
    int j;
    for (j = 0; j < n; j++) {
      printf("%s(%d,%d) = %22.16g;\n", name, i + 1, j + 1, A[j * lda + i]);
    }
  }
}


x86 assembly (clang, -O0):
<print_matrix_canonical>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a3 <print_matrix_canonical+0x93>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1190 <print_matrix_canonical+0x80>
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%edi
imul   -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
movslq %edi,%rdi
movsd  (%rax,%rdi,8),%xmm0
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <print_matrix_canonical+0x34>
jmp    1195 <print_matrix_canonical+0x85>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1131 <print_matrix_canonical+0x21>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_matrix_canonical>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,0xc(%rsp)
test   %esi,%esi
jle    11a9 <print_matrix_canonical+0x99>
mov    %rdi,%r15
movslq %r8d,%rdi
mov    %esi,%eax
mov    %rax,0x18(%rsp)
mov    0xc(%rsp),%ebx
shl    $0x3,%rdi
xor    %r14d,%r14d
lea    0xeb6(%rip),%r13
mov    %rdi,0x20(%rsp)
jmp    116d <print_matrix_canonical+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addq   $0x8,0x10(%rsp)
cmp    0x18(%rsp),%r14
je     11a9 <print_matrix_canonical+0x99>
add    $0x1,%r14
cmpl   $0x0,0xc(%rsp)
jle    1160 <print_matrix_canonical+0x50>
mov    0x10(%rsp),%r12
xor    %ebp,%ebp
nop
add    $0x1,%rbp
movsd  (%r12),%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
mov    0x20(%rsp),%rdi
add    %rdi,%r12
cmp    %rbp,%rbx
jne    1180 <print_matrix_canonical+0x70>
jmp    1160 <print_matrix_canonical+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%s(%d,%d) = %22.16g;\0A\00"
define void @print_matrix_canonical(i8* %0, i32 %1, i32 %2, double* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %13
13: ; preds = %42, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %45
17: ; preds = %13
store i32 0, i32* %12
br label %18
18: ; preds = %38, %17
%19 = load i32, i32* %12
%20 = load i32, i32* %8
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %41
22: ; preds = %18
%23 = load i8*, i8** %6
%24 = load i32, i32* %11
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %12
%27 = add nsw i32 %26, 1
%28 = load double*, double** %9
%29 = load i32, i32* %12
%30 = load i32, i32* %10
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %11
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %28, i64 %34
%36 = load double, double* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %25, i32 %27, double %36)
br label %38
38: ; preds = %22
%39 = load i32, i32* %12
%40 = add nsw i32 %39, 1
store i32 %40, i32* %12
br label %18
41: ; preds = %18
br label %42
42: ; preds = %41
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %13
45: ; preds = %13
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"%s(%d,%d) = %22.16g;\0A\00"
define void @print_matrix_canonical(i8* %0, i32 %1, i32 %2, double* nocapture %3, i32 %4) {
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %29
7: ; preds = %5
%8 = icmp sgt i32 %2, 0
%9 = sext i32 %4 to i64
%10 = zext i32 %1 to i64
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %7, %27
%13 = phi i64 [ 0, %7 ], [ %14, %27 ]
%14 = add nuw nsw i64 %13, 1
br i1 %8, label %15, label %27
15: ; preds = %12
%16 = trunc i64 %14 to i32
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %19, %17 ]
%19 = add nuw nsw i64 %18, 1
%20 = mul nsw i64 %18, %9
%21 = add nsw i64 %20, %13
%22 = getelementptr inbounds double, double* %3, i64 %21
%23 = load double, double* %22
%24 = trunc i64 %19 to i32
%25 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %16, i32 %24, double %23)
%26 = icmp eq i64 %19, %11
br i1 %26, label %27, label %17
27: ; preds = %17, %12
%28 = icmp eq i64 %14, %10
br i1 %28, label %29, label %12
29: ; preds = %27, %5
ret void
}