#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void fmatprt(FILE *fp, 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)
      fprintf(fp, fmt, *p++);
    fprintf(fp, "\n");
  }
}


x86 assembly (clang, -O0):
<fmatprt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a8 <fmatprt+0x98>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1188 <fmatprt+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
movsd  (%rax),%xmm0
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <fmatprt+0x3c>
mov    -0x8(%rbp),%rdi
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <fmatprt+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmatprt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
test   %edx,%edx
jle    118e <fmatprt+0x6e>
mov    %r8,%r12
mov    %ecx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
xor    %r13d,%r13d
jmp    1168 <fmatprt+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%r13d
cmp    0x4(%rsp),%r13d
je     118e <fmatprt+0x6e>
test   %r14d,%r14d
jle    1150 <fmatprt+0x30>
mov    %r14d,%r15d
movsd  0x0(%rbp),%xmm0
add    $0x8,%rbp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    $0xffffffff,%r15d
jne    1170 <fmatprt+0x50>
jmp    1150 <fmatprt+0x30>
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 @fmatprt(i32* %0, double* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
store i32* %0, i32** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
store i32 0, i32* %11
%14 = load double*, double** %7
store double* %14, double** %13
br label %15
15: ; preds = %37, %5
%16 = load i32, i32* %11
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
store i32 0, i32* %12
br label %20
20: ; preds = %31, %19
%21 = load i32, i32* %12
%22 = load i32, i32* %9
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %34
24: ; preds = %20
%25 = load i32*, i32** %6
%26 = load i8*, i8** %10
%27 = load double*, double** %13
%28 = getelementptr inbounds double, double* %27, i32 1
store double* %28, double** %13
%29 = load double, double* %27
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* %26, double %29)
br label %31
31: ; preds = %24
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
br label %20
34: ; preds = %20
%35 = load i32*, i32** %6
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %34
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
br label %15
40: ; preds = %15
ret void
}

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