#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 */
double strtod(char *, char **);
scalar_t__ wf_next_argument(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ wf_skip_line(int /*<<< orphan*/ *);
int wf_parse_vector(double *vec, size_t dim, FILE *fp) {
  char *end, token[100];
  size_t i;
  for (i = 0; i < dim; i++) {
    if (wf_next_argument(token, sizeof token, fp) == 0) {
      return -1;
    }
    vec[i] = strtod(token, &end);
    if (end == token || *end != '\0') {
      return -1;
    }
  }
  wf_skip_line(fp);
  return 0;
}


x86 assembly (clang, -O0):
<wf_parse_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11fa <wf_parse_vector+0xca>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x64,%esi
call   1040 <wf_next_argument@plt>
cmp    $0x0,%rax
jne    118e <wf_parse_vector+0x5e>
movl   $0xffffffff,-0x4(%rbp)
jmp    120a <wf_parse_vector+0xda>
lea    -0x90(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <strtod@plt>
mov    -0x10(%rbp),%rax
mov    -0x98(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
lea    -0x90(%rbp),%rcx
cmp    %rcx,%rax
je     11d2 <wf_parse_vector+0xa2>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11de <wf_parse_vector+0xae>
movl   $0xffffffff,-0x4(%rbp)
jmp    120a <wf_parse_vector+0xda>
jmp    11e3 <wf_parse_vector+0xb3>
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x98(%rbp)
jmp    1152 <wf_parse_vector+0x22>
mov    -0x20(%rbp),%rdi
call   1050 <wf_skip_line@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wf_parse_vector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rdx,%r14
test   %rsi,%rsi
je     11a0 <wf_parse_vector+0x70>
mov    %rsi,%r12
mov    %rdi,%r15
xor    %r13d,%r13d
lea    0x10(%rsp),%rbx
mov    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1040 <wf_next_argument@plt>
test   %rax,%rax
je     11aa <wf_parse_vector+0x7a>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%r15,%r13,8)
mov    0x8(%rsp),%rax
cmp    %rbx,%rax
je     11aa <wf_parse_vector+0x7a>
cmpb   $0x0,(%rax)
jne    11aa <wf_parse_vector+0x7a>
add    $0x1,%r13
cmp    %r13,%r12
jne    1160 <wf_parse_vector+0x30>
mov    %r14,%rdi
call   1050 <wf_skip_line@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @wf_parse_vector(double* nocapture writeonly %0, i64 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = bitcast i8** %4 to i8*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = icmp eq i64 %1, 0
br i1 %8, label %24, label %11
9: ; preds = %20
%10 = icmp eq i64 %23, %1
br i1 %10, label %24, label %11
11: ; preds = %3, %9
%12 = phi i64 [ %23, %9 ], [ 0, %3 ]
%13 = call i64 @wf_next_argument(i8* %7, i32 100, i32* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %26, label %15
15: ; preds = %11
%16 = call double @strtod(i8* %7, i8** %4)
%17 = getelementptr inbounds double, double* %0, i64 %12
store double %16, double* %17
%18 = load i8*, i8** %4
%19 = icmp eq i8* %18, %7
br i1 %19, label %26, label %20
20: ; preds = %15
%21 = load i8, i8* %18
%22 = icmp eq i8 %21, 0
%23 = add nuw i64 %12, 1
br i1 %22, label %9, label %26
24: ; preds = %9, %3
%25 = call i32 @wf_skip_line(i32* %2)
br label %26
26: ; preds = %15, %20, %11, %24
%27 = phi i32 [ 0, %24 ], [ -1, %11 ], [ -1, %20 ], [ -1, %15 ]
ret i32 %27
}