#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*/ ecitoecef(double, double, double, double, double, double,
                             double, double *, double *, double *, double *,
                             double *, double *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double, double,
                           double, double, double, double);
int fscanf(int /*<<< orphan*/ *, char *, double *, double *, double *, double *,
           double *, double *, double *);
double utc2gha(int, int, int, int, double);
void fix_state_vectors(int year, int julianDay, int hour, int min, double sec) {
  double time, x, y, z, xv, yv, zv;
  double gha;
  double otime, ox, oy, oz, oxv, oyv, ozv;
  FILE *fp, *fpo;
  fp = fopen("propagated_state_vector.txt", "r");
  fpo = fopen("fixed_state_vector.txt", "w");
  while (fscanf(fp, "%lf %lf %lf %lf %lf %lf %lf", &time, &x, &y, &z, &xv, &yv,
                &zv) == 7) {
    otime = time * 60.0;
    gha = utc2gha(year, julianDay, hour, min, sec + otime);
    ecitoecef(gha, x, y, z, xv, yv, zv, &ox, &oy, &oz, &oxv, &oyv, &ozv);
    fprintf(fpo, "%14.8lf %14.8lf %14.8lf %14.8lf %14.9lf %14.9lf %14.9lf \n",
            otime, ox * 1000.0, oy * 1000.0, oz * 1000.0, oxv * 1000.0,
            oyv * 1000.0, ozv * 1000.0);
  }
  fclose(fp);
  fclose(fpo);
}


x86 assembly (clang, -O0):
<fix_state_vectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x98(%rbp)
lea    0xe91(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x98(%rbp),%rdi
lea    0xe89(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
lea    -0x40(%rbp),%r11
lea    -0x48(%rbp),%r10
lea    -0x50(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <fscanf@plt>
cmp    $0x7,%eax
jne    12df <fix_state_vectors+0x17f>
movsd  0xe0a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
movsd  -0x18(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
call   1050 <utc2gha@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm5
movsd  -0x50(%rbp),%xmm6
lea    -0x68(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x78(%rbp),%rdx
lea    -0x80(%rbp),%rcx
lea    -0x88(%rbp),%r8
lea    -0x90(%rbp),%r9
call   1080 <ecitoecef@plt>
mov    -0xa0(%rbp),%rdi
movsd  -0x60(%rbp),%xmm0
movsd  0xd7e(%rip),%xmm1
mulsd  -0x68(%rbp),%xmm1
movsd  0xd71(%rip),%xmm2
mulsd  -0x70(%rbp),%xmm2
movsd  0xd64(%rip),%xmm3
mulsd  -0x78(%rbp),%xmm3
movsd  0xd57(%rip),%xmm4
mulsd  -0x80(%rbp),%xmm4
movsd  0xd4a(%rip),%xmm5
mulsd  -0x88(%rbp),%xmm5
ff
movsd  0xd3a(%rip),%xmm6
mulsd  -0x90(%rbp),%xmm6
ff
lea    0xd8e(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11b0 <fix_state_vectors+0x50>
mov    -0x98(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xa0(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_state_vectors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  %xmm0,0x38(%rsp)
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%r13d
lea    0xe89(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe91(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
lea    0x10(%rsp),%r10
lea    0x18(%rsp),%r11
lea    0xe81(%rip),%rsi
lea    0x38(%rsp),%rdx
lea    0x30(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x20(%rsp),%r9
mov    %rbx,%rdi
push   %rax
push   %r10
push   %r11
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1040 <fscanf@plt>
add    $0x20,%rsp
cmp    $0x7,%eax
jne    1305 <fix_state_vectors+0x1a5>
movsd  0x30(%rsp),%xmm0
mulsd  0xdf0(%rip),%xmm0
movsd  %xmm0,0x40(%rsp)
addsd  0x38(%rsp),%xmm0
mov    %r13d,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1050 <utc2gha@plt>
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm5
movsd  (%rsp),%xmm6
lea    0x70(%rsp),%rdi
lea    0x68(%rsp),%rsi
lea    0x60(%rsp),%rdx
lea    0x58(%rsp),%rcx
lea    0x50(%rsp),%r8
lea    0x48(%rsp),%r9
call   1080 <ecitoecef@plt>
movsd  0x70(%rsp),%xmm1
movsd  0xd87(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0x68(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  0x60(%rsp),%xmm3
mulsd  %xmm0,%xmm3
movsd  0x58(%rsp),%xmm4
mulsd  %xmm0,%xmm4
movsd  0x50(%rsp),%xmm5
mulsd  %xmm0,%xmm5
movsd  0x48(%rsp),%xmm6
mulsd  %xmm0,%xmm6
mov    %rbp,%rdi
lea    0xda2(%rip),%rsi
movsd  0x40(%rsp),%xmm0
call   1060 <fprintf@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
lea    0xd6d(%rip),%rsi
lea    0x38(%rsp),%rdx
lea    0x30(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x20(%rsp),%r9
lea    0x8(%rsp),%rax
push   %rax
lea    0x18(%rsp),%rax
push   %rax
lea    0x28(%rsp),%rax
push   %rax
jmp    11f0 <fix_state_vectors+0x90>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"propagated_state_vector.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"fixed_state_vector.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [28 x i8] c"%lf %lf %lf %lf %lf %lf %lf\00"
@.str.5 = [58 x i8] c"%14.8lf %14.8lf %14.8lf %14.8lf %14.9lf %14.9lf %14.9lf \0A\00"
define void @fix_state_vectors(i32 %0, i32 %1, i32 %2, i32 %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca i32*
%27 = alloca i32*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double %4, double* %10
%28 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %26
%29 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %29, i32** %27
br label %30
30: ; preds = %34, %5
%31 = load i32*, i32** %26
%32 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double* %11, double* %12, double* %13, double* %14, double* %15, double* %16, double* %17)
%33 = icmp eq i32 %32, 7
br i1 %33, label %34, label %68
34: ; preds = %30
%35 = load double, double* %11
%36 = fmul double %35, 6.000000e+01
store double %36, double* %19
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load double, double* %10
%42 = load double, double* %19
%43 = fadd double %41, %42
%44 = call double @utc2gha(i32 %37, i32 %38, i32 %39, i32 %40, double %43)
store double %44, double* %18
%45 = load double, double* %18
%46 = load double, double* %12
%47 = load double, double* %13
%48 = load double, double* %14
%49 = load double, double* %15
%50 = load double, double* %16
%51 = load double, double* %17
%52 = call i32 @ecitoecef(double %45, double %46, double %47, double %48, double %49, double %50, double %51, double* %20, double* %21, double* %22, double* %23, double* %24, double* %25)
%53 = load i32*, i32** %27
%54 = load double, double* %19
%55 = load double, double* %20
%56 = fmul double %55, 1.000000e+03
%57 = load double, double* %21
%58 = fmul double %57, 1.000000e+03
%59 = load double, double* %22
%60 = fmul double %59, 1.000000e+03
%61 = load double, double* %23
%62 = fmul double %61, 1.000000e+03
%63 = load double, double* %24
%64 = fmul double %63, 1.000000e+03
%65 = load double, double* %25
%66 = fmul double %65, 1.000000e+03
%67 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), double %54, double %56, double %58, double %60, double %62, double %64, double %66)
br label %30
68: ; preds = %30
%69 = load i32*, i32** %26
%70 = call i32 @fclose(i32* %69)
%71 = load i32*, i32** %27
%72 = call i32 @fclose(i32* %71)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"propagated_state_vector.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [23 x i8] c"fixed_state_vector.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [28 x i8] c"%lf %lf %lf %lf %lf %lf %lf\00"
@.str.5 = [58 x i8] c"%14.8lf %14.8lf %14.8lf %14.8lf %14.9lf %14.9lf %14.9lf \0A\00"
define void @fix_state_vectors(i32 %0, i32 %1, i32 %2, i32 %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = bitcast double* %6 to i8*
%20 = bitcast double* %7 to i8*
%21 = bitcast double* %8 to i8*
%22 = bitcast double* %9 to i8*
%23 = bitcast double* %10 to i8*
%24 = bitcast double* %11 to i8*
%25 = bitcast double* %12 to i8*
%26 = bitcast double* %13 to i8*
%27 = bitcast double* %14 to i8*
%28 = bitcast double* %15 to i8*
%29 = bitcast double* %16 to i8*
%30 = bitcast double* %17 to i8*
%31 = bitcast double* %18 to i8*
%32 = tail call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double* %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12)
%35 = icmp eq i32 %34, 7
br i1 %35, label %36, label %63
36: ; preds = %5, %36
%37 = load double, double* %6
%38 = fmul double %37, 6.000000e+01
%39 = fadd double %38, %4
%40 = call double @utc2gha(i32 %0, i32 %1, i32 %2, i32 %3, double %39)
%41 = load double, double* %7
%42 = load double, double* %8
%43 = load double, double* %9
%44 = load double, double* %10
%45 = load double, double* %11
%46 = load double, double* %12
%47 = call i32 @ecitoecef(double %40, double %41, double %42, double %43, double %44, double %45, double %46, double* %13, double* %14, double* %15, double* %16, double* %17, double* %18)
%48 = load double, double* %13
%49 = fmul double %48, 1.000000e+03
%50 = load double, double* %14
%51 = fmul double %50, 1.000000e+03
%52 = load double, double* %15
%53 = fmul double %52, 1.000000e+03
%54 = load double, double* %16
%55 = fmul double %54, 1.000000e+03
%56 = load double, double* %17
%57 = fmul double %56, 1.000000e+03
%58 = load double, double* %18
%59 = fmul double %58, 1.000000e+03
%60 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), double %38, double %49, double %51, double %53, double %55, double %57, double %59)
%61 = call i32 @fscanf(i32* %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), double* %6, double* %7, double* %8, double* %9, double* %10, double* %11, double* %12)
%62 = icmp eq i32 %61, 7
br i1 %62, label %36, label %63
63: ; preds = %36, %5
%64 = call i32 @fclose(i32* %32)
%65 = call i32 @fclose(i32* %33)
ret void
}