#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*/ drive(int, long double *, long double *, long double *,
                         long double *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long double);
int fscanf(int /*<<< orphan*/ *, char *, long double *);
void main(void) {
  int k, N = 0;
  long double v[100002];
  long double x[100002];
  long double w[100002];
  long double c[100002];
  FILE *fid;
  ;
  fid = fopen("data.bin", "r");
  while (!feof(fid)) {
    if (fscanf(fid, "%Lf", &c[N]) == 1)
      ++N;
  }
  fclose(fid);
  fid = fopen("data_x.bin", "r");
  for (k = 0; k < N; k++) {
    fscanf(fid, "%Lf", &x[k]);
  }
  fclose(fid);
  fid = fopen("data_w.bin", "r");
  for (k = 0; k < N; k++) {
    fscanf(fid, "%Lf", &w[k]);
  }
  fclose(fid);
  drive(N, c, x, w, v);
  fid = fopen("results.bin", "w+");
  for (k = 0; k < N; k++)
    fprintf(fid, "%33.33Lg\n", v[k]);
  fclose(fid);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61a8b0,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x61a898(%rbp)
mov    -0x61a898(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ad <main+0x4d>
jmp    11e9 <main+0x89>
mov    -0x61a898(%rbp),%rdi
movslq -0x8(%rbp),%rax
lea    -0x61a890(%rbp),%rdx
shl    $0x4,%rax
add    %rax,%rdx
lea    0xe3e(%rip),%rsi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11e4 <main+0x84>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <main+0x2c>
mov    -0x61a898(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe13(%rip),%rdi
lea    0xe06(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x61a898(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1255 <main+0xf5>
mov    -0x61a898(%rbp),%rdi
movslq -0x4(%rbp),%rax
lea    -0x30d450(%rbp),%rdx
shl    $0x4,%rax
add    %rax,%rdx
lea    0xdc9(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1216 <main+0xb6>
mov    -0x61a898(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdb2(%rip),%rdi
lea    0xd9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x61a898(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c1 <main+0x161>
mov    -0x61a898(%rbp),%rdi
movslq -0x4(%rbp),%rax
lea    -0x493e70(%rbp),%rdx
shl    $0x4,%rax
add    %rax,%rdx
lea    0xd5d(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1282 <main+0x122>
mov    -0x61a898(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%edi
lea    -0x61a890(%rbp),%rsi
lea    -0x30d450(%rbp),%rdx
lea    -0x493e70(%rbp),%rcx
lea    -0x186a30(%rbp),%r8
call   1080 <drive@plt>
lea    0xd2d(%rip),%rdi
lea    0xd32(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x61a898(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1353 <main+0x1f3>
mov    -0x61a898(%rbp),%rdi
movslq -0x4(%rbp),%rax
shl    $0x4,%rax
fldt   -0x186a30(%rbp,%rax,1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xcf4(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1312 <main+0x1b2>
mov    -0x61a898(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x61a8b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a898,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <feof@plt>
xor    %r13d,%r13d
test   %eax,%eax
jne    11d1 <main+0x71>
xor    %r13d,%r13d
lea    0xe6b(%rip),%r15
mov    %r13d,%eax
shl    $0x4,%rax
lea    (%rsp,%rax,1),%rdx
add    $0x10,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fscanf@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%r13d
mov    %r14,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11a0 <main+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xe2f(%rip),%rdi
lea    0xe22(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
mov    %r13d,%r12d
test   %r13d,%r13d
je     1228 <main+0xc8>
lea    0x30d450(%rsp),%rbx
lea    0xe05(%rip),%r15
mov    %r12,%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x10,%rbx
add    $0xffffffffffffffff,%rbp
jne    1210 <main+0xb0>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xde3(%rip),%rdi
lea    0xdcb(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %r13d,%r13d
je     1278 <main+0x118>
lea    0x186a30(%rsp),%rbx
lea    0xdb1(%rip),%r15
mov    %r12,%rbp
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x10,%rbx
add    $0xffffffffffffffff,%rbp
jne    1260 <main+0x100>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0x10(%rsp),%rsi
lea    0x30d450(%rsp),%rdx
lea    0x186a30(%rsp),%rcx
lea    0x493e70(%rsp),%r8
mov    %r13d,%edi
call   1080 <drive@plt>
lea    0xd79(%rip),%rdi
lea    0xd7e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %r13d,%r13d
je     12ee <main+0x18e>
shl    $0x4,%r12
xor    %ebp,%ebp
lea    0xd67(%rip),%rbx
nopl   (%rax)
fldt   0x493e70(%rsp,%rbp,1)
fstpt  (%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <fprintf@plt>
add    $0x10,%rbp
cmp    %rbp,%r12
jne    12d0 <main+0x170>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x61a898,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"data.bin\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%Lf\00"
@.str.3 = [11 x i8] c"data_x.bin\00"
@.str.4 = [11 x i8] c"data_w.bin\00"
@.str.5 = [12 x i8] c"results.bin\00"
@.str.6 = [3 x i8] c"w+\00"
@.str.7 = [10 x i8] c"%33.33Lg\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100002 x x86_fp80]
%4 = alloca [100002 x x86_fp80]
%5 = alloca [100002 x x86_fp80]
%6 = alloca [100002 x x86_fp80]
%7 = alloca i32*
store i32 0, i32* %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
br label %9
9: ; preds = %24, %0
%10 = load i32*, i32** %7
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = load i32*, i32** %7
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %6, i64 0, i64 %17
%19 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %24
24: ; preds = %21, %14
br label %9
25: ; preds = %9
%26 = load i32*, i32** %7
%27 = call i32 @fclose(i32* %26)
%28 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %7
store i32 0, i32* %1
br label %29
29: ; preds = %39, %25
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i32*, i32** %7
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %4, i64 0, i64 %36
%38 = call i32 @fscanf(i32* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %1
%41 = add nsw i32 %40, 1
store i32 %41, i32* %1
br label %29
42: ; preds = %29
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
%45 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %45, i32** %7
store i32 0, i32* %1
br label %46
46: ; preds = %56, %42
%47 = load i32, i32* %1
%48 = load i32, i32* %2
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %59
50: ; preds = %46
%51 = load i32*, i32** %7
%52 = load i32, i32* %1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %5, i64 0, i64 %53
%55 = call i32 @fscanf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %54)
br label %56
56: ; preds = %50
%57 = load i32, i32* %1
%58 = add nsw i32 %57, 1
store i32 %58, i32* %1
br label %46
59: ; preds = %46
%60 = load i32*, i32** %7
%61 = call i32 @fclose(i32* %60)
%62 = load i32, i32* %2
%63 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %6, i64 0, i64 0
%64 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %4, i64 0, i64 0
%65 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %5, i64 0, i64 0
%66 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %3, i64 0, i64 0
%67 = call i32 @drive(i32 %62, x86_fp80* %63, x86_fp80* %64, x86_fp80* %65, x86_fp80* %66)
%68 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %68, i32** %7
store i32 0, i32* %1
br label %69
69: ; preds = %80, %59
%70 = load i32, i32* %1
%71 = load i32, i32* %2
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %83
73: ; preds = %69
%74 = load i32*, i32** %7
%75 = load i32, i32* %1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %3, i64 0, i64 %76
%78 = load x86_fp80, x86_fp80* %77
%79 = call i32 @fprintf(i32* %74, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %78)
br label %80
80: ; preds = %73
%81 = load i32, i32* %1
%82 = add nsw i32 %81, 1
store i32 %82, i32* %1
br label %69
83: ; preds = %69
%84 = load i32*, i32** %7
%85 = call i32 @fclose(i32* %84)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"data.bin\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%Lf\00"
@.str.3 = [11 x i8] c"data_x.bin\00"
@.str.4 = [11 x i8] c"data_w.bin\00"
@.str.5 = [12 x i8] c"results.bin\00"
@.str.6 = [3 x i8] c"w+\00"
@.str.7 = [10 x i8] c"%33.33Lg\0A\00"
define void @main() {
%1 = alloca [100002 x x86_fp80]
%2 = alloca [100002 x x86_fp80]
%3 = alloca [100002 x x86_fp80]
%4 = alloca [100002 x x86_fp80]
%5 = bitcast [100002 x x86_fp80]* %1 to i8*
%6 = bitcast [100002 x x86_fp80]* %2 to i8*
%7 = bitcast [100002 x x86_fp80]* %3 to i8*
%8 = bitcast [100002 x x86_fp80]* %4 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @feof(i32* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %0, %12
%13 = phi i32 [ %19, %12 ], [ 0, %0 ]
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %4, i64 0, i64 %14
%16 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %15)
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %13, %18
%20 = call i32 @feof(i32* %9)
%21 = icmp eq i32 %20, 0
br i1 %21, label %12, label %22
22: ; preds = %12, %0
%23 = phi i32 [ 0, %0 ], [ %19, %12 ]
%24 = call i32 @fclose(i32* %9)
%25 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32 %23, 0
br i1 %26, label %35, label %27
27: ; preds = %22
%28 = zext i32 %23 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %33, %29 ]
%31 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %2, i64 0, i64 %30
%32 = call i32 @fscanf(i32* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %31)
%33 = add nuw nsw i64 %30, 1
%34 = icmp eq i64 %33, %28
br i1 %34, label %35, label %29
35: ; preds = %29, %22
%36 = call i32 @fclose(i32* %25)
%37 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br i1 %26, label %46, label %38
38: ; preds = %35
%39 = zext i32 %23 to i64
br label %40
40: ; preds = %38, %40
%41 = phi i64 [ 0, %38 ], [ %44, %40 ]
%42 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %3, i64 0, i64 %41
%43 = call i32 @fscanf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %42)
%44 = add nuw nsw i64 %41, 1
%45 = icmp eq i64 %44, %39
br i1 %45, label %46, label %40
46: ; preds = %40, %35
%47 = call i32 @fclose(i32* %37)
%48 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %4, i64 0, i64 0
%49 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %2, i64 0, i64 0
%50 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %3, i64 0, i64 0
%51 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %1, i64 0, i64 0
%52 = call i32 @drive(i32 %23, x86_fp80* %48, x86_fp80* %49, x86_fp80* %50, x86_fp80* %51)
%53 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br i1 %26, label %63, label %54
54: ; preds = %46
%55 = zext i32 %23 to i64
br label %56
56: ; preds = %54, %56
%57 = phi i64 [ 0, %54 ], [ %61, %56 ]
%58 = getelementptr inbounds [100002 x x86_fp80], [100002 x x86_fp80]* %1, i64 0, i64 %57
%59 = load x86_fp80, x86_fp80* %58
%60 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %59)
%61 = add nuw nsw i64 %57, 1
%62 = icmp eq i64 %61, %55
br i1 %62, label %63, label %56
63: ; preds = %56, %46
%64 = call i32 @fclose(i32* %53)
ret void
}