#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void printMatrix(double *matrix, int xDim, int yDim, FILE *fout) {
  int i = 0, j = 0;
  for (i = 0; i < xDim; i++) {
    for (j = 0; j < yDim; j++) {
      fprintf(fout, "%lf ", *(matrix + i * yDim + j));
    }
    fprintf(fout, "\n");
  }
  fclose(fout);
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <printMatrix+0xa8>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a8 <printMatrix+0x88>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe6d(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <printMatrix+0x3e>
mov    -0x18(%rbp),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <printMatrix+0x2b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %edx,0x4(%rsp)
test   %esi,%esi
jle    11bf <printMatrix+0x8f>
mov    %rdi,%rbp
movslq 0x4(%rsp),%rax
mov    %esi,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r14d
shl    $0x3,%rax
mov    %rax,0x10(%rsp)
xor    %r13d,%r13d
lea    0xe92(%rip),%r15
jmp    118d <printMatrix+0x5d>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%r13
add    0x10(%rsp),%rbp
cmp    0x8(%rsp),%r13
je     11bf <printMatrix+0x8f>
cmpl   $0x0,0x4(%rsp)
jle    1170 <printMatrix+0x40>
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%r12,8),%xmm0
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    11a0 <printMatrix+0x70>
jmp    1170 <printMatrix+0x40>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

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