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

/* Variables and functions */
double atof(char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int readLocalMatrix(double *lmat, int nla, int mla, FILE *store) {
  int i;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int size = nla * mla;
  for (i = 0; i < size; i++) {
    if ((read = getline(&line, &len, store)) != -1) {
      lmat[i] = atof(line);
    }
  }
  free(line);
  return 0;
}


x86 assembly (clang, -O0):
<readLocalMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    11b9 <readLocalMatrix+0x89>
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     11a6 <readLocalMatrix+0x76>
mov    -0x28(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11ab <readLocalMatrix+0x7b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <readLocalMatrix+0x37>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLocalMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
imul   %edx,%esi
test   %esi,%esi
jle    11a5 <readLocalMatrix+0x75>
mov    %rcx,%r13
mov    %rdi,%r14
mov    %esi,%ebx
xor    %ebp,%ebp
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    1179 <readLocalMatrix+0x49>
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     119e <readLocalMatrix+0x6e>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     1170 <readLocalMatrix+0x40>
mov    0x8(%rsp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r14,%rbp,8)
jmp    1170 <readLocalMatrix+0x40>
mov    0x8(%rsp),%rdi
jmp    11a7 <readLocalMatrix+0x77>
xor    %edi,%edi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @readLocalMatrix(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 i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i8* null, i8** %10
store i64 0, i64* %11
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %13
store i32 0, i32* %9
br label %17
17: ; preds = %33, %4
%18 = load i32, i32* %9
%19 = load i32, i32* %13
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
%22 = load i32*, i32** %8
%23 = call i32 @getline(i8** %10, i64* %11, i32* %22)
store i32 %23, i32* %12
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i8*, i8** %10
%27 = call double @atof(i8* %26)
%28 = load double*, double** %5
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double %27, double* %31
br label %32
32: ; preds = %25, %21
br label %33
33: ; preds = %32
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %17
36: ; preds = %17
%37 = load i8*, i8** %10
%38 = call i32 @free(i8* %37)
ret i32 0
}

LLVM IR (-O2):
define i32 @readLocalMatrix(double* nocapture writeonly %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = bitcast i64* %6 to i8*
store i64 0, i64* %6
%9 = mul i32 %2, %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %4
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %11, %21
%14 = phi i64 [ 0, %11 ], [ %22, %21 ]
%15 = call i32 @getline(i8** %5, i64* %6, i32* %3)
%16 = icmp eq i32 %15, -1
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = call double @atof(i8* %18)
%20 = getelementptr inbounds double, double* %0, i64 %14
store double %19, double* %20
br label %21
21: ; preds = %13, %17
%22 = add nuw nsw i64 %14, 1
%23 = icmp eq i64 %22, %12
br i1 %23, label %24, label %13
24: ; preds = %21
%25 = load i8*, i8** %5
br label %26
26: ; preds = %24, %4
%27 = phi i8* [ %25, %24 ], [ null, %4 ]
%28 = call i32 @free(i8* %27)
ret i32 0
}