#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*/ *);
void readNextBlock(int i0, int i1, int j0, int j1, double *mat, FILE *store) {
  int i;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  int size = (i1 - i0) * (j1 - j0);
  for (i = 0; i < size; i++) {
    if ((read = getline(&line, &len, store)) != -1) {
      mat[i] = atof(line);
    }
  }
  free(line);
}


x86 assembly (clang, -O0):
<readNextBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    11c7 <readNextBlock+0x97>
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0xffffffff,%eax
je     11b4 <readNextBlock+0x84>
mov    -0x30(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11b9 <readNextBlock+0x89>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1175 <readNextBlock+0x45>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNextBlock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
sub    %edi,%esi
sub    %edx,%ecx
imul   %esi,%ecx
test   %ecx,%ecx
jle    11b5 <readNextBlock+0x85>
mov    %r9,%r13
mov    %r8,%r14
mov    %ecx,%ebx
xor    %ebp,%ebp
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    1189 <readNextBlock+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11ae <readNextBlock+0x7e>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     1180 <readNextBlock+0x50>
mov    0x8(%rsp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r14,%rbp,8)
jmp    1180 <readNextBlock+0x50>
mov    0x8(%rsp),%rdi
jmp    11b7 <readNextBlock+0x87>
xor    %edi,%edi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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