#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ strcmp(char *, char *);
int read_vecs(int *one, double *two, double *three) {
  FILE *fp;
  char line[100];
  fp = fopen("vector_in.dat", "r");
  fscanf(fp, "%s %d", line, one);
  if (strcmp(line, "dim") != 0 || *one < 1) {
    return -1;
  }
  int count = *one, count2 = *one;
  fscanf(fp, "%s", line);
  int i = 0;
  while (count-- != 0) {
    fscanf(fp, "%lf", (two + i++));
  }
  fscanf(fp, "%s", line);
  i = 0;
  while (count2-- != 0) {
    fscanf(fp, "%lf", (three + i++));
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<read_vecs>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xea2(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11b5 <read_vecs+0x75>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jge    11c1 <read_vecs+0x81>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c6 <read_vecs+0x186>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x9c(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x94(%rbp)
cmp    $0x0,%eax
je     124b <read_vecs+0x10b>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x9c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x9c(%rbp)
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
jmp    11fc <read_vecs+0xbc>
mov    -0x28(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x9c(%rbp)
mov    -0x98(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x98(%rbp)
cmp    $0x0,%eax
je     12bd <read_vecs+0x17d>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x9c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x9c(%rbp)
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
jmp    126e <read_vecs+0x12e>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_vecs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xea2(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe9c(%rip),%rsi
mov    %rsp,%r13
mov    %rax,%rdi
mov    %r13,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe88(%rip),%rsi
mov    %r13,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1232 <read_vecs+0xf2>
mov    (%r12),%r13d
test   %r13d,%r13d
jle    1232 <read_vecs+0xf2>
lea    0xe67(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe56(%rip),%r12
mov    %r13d,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x8,%rbx
add    $0xffffffff,%ebp
jne    11d0 <read_vecs+0x90>
lea    0xe2a(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe19(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x8,%r15
add    $0xffffffff,%r13d
jne    1210 <read_vecs+0xd0>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"vector_in.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%s %d\00"
@.str.3 = [4 x i8] c"dim\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%lf\00"
define i32 @read_vecs(i32* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32*
%9 = alloca [100 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store double* %1, double** %6
store double* %2, double** %7
%13 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %8
%14 = load i32*, i32** %8
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%16 = load i32*, i32** %5
%17 = call i32 (i32*, i8*, ...) @fscanf(i32* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32* %16)
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %3
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %26
25: ; preds = %21, %3
store i32 -1, i32* %4
br label %65
26: ; preds = %21
%27 = load i32*, i32** %5
%28 = load i32, i32* %27
store i32 %28, i32* %10
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
store i32 %30, i32* %11
%31 = load i32*, i32** %8
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%33 = call i32 (i32*, i8*, ...) @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %32)
store i32 0, i32* %12
br label %34
34: ; preds = %38, %26
%35 = load i32, i32* %10
%36 = add nsw i32 %35, -1
store i32 %36, i32* %10
%37 = icmp ne i32 %35, 0
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = load i32*, i32** %8
%40 = load double*, double** %6
%41 = load i32, i32* %12
%42 = add nsw i32 %41, 1
store i32 %42, i32* %12
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds double, double* %40, i64 %43
%45 = call i32 (i32*, i8*, ...) @fscanf(i32* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %44)
br label %34
46: ; preds = %34
%47 = load i32*, i32** %8
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%49 = call i32 (i32*, i8*, ...) @fscanf(i32* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %48)
store i32 0, i32* %12
br label %50
50: ; preds = %54, %46
%51 = load i32, i32* %11
%52 = add nsw i32 %51, -1
store i32 %52, i32* %11
%53 = icmp ne i32 %51, 0
br i1 %53, label %54, label %62
54: ; preds = %50
%55 = load i32*, i32** %8
%56 = load double*, double** %7
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds double, double* %56, i64 %59
%61 = call i32 (i32*, i8*, ...) @fscanf(i32* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %60)
br label %50
62: ; preds = %50
%63 = load i32*, i32** %8
%64 = call i32 @fclose(i32* %63)
br label %65
65: ; preds = %62, %25
%66 = load i32, i32* %4
ret i32 %66
}

LLVM IR (-O2):
@.str = [14 x i8] c"vector_in.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%s %d\00"
@.str.3 = [4 x i8] c"dim\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%lf\00"
define i32 @read_vecs(i32* %0, double* %1, double* %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32* %0)
%8 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %3
%11 = load i32, i32* %0
%12 = icmp slt i32 %11, 1
br i1 %12, label %35, label %13
13: ; preds = %10
%14 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %19, %15 ]
%17 = phi i32 [ %11, %13 ], [ %18, %15 ]
%18 = add nsw i32 %17, -1
%19 = add nuw nsw i64 %16, 1
%20 = getelementptr inbounds double, double* %1, i64 %16
%21 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %20)
%22 = icmp eq i32 %18, 0
br i1 %22, label %23, label %15
23: ; preds = %15
%24 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %29, %25 ]
%27 = phi i32 [ %11, %23 ], [ %28, %25 ]
%28 = add nsw i32 %27, -1
%29 = add nuw nsw i64 %26, 1
%30 = getelementptr inbounds double, double* %2, i64 %26
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %30)
%32 = icmp eq i32 %28, 0
br i1 %32, label %33, label %25
33: ; preds = %25
%34 = call i32 @fclose(i32* %6)
br label %35
35: ; preds = %3, %10, %33
ret i32 -1
}