#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 matprt(double *a, int n, int m, char *fmt) {
  int i, j;
  double *p;
  for (i = 0, p = a; i < n; ++i) {
    for (j = 0; j < m; ++j)
      printf(fmt, *p++);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<matprt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119c <matprt+0x8c>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1180 <matprt+0x70>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x28(%rbp)
movsd  (%rax),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1148 <matprt+0x38>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1135 <matprt+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matprt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    117a <matprt+0x5a>
mov    %rcx,%r13
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbp
xor    %r12d,%r12d
jmp    1153 <matprt+0x33>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    %r14d,%r12d
je     117a <matprt+0x5a>
test   %r15d,%r15d
jle    1140 <matprt+0x20>
mov    %r15d,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp),%xmm0
add    $0x8,%rbp
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1160 <matprt+0x40>
jmp    1140 <matprt+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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