#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*/ fgets(char *, int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, double *);
char *strtok(char *, char *);
int readArray(FILE *fr, char *line, const int maxLineLength, double *target) {
  char *currValue;
  int currIndex = 0;
  if (!fgets(line, maxLineLength, fr)) {
    return 0;
  }
  currValue = strtok(line, ",");
  while (currValue != NULL) {
    sscanf(currValue, "%lf", &target[currIndex++]);
    currValue = strtok(NULL, ",");
  }
  return 1;
}


x86 assembly (clang, -O0):
<readArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <fgets@plt>
cmp    $0x0,%eax
jne    1173 <readArray+0x43>
movl   $0x0,-0x4(%rbp)
jmp    11da <readArray+0xaa>
mov    -0x18(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11d3 <readArray+0xa3>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x34(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x34(%rbp)
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe4d(%rip),%rsi
call   1040 <sscanf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe3b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x30(%rbp)
jmp    1187 <readArray+0x57>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rsi,%rbp
mov    %rdi,%rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
call   1030 <fgets@plt>
test   %eax,%eax
je     11a3 <readArray+0x73>
lea    0xea8(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strtok@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     11a6 <readArray+0x76>
lea    0xe90(%rip),%r15
lea    0xe87(%rip),%rbp
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <sscanf@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1050 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1180 <readArray+0x50>
jmp    11a6 <readArray+0x76>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
@.str.1 = [4 x i8] c"%lf\00"
define i32 @readArray(i32* %0, i8* %1, i32 %2, double* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca double*
%10 = alloca i8*
%11 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store double* %3, double** %9
store i32 0, i32* %11
%12 = load i8*, i8** %7
%13 = load i32, i32* %8
%14 = load i32*, i32** %6
%15 = call i32 @fgets(i8* %12, i32 %13, i32* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %4
store i32 0, i32* %5
br label %34
18: ; preds = %4
%19 = load i8*, i8** %7
%20 = call i8* @strtok(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %20, i8** %10
br label %21
21: ; preds = %24, %18
%22 = load i8*, i8** %10
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i8*, i8** %10
%26 = load double*, double** %9
%27 = load i32, i32* %11
%28 = add nsw i32 %27, 1
store i32 %28, i32* %11
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds double, double* %26, i64 %29
%31 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %30)
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %32, i8** %10
br label %21
33: ; preds = %21
store i32 1, i32* %5
br label %34
34: ; preds = %33, %17
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
@.str.1 = [4 x i8] c"%lf\00"
define i32 @readArray(i32* nocapture %0, i8* %1, i32 %2, double* %3) {
%5 = tail call i32 @fgets(i8* %1, i32 %2, i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4
%8 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i8* %8, null
br i1 %9, label %18, label %10
10: ; preds = %7, %10
%11 = phi i64 [ %13, %10 ], [ 0, %7 ]
%12 = phi i8* [ %16, %10 ], [ %8, %7 ]
%13 = add nuw i64 %11, 1
%14 = getelementptr inbounds double, double* %3, i64 %11
%15 = tail call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %14)
%16 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %10
18: ; preds = %10, %7, %4
%19 = phi i32 [ 0, %4 ], [ 1, %7 ], [ 1, %10 ]
ret i32 %19
}