#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void printm(int m, int n, double mat[m][n]) {
  int i, j;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      fprintf(stdout, "%7.5f ", mat[i][j]);
    }
    fprintf(stdout, "\n");
  }
  fprintf(stdout, "\n");
}


x86 assembly (clang, -O0):
<printm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b9 <printm+0xa9>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1194 <printm+0x84>
mov    -0x20(%rbp),%rdx
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe81(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <printm+0x33>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <printm+0x20>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0x4(%rsp)
test   %edi,%edi
jle    11ae <printm+0x9e>
mov    %rdx,%rbx
mov    0x4(%rsp),%ebp
mov    %edi,%eax
mov    %rax,0x10(%rsp)
lea    0x0(,%rbp,8),%rax
mov    %rax,0x8(%rsp)
mov    0x2e94(%rip),%r14
lea    0xead(%rip),%r12
xor    %r13d,%r13d
jmp    1181 <printm+0x71>
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
lea    0xe9d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r13
add    0x8(%rsp),%rbx
cmp    0x10(%rsp),%r13
je     11ae <printm+0x9e>
cmpl   $0x0,0x4(%rsp)
jle    1160 <printm+0x50>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
movsd  (%rbx,%r15,8),%xmm0
mov    %r12,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1190 <printm+0x80>
jmp    1160 <printm+0x50>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

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

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