#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 */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
float *wbImportVector(const char *fileName, int *inputLength) {
  int i, n;
  FILE *vectorFile;
  float *vector;
  printf("wbImportVector fileName is \"%s\"\n", fileName);
  if (strcmp(fileName, "") == 0) {
    *inputLength = 0;
    fprintf(stderr, "input vector file name is \"\" (empty string)\n");
    exit(-1);
  }
  vectorFile = fopen(fileName, "r");
  printf("here\n");
  if (vectorFile == NULL) {
    fprintf(stderr, "can\'t open input vector file \"%s\"\n", fileName);
    *inputLength = 0;
    exit(-1);
  }
  if (fscanf(vectorFile, "%d", &n) == EOF) {
    fprintf(stderr, "premature EOF in input vector file\n");
    *inputLength = 0;
    exit(-1);
  }
  vector = (float *)malloc(n * sizeof(float));
  if (vector == NULL) {
    fprintf(stderr, "can\'t allocate host memory for input vector\n");
    *inputLength = 0;
    exit(-1);
  }
  for (i = 0; i < n; i++) {
    if (fscanf(vectorFile, "%f", &vector[i]) == EOF) {
      fprintf(stderr, "only got %d floats in input vector file %s\n", i + 1,
              fileName);
      *inputLength = 0;
      exit(-1);
    }
  }
  *inputLength = n;
  return vector;
}


x86 assembly (clang, -O0):
<wbImportVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xedb(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d7 <wbImportVector+0x67>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
jne    1233 <wbImportVector+0xc3>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xe3b(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    0x2d98(%rip),%rcx
cmp    (%rcx),%rax
jne    1284 <wbImportVector+0x114>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1090 <exit@plt>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12cd <wbImportVector+0x15d>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1090 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1359 <wbImportVector+0x1e9>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    0x2ce0(%rip),%rcx
cmp    (%rcx),%rax
jne    1346 <wbImportVector+0x1d6>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x8(%rbp),%rcx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1090 <exit@plt>
jmp    134b <wbImportVector+0x1db>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12d4 <wbImportVector+0x164>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wbImportVector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe65(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12b6 <wbImportVector+0x136>
lea    0xe8a(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
mov    %rax,%r13
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
test   %r13,%r13
je     12dd <wbImportVector+0x15d>
lea    0xe88(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x2de7(%rip),%r15
cmp    (%r15),%rax
je     12f9 <wbImportVector+0x179>
mov    %rbx,0x8(%rsp)
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1320 <wbImportVector+0x1a0>
mov    %rax,%r14
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1267 <wbImportVector+0xe7>
mov    %rbp,0x10(%rsp)
lea    0xe8c(%rip),%rbp
mov    %r14,%r12
xor    %ebx,%ebx
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    (%r15),%rax
je     1280 <wbImportVector+0x100>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x4,%r12
cmp    %rax,%rbx
jl     1240 <wbImportVector+0xc0>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
add    $0x1,%ebx
lea    0xe37(%rip),%rsi
mov    %ebx,%edx
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x8(%rsp),%rax
movl   $0x0,(%rax)
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
movl   $0x0,(%rbx)
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
lea    0xd63(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1310 <wbImportVector+0x190>
mov    0x2cd8(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
movl   $0x0,(%rbx)
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
lea    0xd6a(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    12a1 <wbImportVector+0x121>

LLVM IR (-O0):
@.str = [33 x i8] c"wbImportVector fileName is \22%s\22\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.2 = [45 x i8] c"input vector file name is \22\22 (empty string)\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"here\0A\00"
@.str.5 = [35 x i8] c"can't open input vector file \22%s\22\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.7 = [36 x i8] c"premature EOF in input vector file\0A\00"
@.str.8 = [45 x i8] c"can't allocate host memory for input vector\0A\00"
@.str.9 = [3 x i8] c"%f\00"
@.str.10 = [44 x i8] c"only got %d floats in input vector file %s\0A\00"
define float* @wbImportVector(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca float*
store i8* %0, i8** %3
store i32* %1, i32** %4
%9 = load i8*, i8** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32*, i32** %4
store i32 0, i32* %15
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load i8*, i8** %3
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %21, i32** %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32*, i32** %7
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %31
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %3
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %27)
%29 = load i32*, i32** %4
store i32 0, i32* %29
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %19
%32 = load i32*, i32** %7
%33 = call i64 (i32*, i8*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%34 = load i64, i64* @EOF
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%39 = load i32*, i32** %4
store i32 0, i32* %39
%40 = call i32 @exit(i32 -1)
unreachable
41: ; preds = %31
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 4
%45 = trunc i64 %44 to i32
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to float*
store float* %47, float** %8
%48 = load float*, float** %8
%49 = icmp eq float* %48, null
br i1 %49, label %50, label %55
50: ; preds = %41
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
%53 = load i32*, i32** %4
store i32 0, i32* %53
%54 = call i32 @exit(i32 -1)
unreachable
55: ; preds = %41
store i32 0, i32* %5
br label %56
56: ; preds = %78, %55
%57 = load i32, i32* %5
%58 = load i32, i32* %6
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %81
60: ; preds = %56
%61 = load i32*, i32** %7
%62 = load float*, float** %8
%63 = load i32, i32* %5
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds float, float* %62, i64 %64
%66 = call i64 (i32*, i8*, ...) @fscanf(i32* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), float* %65)
%67 = load i64, i64* @EOF
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %77
69: ; preds = %60
%70 = load i32, i32* @stderr
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
%73 = load i8*, i8** %3
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), i32 %72, i8* %73)
%75 = load i32*, i32** %4
store i32 0, i32* %75
%76 = call i32 @exit(i32 -1)
unreachable
77: ; preds = %60
br label %78
78: ; preds = %77
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %56
81: ; preds = %56
%82 = load i32, i32* %6
%83 = load i32*, i32** %4
store i32 %82, i32* %83
%84 = load float*, float** %8
ret float* %84
}

LLVM IR (-O2):
@.str = [33 x i8] c"wbImportVector fileName is \22%s\22\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.2 = [45 x i8] c"input vector file name is \22\22 (empty string)\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.5 = [35 x i8] c"can't open input vector file \22%s\22\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.7 = [36 x i8] c"premature EOF in input vector file\0A\00"
@.str.8 = [45 x i8] c"can't allocate host memory for input vector\0A\00"
@.str.9 = [3 x i8] c"%f\00"
@.str.10 = [44 x i8] c"only got %d floats in input vector file %s\0A\00"
@str = [5 x i8] c"here\00"
define float* @wbImportVector(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
store i32 0, i32* %1
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%15 = icmp eq i32* %13, null
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %0)
store i32 0, i32* %1
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %12
%21 = call i64 (i32*, i8*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %20
%29 = load i32, i32* %3
%30 = shl i32 %29, 2
%31 = call i64 @malloc(i32 %30)
%32 = inttoptr i64 %31 to float*
%33 = icmp eq i64 %31, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = load i32, i32* %3
%36 = icmp sgt i32 %35, 0
br i1 %36, label %41, label %58
37: ; preds = %28
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
%40 = call i32 @exit(i32 -1)
unreachable
41: ; preds = %34, %53
%42 = phi i64 [ %54, %53 ], [ 0, %34 ]
%43 = getelementptr inbounds float, float* %32, i64 %42
%44 = call i64 (i32*, i8*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), float* %43)
%45 = load i64, i64* @EOF
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %53
47: ; preds = %41
%48 = trunc i64 %42 to i32
%49 = load i32, i32* @stderr
%50 = add nuw nsw i32 %48, 1
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), i32 %50, i8* %0)
store i32 0, i32* %1
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %41
%54 = add nuw nsw i64 %42, 1
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = icmp slt i64 %54, %56
br i1 %57, label %41, label %58
58: ; preds = %53, %34
%59 = phi i32 [ %35, %34 ], [ %55, %53 ]
store i32 %59, i32* %1
ret float* %32
}