#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 d_print_to_file_mat(FILE *file, int row, int col, double *A, int lda) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) {
      fprintf(file, "%9.5f ", A[i + lda * j]);
    }
    fprintf(file, "\n");
  }
  fprintf(file, "\n");
}


x86 assembly (clang, -O0):
<d_print_to_file_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <d_print_to_file_mat+0x98>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1188 <d_print_to_file_mat+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x24(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe8d(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <d_print_to_file_mat+0x34>
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1131 <d_print_to_file_mat+0x21>
mov    -0x8(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_print_to_file_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,0xc(%rsp)
mov    %rdi,%rbx
test   %esi,%esi
jle    11bd <d_print_to_file_mat+0x9d>
movslq %r8d,%rbp
mov    %esi,%eax
mov    %rax,0x20(%rsp)
mov    0xc(%rsp),%eax
mov    %rax,0x18(%rsp)
shl    $0x3,%rbp
xor    %r15d,%r15d
lea    0xea1(%rip),%r12
jmp    118e <d_print_to_file_mat+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%r15
addq   $0x8,0x10(%rsp)
cmp    0x20(%rsp),%r15
je     11bd <d_print_to_file_mat+0x9d>
cmpl   $0x0,0xc(%rsp)
jle    1170 <d_print_to_file_mat+0x50>
mov    0x18(%rsp),%r13
mov    0x10(%rsp),%r14
nop
movsd  (%r14),%xmm0
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    %rbp,%r14
add    $0xffffffffffffffff,%r13
jne    11a0 <d_print_to_file_mat+0x80>
jmp    1170 <d_print_to_file_mat+0x50>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

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