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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void fmprint(double *matrix, int nrows, int ncols, FILE *file) {
  int i, j;
  fprintf(file, "\n  +");
  for (i = 0; i < ncols; i++) {
    fprintf(file, "--------------+");
  }
  fputs("\n", file);
  for (i = 0; i < nrows; i++) {
    fprintf(file, "  |");
    for (j = 0; j < ncols; j++) {
      fprintf(file, " %12.4f |", matrix[((i) * (ncols) + (j))]);
    }
    fputs("\n", file);
  }
  fprintf(file, "  +");
  for (i = 0; i < ncols; i++) {
    fprintf(file, "--------------+");
  }
  fputs("\n\n", file);
}


x86 assembly (clang, -O0):
<fmprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    117b <fmprint+0x5b>
mov    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <fmprint+0x2f>
mov    -0x18(%rbp),%rsi
lea    0xe9e(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1217 <fmprint+0xf7>
mov    -0x18(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f9 <fmprint+0xd9>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe35(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b7 <fmprint+0x97>
mov    -0x18(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <fmprint+0x72>
mov    -0x18(%rbp),%rdi
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    125c <fmprint+0x13c>
mov    -0x18(%rbp),%rdi
lea    0xdbe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1230 <fmprint+0x110>
mov    -0x18(%rbp),%rsi
lea    0xdbc(%rip),%rdi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmprint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r13
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0xeaf(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
test   %r14d,%r14d
jle    118a <fmprint+0x5a>
lea    0xe99(%rip),%r12
mov    %r14d,%ebx
nop
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %r13,%rcx
call   1050 <fwrite@plt>
add    $0xffffffff,%ebx
jne    1170 <fmprint+0x40>
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
test   %r15d,%r15d
jle    123f <fmprint+0x10f>
movslq %r14d,%rax
mov    %r15d,%ecx
mov    %rcx,0x8(%rsp)
mov    %r14d,%r15d
shl    $0x3,%rax
mov    %rax,0x10(%rsp)
xor    %ebx,%ebx
lea    0xe59(%rip),%r12
mov    %r14d,0x4(%rsp)
jmp    11f2 <fmprint+0xc2>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
add    0x10(%rsp),%rbp
cmp    0x8(%rsp),%rbx
mov    0x4(%rsp),%r14d
je     123f <fmprint+0x10f>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xe12(%rip),%rdi
mov    %r13,%rcx
call   1050 <fwrite@plt>
test   %r14d,%r14d
jle    11d0 <fmprint+0xa0>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x0(%rbp,%r14,8),%xmm0
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,%r15
jne    1220 <fmprint+0xf0>
jmp    11d0 <fmprint+0xa0>
lea    0xdbb(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1050 <fwrite@plt>
test   %r14d,%r14d
jle    128b <fmprint+0x15b>
lea    0xda1(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r13,%rcx
call   1050 <fwrite@plt>
add    $0xffffffff,%r14d
jne    1270 <fmprint+0x140>
lea    0xd91(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rcx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"\0A +\00"
@.str.1 = [16 x i8] c"--------------+\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c" |\00"
@.str.4 = [10 x i8] c" %12.4f |\00"
@.str.5 = [4 x i8] c" +\00"
@.str.6 = [3 x i8] c"\0A\0A\00"
define void @fmprint(double* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%11 = load i32*, i32** %8
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %13
13: ; preds = %20, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i32*, i32** %8
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17
%21 = load i32, i32* %9
%22 = add nsw i32 %21, 1
store i32 %22, i32* %9
br label %13
23: ; preds = %13
%24 = load i32*, i32** %8
%25 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32* %24)
store i32 0, i32* %9
br label %26
26: ; preds = %55, %23
%27 = load i32, i32* %9
%28 = load i32, i32* %6
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %58
30: ; preds = %26
%31 = load i32*, i32** %8
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %10
br label %33
33: ; preds = %49, %30
%34 = load i32, i32* %10
%35 = load i32, i32* %7
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %52
37: ; preds = %33
%38 = load i32*, i32** %8
%39 = load double*, double** %5
%40 = load i32, i32* %9
%41 = load i32, i32* %7
%42 = mul nsw i32 %40, %41
%43 = load i32, i32* %10
%44 = add nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %39, i64 %45
%47 = load double, double* %46
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %47)
br label %49
49: ; preds = %37
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
br label %33
52: ; preds = %33
%53 = load i32*, i32** %8
%54 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32* %53)
br label %55
55: ; preds = %52
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %26
58: ; preds = %26
%59 = load i32*, i32** %8
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %9
br label %61
61: ; preds = %68, %58
%62 = load i32, i32* %9
%63 = load i32, i32* %7
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %71
65: ; preds = %61
%66 = load i32*, i32** %8
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %68
68: ; preds = %65
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %61
71: ; preds = %61
%72 = load i32*, i32** %8
%73 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %72)
ret void
}

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