#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 *, ...);
void printMatrix(double *matrix, int row, int col) {
  int i, j;
  printf("-------------------------------------------------------\n");
  printf("Result Matrix:\n");
  for (i = 0; i < row; i++) {
    printf("\n");
    for (j = 0; j < col; j++) {
      printf("%6.2f   ", matrix[i * col + j]);
    }
  }
  printf("\n-------------------------------------------------------\n");
  printf("Done.\n");
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <printMatrix+0xa7>
lea    0xef9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a4 <printMatrix+0x94>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1166 <printMatrix+0x56>
jmp    11a9 <printMatrix+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1145 <printMatrix+0x35>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0xc(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    11db <printMatrix+0xab>
movslq 0xc(%rsp),%r15
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
mov    %r15d,%ebp
shl    $0x3,%r15
xor    %r14d,%r14d
lea    0xe80(%rip),%r13
jmp    119e <printMatrix+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14
add    %r15,%rbx
cmp    0x10(%rsp),%r14
je     11db <printMatrix+0xab>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    1190 <printMatrix+0x60>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rbx,%r12,8),%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    11c0 <printMatrix+0x90>
jmp    1190 <printMatrix+0x60>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
lea    0xe63(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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