#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__ malloc(int);
scalar_t__ strcmp(char *, char *);
int read_vecs(int *one, double **two, double **three) {
  FILE *fp;
  char line[128];
  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;
  *two = (double *)malloc(sizeof(double) * *one);
  *three = (double *)malloc(sizeof(double) * *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    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xe92(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c5 <read_vecs+0x75>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
jge    11d1 <read_vecs+0x81>
movl   $0xffffffff,-0x4(%rbp)
jmp    1314 <read_vecs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xb8(%rbp)
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0xbc(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xb4(%rbp)
cmp    $0x0,%eax
je     1296 <read_vecs+0x146>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0xbc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xbc(%rbp)
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
jmp    1244 <read_vecs+0xf4>
mov    -0x28(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0xbc(%rbp)
mov    -0xb8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xb8(%rbp)
cmp    $0x0,%eax
je     130b <read_vecs+0x1bb>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
mov    -0xbc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xbc(%rbp)
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
jmp    12b9 <read_vecs+0x169>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_vecs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xe8f(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r13
lea    0xe89(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1284 <read_vecs+0x134>
mov    (%r12),%ebx
test   %ebx,%ebx
jle    1284 <read_vecs+0x134>
lea    0x0(,%rbx,8),%edi
call   1060 <malloc@plt>
mov    %rax,(%r15)
mov    (%r12),%edi
shl    $0x3,%edi
call   1060 <malloc@plt>
mov    %rbp,0x8(%rsp)
mov    %rax,0x0(%rbp)
lea    0xe2f(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xe1c(%rip),%r12
xor    %ebp,%ebp
mov    %ebx,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    (%r15),%rdx
add    %rbp,%rdx
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x8,%rbp
add    $0xffffffff,%r14d
jne    1210 <read_vecs+0xc0>
lea    0xde6(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xdd3(%rip),%r15
xor    %ebp,%ebp
mov    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%rdx
add    %rbp,%rdx
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <fscanf@plt>
add    $0x8,%rbp
add    $0xffffffff,%ebx
jne    1260 <read_vecs+0x110>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x98,%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 [128 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 [128 x i8], [128 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 [128 x i8], [128 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 %83
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** %5
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = mul i64 8, %33
%35 = trunc i64 %34 to i32
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to double*
%38 = load double**, double*** %6
store double* %37, double** %38
%39 = load i32*, i32** %5
%40 = load i32, i32* %39
%41 = sext i32 %40 to i64
%42 = mul i64 8, %41
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to double*
%46 = load double**, double*** %7
store double* %45, double** %46
%47 = load i32*, i32** %8
%48 = getelementptr inbounds [128 x i8], [128 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, %26
%51 = load i32, i32* %10
%52 = add nsw i32 %51, -1
store i32 %52, i32* %10
%53 = icmp ne i32 %51, 0
br i1 %53, label %54, label %63
54: ; preds = %50
%55 = load i32*, i32** %8
%56 = load double**, double*** %6
%57 = load double*, double** %56
%58 = load i32, i32* %12
%59 = add nsw i32 %58, 1
store i32 %59, i32* %12
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds double, double* %57, i64 %60
%62 = call i32 (i32*, i8*, ...) @fscanf(i32* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %61)
br label %50
63: ; preds = %50
%64 = load i32*, i32** %8
%65 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%66 = call i32 (i32*, i8*, ...) @fscanf(i32* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %65)
store i32 0, i32* %12
br label %67
67: ; preds = %71, %63
%68 = load i32, i32* %11
%69 = add nsw i32 %68, -1
store i32 %69, i32* %11
%70 = icmp ne i32 %68, 0
br i1 %70, label %71, label %80
71: ; preds = %67
%72 = load i32*, i32** %8
%73 = load double**, double*** %7
%74 = load double*, double** %73
%75 = load i32, i32* %12
%76 = add nsw i32 %75, 1
store i32 %76, i32* %12
%77 = sext i32 %75 to i64
%78 = getelementptr inbounds double, double* %74, i64 %77
%79 = call i32 (i32*, i8*, ...) @fscanf(i32* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %78)
br label %67
80: ; preds = %67
%81 = load i32*, i32** %8
%82 = call i32 @fclose(i32* %81)
br label %83
83: ; preds = %80, %25
%84 = load i32, i32* %4
ret i32 %84
}

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** nocapture %1, double** nocapture %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 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 %44
10: ; preds = %3
%11 = load i32, i32* %0
%12 = icmp slt i32 %11, 1
br i1 %12, label %44, label %13
13: ; preds = %10
%14 = shl i32 %11, 3
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
store double* %16, double** %1
%17 = load i32, i32* %0
%18 = shl i32 %17, 3
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to double*
store double* %20, double** %2
%21 = 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 %22
22: ; preds = %13, %22
%23 = phi i64 [ 0, %13 ], [ %27, %22 ]
%24 = phi i32 [ %11, %13 ], [ %25, %22 ]
%25 = add nsw i32 %24, -1
%26 = load double*, double** %1
%27 = add nuw nsw i64 %23, 1
%28 = getelementptr inbounds double, double* %26, i64 %23
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %28)
%30 = icmp eq i32 %25, 0
br i1 %30, label %31, label %22
31: ; preds = %22
%32 = 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 %33
33: ; preds = %31, %33
%34 = phi i64 [ 0, %31 ], [ %38, %33 ]
%35 = phi i32 [ %11, %31 ], [ %36, %33 ]
%36 = add nsw i32 %35, -1
%37 = load double*, double** %2
%38 = add nuw nsw i64 %34, 1
%39 = getelementptr inbounds double, double* %37, i64 %34
%40 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), double* %39)
%41 = icmp eq i32 %36, 0
br i1 %41, label %42, label %33
42: ; preds = %33
%43 = call i32 @fclose(i32* %6)
br label %44
44: ; preds = %3, %10, %42
ret i32 -1
}