#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 *, ...);
int /*<<< orphan*/ printf(char *);
void readInput(double input[], char *outputFileName) {
  char tokenPtr[300] = {0};
  double dt;
  double simulationDuration;
  double stepNumber;
  int i;
  double speed;
  double altitude;
  FILE *fPtr;
  if ((fPtr = fopen("input.txt", "r")) == NULL) {
    printf("File could not be opened\n");
  } else {
    fscanf(fPtr, "%lg", &dt);
    fscanf(fPtr, "%s", tokenPtr);
    fscanf(fPtr, "%lg", &simulationDuration);
    fscanf(fPtr, "%s", tokenPtr);
    fscanf(fPtr, "%s", outputFileName);
    fscanf(fPtr, "%s", tokenPtr);
    fscanf(fPtr, "%lg", &speed);
    fscanf(fPtr, "%s", tokenPtr);
    fscanf(fPtr, "%lg", &altitude);
    fscanf(fPtr, "%s", tokenPtr);
    fscanf(fPtr, "%lg", &stepNumber);
    if (stepNumber > 20) {
      printf("Step number too big, no command considered.\n");
    } else {
      fscanf(fPtr, "%s", tokenPtr);
      for (i = 0; i < stepNumber * 3; i++) {
        fscanf(fPtr, "%lg", &input[i + 5]);
      }
    }
    fclose(fPtr);
  }
  input[0] = dt;
  input[1] = simulationDuration;
  input[2] = speed;
  input[3] = altitude;
  input[4] = stepNumber;
}


x86 assembly (clang, -O0):
<readInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1050 <memset@plt>
lea    0xe93(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x178(%rbp)
cmp    $0x0,%rax
jne    11ab <readInput+0x5b>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
jmp    139f <readInput+0x24f>
mov    -0x178(%rbp),%rdi
lea    0xe7d(%rip),%rsi
lea    -0x148(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xe5e(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    0xe45(%rip),%rsi
lea    -0x150(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    0xdd8(%rip),%rsi
lea    -0x168(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    0xda0(%rip),%rsi
lea    -0x170(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x178(%rbp),%rdi
lea    0xd68(%rip),%rsi
lea    -0x158(%rbp),%rdx
mov    $0x0,%al
call   1060 <fscanf@plt>
movsd  -0x158(%rbp),%xmm0
ff
movsd  0xd14(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1307 <readInput+0x1b7>
lea    0xd40(%rip),%rdi
call   1040 <printf@plt>
jmp    1393 <readInput+0x243>
mov    -0x178(%rbp),%rdi
lea    -0x140(%rbp),%rdx
lea    0xd1e(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
movl   $0x0,-0x15c(%rbp)
cvtsi2sdl -0x15c(%rbp),%xmm1
ff
movsd  0xccb(%rip),%xmm0
mulsd  -0x158(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    138e <readInput+0x23e>
mov    -0x178(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x15c(%rbp),%eax
add    $0x5,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
lea    0xcc3(%rip),%rsi
mov    $0x0,%al
call   1060 <fscanf@plt>
mov    -0x15c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x15c(%rbp)
jmp    132d <readInput+0x1dd>
jmp    1393 <readInput+0x243>
mov    -0x178(%rbp),%rdi
call   1030 <fclose@plt>
movsd  -0x148(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x150(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x168(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x170(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x158(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x168,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x30(%rsp),%rdi
mov    $0x12c,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe91(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1285 <readInput+0x135>
mov    %rax,%r12
lea    0xe7e(%rip),%r15
lea    0x28(%rsp),%rdx
mov    %rax,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0xe69(%rip),%r13
lea    0x30(%rsp),%rbp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0x20(%rsp),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0x18(%rsp),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0x10(%rsp),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xd8e(%rip),%xmm0
jbe    1296 <readInput+0x146>
lea    0xda8(%rip),%rdi
call   1030 <puts@plt>
jmp    1312 <readInput+0x1c2>
lea    0xdc3(%rip),%rdi
call   1030 <puts@plt>
jmp    1338 <readInput+0x1e8>
lea    0xd83(%rip),%rsi
lea    0x30(%rsp),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xd4e(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1312 <readInput+0x1c2>
lea    0x28(%r14),%rbp
mov    $0x1,%ebx
lea    0xd48(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xd03(%rip),%xmm1
add    $0x8,%rbp
add    $0x1,%ebx
ucomisd %xmm0,%xmm1
ja     12e0 <readInput+0x190>
mov    %r12,%rdi
call   1040 <fclose@plt>
movsd  0x28(%rsp),%xmm4
movsd  0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
movsd  %xmm4,(%r14)
movsd  %xmm3,0x8(%r14)
movsd  %xmm2,0x10(%r14)
movsd  %xmm1,0x18(%r14)
movsd  %xmm0,0x20(%r14)
add    $0x168,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [26 x i8] c"File could not be opened\0A\00"
@.str.3 = [4 x i8] c"%lg\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [45 x i8] c"Step number too big, no command considered.\0A\00"
define void @readInput(double* %0, i8* %1) {
%3 = alloca double*
%4 = alloca i8*
%5 = alloca [300 x i8]
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32*
store double* %0, double** %3
store i8* %1, i8** %4
%13 = bitcast [300 x i8]* %5 to i8*
%14 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %12
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %76
18: ; preds = %2
%19 = load i32*, i32** %12
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %6)
%21 = load i32*, i32** %12
%22 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%23 = call i32 (i32*, i8*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%24 = load i32*, i32** %12
%25 = call i32 (i32*, i8*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %7)
%26 = load i32*, i32** %12
%27 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = load i32*, i32** %12
%30 = load i8*, i8** %4
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = load i32*, i32** %12
%33 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%34 = call i32 (i32*, i8*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = load i32*, i32** %12
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %10)
%37 = load i32*, i32** %12
%38 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%39 = call i32 (i32*, i8*, ...) @fscanf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = load i32*, i32** %12
%41 = call i32 (i32*, i8*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %11)
%42 = load i32*, i32** %12
%43 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%44 = call i32 (i32*, i8*, ...) @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i32*, i32** %12
%46 = call i32 (i32*, i8*, ...) @fscanf(i32* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %8)
%47 = load double, double* %8
%48 = fcmp ogt double %47, 2.000000e+01
br i1 %48, label %49, label %51
49: ; preds = %18
%50 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
br label %73
51: ; preds = %18
%52 = load i32*, i32** %12
%53 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%54 = call i32 (i32*, i8*, ...) @fscanf(i32* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %53)
store i32 0, i32* %9
br label %55
55: ; preds = %69, %51
%56 = load i32, i32* %9
%57 = sitofp i32 %56 to double
%58 = load double, double* %8
%59 = fmul double %58, 3.000000e+00
%60 = fcmp olt double %57, %59
br i1 %60, label %61, label %72
61: ; preds = %55
%62 = load i32*, i32** %12
%63 = load double*, double** %3
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %63, i64 %66
%68 = call i32 (i32*, i8*, ...) @fscanf(i32* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %67)
br label %69
69: ; preds = %61
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
br label %55
72: ; preds = %55
br label %73
73: ; preds = %72, %49
%74 = load i32*, i32** %12
%75 = call i32 @fclose(i32* %74)
br label %76
76: ; preds = %73, %16
%77 = load double, double* %6
%78 = load double*, double** %3
%79 = getelementptr inbounds double, double* %78, i64 0
store double %77, double* %79
%80 = load double, double* %7
%81 = load double*, double** %3
%82 = getelementptr inbounds double, double* %81, i64 1
store double %80, double* %82
%83 = load double, double* %10
%84 = load double*, double** %3
%85 = getelementptr inbounds double, double* %84, i64 2
store double %83, double* %85
%86 = load double, double* %11
%87 = load double*, double** %3
%88 = getelementptr inbounds double, double* %87, i64 3
store double %86, double* %88
%89 = load double, double* %8
%90 = load double*, double** %3
%91 = getelementptr inbounds double, double* %90, i64 4
store double %89, double* %91
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [4 x i8] c"%lg\00"
@.str.4 = [3 x i8] c"%s\00"
@str = [44 x i8] c"Step number too big, no command considered.\00"
@str.6 = [25 x i8] c"File could not be opened\00"
define void @readInput(double* %0, i8* %1) {
%3 = alloca [300 x i8]
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%10 = bitcast double* %4 to i8*
%11 = bitcast double* %5 to i8*
%12 = bitcast double* %6 to i8*
%13 = bitcast double* %7 to i8*
%14 = bitcast double* %8 to i8*
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
br label %58
19: ; preds = %2
%20 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %4)
%21 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%22 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %5)
%23 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%24 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%25 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%26 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %7)
%27 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %8)
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %6)
%31 = load double, double* %6
%32 = fcmp ogt double %31, 2.000000e+01
br i1 %32, label %33, label %35
33: ; preds = %19
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %51
35: ; preds = %19
%36 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%37 = load double, double* %6
%38 = fmul double %37, 3.000000e+00
%39 = fcmp ogt double %38, 0.000000e+00
br i1 %39, label %40, label %51
40: ; preds = %35, %40
%41 = phi i64 [ %45, %40 ], [ 0, %35 ]
%42 = add nuw nsw i64 %41, 5
%43 = getelementptr inbounds double, double* %0, i64 %42
%44 = call i32 (i32*, i8*, ...) @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %43)
%45 = add nuw i64 %41, 1
%46 = trunc i64 %45 to i32
%47 = sitofp i32 %46 to double
%48 = load double, double* %6
%49 = fmul double %48, 3.000000e+00
%50 = fcmp ogt double %49, %47
br i1 %50, label %40, label %51
51: ; preds = %40, %35, %33
%52 = call i32 @fclose(i32* %15)
%53 = load double, double* %4
%54 = load double, double* %5
%55 = load double, double* %7
%56 = load double, double* %8
%57 = load double, double* %6
br label %58
58: ; preds = %51, %17
%59 = phi double [ %57, %51 ], [ undef, %17 ]
%60 = phi double [ %56, %51 ], [ undef, %17 ]
%61 = phi double [ %55, %51 ], [ undef, %17 ]
%62 = phi double [ %54, %51 ], [ undef, %17 ]
%63 = phi double [ %53, %51 ], [ undef, %17 ]
store double %63, double* %0
%64 = getelementptr inbounds double, double* %0, i64 1
store double %62, double* %64
%65 = getelementptr inbounds double, double* %0, i64 2
store double %61, double* %65
%66 = getelementptr inbounds double, double* %0, i64 3
store double %60, double* %66
%67 = getelementptr inbounds double, double* %0, i64 4
store double %59, double* %67
ret void
}