#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 printMat(double *A, int n, int m) {
  int i, j;
  for (i = 0; i < n; i++) {
    printf("[ ");
    for (j = 0; j < m; j++) {
      printf("%.8f ", A[i + j * n]);
    }
    printf("]\n");
  }
}


x86 assembly (clang, -O0):
<printMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a6 <printMat+0x96>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    118a <printMat+0x7a>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%edx
imul   -0xc(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe8e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <printMat+0x3a>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <printMat+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0x4(%rsp)
test   %esi,%esi
jle    11c9 <printMat+0xa9>
mov    %rdi,%r13
mov    %esi,%eax
mov    0x4(%rsp),%ecx
mov    %rcx,0x8(%rsp)
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,8),%r12
lea    0xea7(%rip),%rbp
xor    %r14d,%r14d
jmp    118b <printMat+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14
add    $0x8,%r13
cmp    0x10(%rsp),%r14
je     11c9 <printMat+0xa9>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1170 <printMat+0x50>
mov    0x8(%rsp),%r15
mov    %r13,%rbx
nopl   0x0(%rax,%rax,1)
movsd  (%rbx),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    %r12,%rbx
add    $0xffffffffffffffff,%r15
jne    11b0 <printMat+0x90>
jmp    1170 <printMat+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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