#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 */
double DBL_DIG;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double);
int saveLocalMatrix(double *lmat, int nla, int mla, FILE *store) {
  long i;
  for (i = 0; i < (nla * mla); i++) {
    fprintf(store, "%.*f\n", DBL_DIG, lmat[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<saveLocalMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jge    117e <saveLocalMatrix+0x6e>
mov    -0x18(%rbp),%rdi
mov    0x2e98(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe98(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112e <saveLocalMatrix+0x1e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saveLocalMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
imul   %edx,%esi
test   %esi,%esi
jle    115f <saveLocalMatrix+0x4f>
mov    %rcx,%r14
mov    %rdi,%r12
movslq %esi,%r13
xor    %ebx,%ebx
mov    0x2eb4(%rip),%rbp
lea    0xec5(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp),%xmm0
movsd  (%r12,%rbx,8),%xmm1
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <saveLocalMatrix+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.*f\0A\00"
@DBL_DIG = global double 0.000000e+00
define i32 @saveLocalMatrix(double* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i64
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i64 0, i64* %9
br label %10
10: ; preds = %25, %4
%11 = load i64, i64* %9
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = mul nsw i32 %12, %13
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %11, %15
br i1 %16, label %17, label %28
17: ; preds = %10
%18 = load i32*, i32** %8
%19 = load double, double* @DBL_DIG
%20 = load double*, double** %5
%21 = load i64, i64* %9
%22 = getelementptr inbounds double, double* %20, i64 %21
%23 = load double, double* %22
%24 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %19, double %23)
br label %25
25: ; preds = %17
%26 = load i64, i64* %9
%27 = add nsw i64 %26, 1
store i64 %27, i64* %9
br label %10
28: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.*f\0A\00"
@DBL_DIG = global double 0.000000e+00
define i32 @saveLocalMatrix(double* nocapture %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = mul nsw i32 %2, %1
%6 = sext i32 %5 to i64
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %16
8: ; preds = %4, %8
%9 = phi i64 [ %14, %8 ], [ 0, %4 ]
%10 = load double, double* @DBL_DIG
%11 = getelementptr inbounds double, double* %0, i64 %9
%12 = load double, double* %11
%13 = tail call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %10, double %12)
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %6
br i1 %15, label %16, label %8
16: ; preds = %8, %4
ret i32 0
}