#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 */
char EOF;
int /*<<< orphan*/ EXIT_FAILURE;
float atof(char *);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
char fpeek(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strtok(char *, char *);
int ReadFileLine(FILE *pFile, float *matrix, int size) {
  char c = fpeek(pFile);
  if (c == EOF)
    return 0;
  char *strNumber;
  int bufSize = size * 30;
  char *buffer = (char *)calloc(bufSize, sizeof(char));
  int i = 0;
  if (fgets(buffer, bufSize, pFile)) {
    strNumber = strtok(buffer, " ");
    i = 0;
    while ((strNumber != NULL) && (i < size)) {
      matrix[i] = atof(strNumber);
      strNumber = strtok(NULL, " ");
      i++;
    }
    if (i < size) {
      printf("Error: Input line doesn't have enough elements, only %d\n", i);
      exit(EXIT_FAILURE);
    }
    free(buffer);
    return 1;
  } else {
    if (!feof(pFile)) {
      printf("Error: Reading from input file didn't finish successfully\n");
      exit(EXIT_FAILURE);
    }
    free(buffer);
    return 0;
  }
}


x86 assembly (clang, -O0):
<ReadFileLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <fpeek@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
mov    0x2e2e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11d1 <ReadFileLine+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1307 <ReadFileLine+0x177>
imul   $0x1e,-0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12c9 <ReadFileLine+0x139>
mov    -0x38(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x3d(%rbp)
je     1241 <ReadFileLine+0xb1>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setl   %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    1251 <ReadFileLine+0xc1>
jmp    1289 <ReadFileLine+0xf9>
mov    -0x28(%rbp),%rdi
call   1040 <atof@plt>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd8e(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1225 <ReadFileLine+0x95>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12b4 <ReadFileLine+0x124>
mov    -0x3c(%rbp),%esi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1307 <ReadFileLine+0x177>
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
jne    12f7 <ReadFileLine+0x167>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadFileLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r13
call   10a0 <fpeek@plt>
mov    0x2e28(%rip),%rcx
xor    %r12d,%r12d
cmp    (%rcx),%al
je     1286 <ReadFileLine+0xe6>
mov    %r15d,%ebp
shl    $0x5,%ebp
sub    %r15d,%ebp
sub    %r15d,%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r13,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1256 <ReadFileLine+0xb6>
lea    0xe01(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strtok@plt>
test   %rax,%rax
je     1273 <ReadFileLine+0xd3>
test   %r15d,%r15d
jle    1273 <ReadFileLine+0xd3>
mov    %rbx,%r13
mov    %r15d,%ebx
xor    %ebp,%ebp
lea    0xde0(%rip),%r15
mov    %rax,%rdi
call   1050 <atof@plt>
movss  %xmm0,(%r14,%rbp,4)
xor    %edi,%edi
mov    %r15,%rsi
call   10b0 <strtok@plt>
add    $0x1,%rbp
test   %rax,%rax
je     1246 <ReadFileLine+0xa6>
cmp    %rbx,%rbp
jb     1220 <ReadFileLine+0x80>
mov    $0x1,%r12d
cmp    %rbx,%rbp
mov    %r13,%rbx
jae    127e <ReadFileLine+0xde>
jmp    129a <ReadFileLine+0xfa>
mov    %r13,%rdi
call   1090 <feof@plt>
xor    %r12d,%r12d
test   %eax,%eax
jne    127e <ReadFileLine+0xde>
lea    0xdcf(%rip),%rdi
call   1040 <puts@plt>
jmp    12aa <ReadFileLine+0x10a>
mov    $0x1,%r12d
test   %r15d,%r15d
jg     1298 <ReadFileLine+0xf8>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
lea    0xd61(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [2 x i8] c" \00"
@.str.1 = [57 x i8] c"Error: Input line doesn't have enough elements, only %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [59 x i8] c"Error: Reading from input file didn't finish successfully\0A\00"
define i32 @ReadFileLine(i32* %0, float* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32* %0, i32** %5
store float* %1, float** %6
store i32 %2, i32* %7
%13 = load i32*, i32** %5
%14 = call signext i8 @fpeek(i32* %13)
store i8 %14, i8* %8
%15 = load i8, i8* %8
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 0, i32* %4
br label %77
21: ; preds = %3
%22 = load i32, i32* %7
%23 = mul nsw i32 %22, 30
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = call i64 @calloc(i32 %24, i32 1)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %11
store i32 0, i32* %12
%27 = load i8*, i8** %11
%28 = load i32, i32* %10
%29 = load i32*, i32** %5
%30 = call i64 @fgets(i8* %27, i32 %28, i32* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %66
32: ; preds = %21
%33 = load i8*, i8** %11
%34 = call i8* @strtok(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %34, i8** %9
store i32 0, i32* %12
br label %35
35: ; preds = %44, %32
%36 = load i8*, i8** %9
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %12
%40 = load i32, i32* %7
%41 = icmp slt i32 %39, %40
br label %42
42: ; preds = %38, %35
%43 = phi i1 [ false, %35 ], [ %41, %38 ]
br i1 %43, label %44, label %54
44: ; preds = %42
%45 = load i8*, i8** %9
%46 = call float @atof(i8* %45)
%47 = load float*, float** %6
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds float, float* %47, i64 %49
store float %46, float* %50
%51 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %51, i8** %9
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %12
br label %35
54: ; preds = %42
%55 = load i32, i32* %12
%56 = load i32, i32* %7
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %63
58: ; preds = %54
%59 = load i32, i32* %12
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %54
%64 = load i8*, i8** %11
%65 = call i32 @free(i8* %64)
store i32 1, i32* %4
br label %77
66: ; preds = %21
%67 = load i32*, i32** %5
%68 = call i32 @feof(i32* %67)
%69 = icmp ne i32 %68, 0
br i1 %69, label %74, label %70
70: ; preds = %66
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %66
%75 = load i8*, i8** %11
%76 = call i32 @free(i8* %75)
store i32 0, i32* %4
br label %77
77: ; preds = %74, %63, %20
%78 = load i32, i32* %4
ret i32 %78
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [2 x i8] c" \00"
@.str.1 = [57 x i8] c"Error: Input line doesn't have enough elements, only %d\0A\00"
@EXIT_FAILURE = global i32 0
@str = [58 x i8] c"Error: Reading from input file didn't finish successfully\00"
define i32 @ReadFileLine(i32* %0, float* nocapture writeonly %1, i32 %2) {
%4 = tail call signext i8 @fpeek(i32* %0)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %48, label %7
7: ; preds = %3
%8 = mul nsw i32 %2, 30
%9 = tail call i64 @calloc(i32 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i64 @fgets(i8* %10, i32 %8, i32* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %38, label %13
13: ; preds = %7
%14 = tail call i8* @strtok(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i8* %14, null
%16 = icmp sgt i32 %2, 0
%17 = and i1 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %13
%19 = zext i32 %2 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %26, %20 ]
%22 = phi i8* [ %14, %18 ], [ %25, %20 ]
%23 = tail call float @atof(i8* %22)
%24 = getelementptr inbounds float, float* %1, i64 %21
store float %23, float* %24
%25 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = add nuw nsw i64 %21, 1
%27 = icmp ne i8* %25, null
%28 = icmp ult i64 %26, %19
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %20, label %30
30: ; preds = %20
%31 = trunc i64 %26 to i32
br i1 %28, label %33, label %45
32: ; preds = %13
br i1 %16, label %33, label %45
33: ; preds = %30, %32
%34 = phi i32 [ %31, %30 ], [ 0, %32 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %7
%39 = tail call i32 @feof(i32* %0)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %38, %32, %30
%46 = phi i32 [ 1, %30 ], [ 1, %32 ], [ 0, %38 ]
%47 = tail call i32 @free(i8* %10)
br label %48
48: ; preds = %45, %3
%49 = phi i32 [ 0, %3 ], [ %46, %45 ]
ret i32 %49
}