#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 */

/* Variables and functions */
int /*<<< orphan*/ Fatal(char *, int);
char *getword(char **);
int sscanf(char *, char *, float *);
void readfloat(char *line, int n, float x[]) {
  int i;
  for (i = 0; i < n; i++) {
    char *str = getword(&line);
    if (!str)
      Fatal("Premature EOL reading %d floats\n", n);
    if (sscanf(str, "%f", x + i) != 1)
      Fatal("Error reading float %d\n", i);
  }
}


x86 assembly (clang, -O0):
<readfloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c7 <readfloat+0x97>
lea    -0x8(%rbp),%rdi
call   1030 <getword@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117d <readfloat+0x4d>
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1050 <Fatal@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe8a(%rip),%rsi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11b4 <readfloat+0x84>
mov    -0x1c(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1050 <Fatal@plt>
jmp    11b9 <readfloat+0x89>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <readfloat+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readfloat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %esi,%esi
jle    11af <readfloat+0x7f>
mov    %rdx,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
mov    %rsp,%r12
lea    0xecc(%rip),%rbp
jmp    116d <readfloat+0x3d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x4,%r15
cmp    %rbx,%r14
je     11af <readfloat+0x7f>
mov    %r12,%rdi
call   1030 <getword@plt>
mov    %rax,%r13
test   %rax,%rax
jne    118c <readfloat+0x5c>
lea    0xe7c(%rip),%rdi
mov    %r14d,%esi
call   1050 <Fatal@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1160 <readfloat+0x30>
lea    0xe7e(%rip),%rdi
mov    %ebx,%esi
call   1050 <Fatal@plt>
jmp    1160 <readfloat+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [33 x i8] c"Premature EOL reading %d floats\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [24 x i8] c"Error reading float %d\0A\00"
define void @readfloat(i8* %0, i32 %1, float* %2) {
%4 = alloca i8*
store i8* %0, i8** %4
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %21
%9 = phi i64 [ 0, %6 ], [ %22, %21 ]
%10 = call i8* @getword(i8** %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @Fatal(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %14
14: ; preds = %12, %8
%15 = getelementptr inbounds float, float* %2, i64 %9
%16 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = trunc i64 %9 to i32
%20 = call i32 @Fatal(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %14
%22 = add nuw nsw i64 %9, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %24, label %8
24: ; preds = %21, %3
ret void
}