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

/* Variables and functions */
char *read_word(char *, int, char const *);
scalar_t__ strlen(char *);
scalar_t__ to_float(char *, float *);
int read_floats(const char *str, float *buf, unsigned int size) {
  unsigned int w;
  for (w = 0; w < size; w++) {
    char word[32];
    str = read_word(word, (sizeof(word) / sizeof(*word)), str);
    if (strlen(word) == 0)
      break;
    if (to_float(word, &buf[w]))
      return -1;
    if (str == NULL)
      break;
  }
  return w;
}


x86 assembly (clang, -O0):
<read_floats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11d4 <read_floats+0xa4>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x20,%esi
call   1050 <read_word@plt>
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1184 <read_floats+0x54>
jmp    11d4 <read_floats+0xa4>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <to_float@plt>
cmp    $0x0,%rax
je     11b1 <read_floats+0x81>
movl   $0xffffffff,-0x4(%rbp)
jmp    11da <read_floats+0xaa>
cmpq   $0x0,-0x10(%rbp)
jne    11c1 <read_floats+0x91>
jmp    11d4 <read_floats+0xa4>
jmp    11c6 <read_floats+0x96>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114a <read_floats+0x1a>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_floats>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
test   %edx,%edx
je     1180 <read_floats+0x60>
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %edx,%r13d
xor    %r14d,%r14d
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
call   1040 <read_word@plt>
cmpb   $0x0,(%rsp)
je     118b <read_floats+0x6b>
mov    %rax,%r15
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <to_float@plt>
test   %rax,%rax
jne    1185 <read_floats+0x65>
test   %r15,%r15
je     118b <read_floats+0x6b>
add    $0x1,%r14
add    $0x4,%rbx
cmp    %r14,%r13
jne    1140 <read_floats+0x20>
mov    %r13d,%r14d
jmp    118b <read_floats+0x6b>
xor    %r14d,%r14d
jmp    118b <read_floats+0x6b>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @read_floats(i8* %0, float* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [32 x i8]
store i8* %0, i8** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %36, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %7
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %39
14: ; preds = %10
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = call i8* @read_word(i8* %15, i32 32, i8* %16)
store i8* %17, i8** %5
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
br label %39
22: ; preds = %14
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%24 = load float*, float** %6
%25 = load i32, i32* %8
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = call i64 @to_float(i8* %23, float* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %22
store i32 -1, i32* %4
br label %41
31: ; preds = %22
%32 = load i8*, i8** %5
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %31
br label %39
35: ; preds = %31
br label %36
36: ; preds = %35
%37 = load i32, i32* %8
%38 = add i32 %37, 1
store i32 %38, i32* %8
br label %10
39: ; preds = %34, %21, %10
%40 = load i32, i32* %8
store i32 %40, i32* %4
br label %41
41: ; preds = %39, %30
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @read_floats(i8* %0, float* %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = icmp eq i32 %2, 0
br i1 %5, label %27, label %6
6: ; preds = %3
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %6, %24
%10 = phi i64 [ 0, %6 ], [ %25, %24 ]
%11 = phi i8* [ %0, %6 ], [ %12, %24 ]
%12 = call i8* @read_word(i8* %7, i32 32, i8* %11)
%13 = load i8, i8* %7
%14 = icmp eq i8 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %9
%16 = getelementptr inbounds float, float* %1, i64 %10
%17 = call i64 @to_float(i8* %7, float* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
br label %27
20: ; preds = %15
%21 = icmp eq i8* %12, null
br i1 %21, label %22, label %24
22: ; preds = %9, %20
%23 = trunc i64 %10 to i32
br label %27
24: ; preds = %20
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %27, label %9
27: ; preds = %24, %3, %22, %19
%28 = phi i32 [ -1, %19 ], [ %23, %22 ], [ 0, %3 ], [ %2, %24 ]
ret i32 %28
}