#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 */

/* Variables and functions */
double cos(double);
int /*<<< orphan*/ gmst(double, double *, double *);
int /*<<< orphan*/ matvec(double **, double *, double *);
double sin(double);
void ecr2eci(double pos[], double vel[], double utsec, double pos_eci[],
             double vel_eci[]) {
  double a[3][3];
  double ap[3][3];
  double cth;
  double cthp;
  double sth;
  double sthp;
  double th;
  double thp;
  double vel_eci_1[3];
  double vel_eci_2[3];
  int i;
  gmst(utsec, &th, &thp);
  cth = cos(th);
  sth = sin(th);
  a[0][0] = cth;
  a[0][1] = -sth;
  a[0][2] = 0.0;
  a[1][0] = sth;
  a[1][1] = cth;
  a[1][2] = 0.0;
  a[2][0] = 0.0;
  a[2][1] = 0.0;
  a[2][2] = 1.0;
  matvec(a, pos, pos_eci);
  cthp = thp * cos(th);
  sthp = thp * sin(th);
  ap[0][0] = -sthp;
  ap[0][1] = -cthp;
  ap[0][2] = 0.0;
  ap[1][0] = cthp;
  ap[1][1] = -sthp;
  ap[1][2] = 0.0;
  ap[2][0] = 0.0;
  ap[2][1] = 0.0;
  ap[2][2] = 0.0;
  matvec(ap, pos, vel_eci_1);
  matvec(a, vel, vel_eci_2);
  for (i = 0; i < 3; i++) {
    vel_eci[i] = vel_eci_1[i] + vel_eci_2[i];
  }
  return;
}


x86 assembly (clang, -O0):
<ecr2eci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    -0xe8(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <gmst@plt>
movsd  -0xe8(%rbp),%xmm0
ff
call   1050 <cos@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xe8(%rbp),%xmm0
ff
call   1040 <sin@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0x70(%rbp)
movsd  -0xd8(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0x58(%rbp)
movsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdeb(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <matvec@plt>
movsd  -0xf0(%rbp),%xmm0
ff
movsd  %xmm0,-0x148(%rbp)
ff
movsd  -0xe8(%rbp),%xmm0
ff
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x148(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0xf0(%rbp),%xmm0
ff
movsd  %xmm0,-0x140(%rbp)
ff
movsd  -0xe8(%rbp),%xmm0
ff
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x140(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0xe0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xd0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xd0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xe0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x80(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x110(%rbp),%rdx
call   1060 <matvec@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x130(%rbp),%rdx
call   1060 <matvec@plt>
movl   $0x0,-0x134(%rbp)
cmpl   $0x3,-0x134(%rbp)
jge    13d2 <ecr2eci+0x292>
movslq -0x134(%rbp),%rax
movsd  -0x110(%rbp,%rax,8),%xmm0
ff ff
movslq -0x134(%rbp),%rax
addsd  -0x130(%rbp,%rax,8),%xmm0
ff ff
mov    -0x28(%rbp),%rax
movslq -0x134(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1381 <ecr2eci+0x241>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecr2eci>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x120,%rsp
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
lea    0x28(%rsp),%rsi
call   1030 <gmst@plt>
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x10(%rsp),%xmm2
movsd  %xmm2,0x80(%rsp)
movaps %xmm0,%xmm1
xorps  0xe60(%rip),%xmm1
movlps %xmm1,0x88(%rsp)
movq   $0x0,0x90(%rsp)
movsd  %xmm0,0x98(%rsp)
movsd  %xmm2,0xa0(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0xa8(%rsp)
movq   $0x0,0xb8(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0xc0(%rsp)
lea    0x80(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <matvec@plt>
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movaps %xmm1,0x30(%rsp)
call   1040 <sin@plt>
movapd 0xdba(%rip),%xmm1
movapd 0x30(%rsp),%xmm2
xorpd  %xmm1,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0xd0(%rsp)
movapd 0x10(%rsp),%xmm0
xorpd  %xmm0,%xmm1
movlpd %xmm1,0xd8(%rsp)
movq   $0x0,0xe0(%rsp)
movsd  %xmm0,0xe8(%rsp)
movsd  %xmm2,0xf0(%rsp)
xorpd  %xmm0,%xmm0
movupd %xmm0,0xf8(%rsp)
movupd %xmm0,0x108(%rsp)
lea    0xd0(%rsp),%rdi
lea    0x60(%rsp),%rdx
mov    %rbx,%rsi
call   1060 <matvec@plt>
lea    0x40(%rsp),%rdx
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <matvec@plt>
movapd 0x60(%rsp),%xmm0
addpd  0x40(%rsp),%xmm0
movupd %xmm0,(%r15)
movsd  0x70(%rsp),%xmm0
addsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x10(%r15)
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @ecr2eci(double* %0, double* %1, double %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca [3 x [3 x double]]
%12 = alloca [3 x [3 x double]]
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca [3 x double]
%20 = alloca [3 x double]
%21 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%22 = load double, double* %8
%23 = call i32 @gmst(double %22, double* %17, double* %18)
%24 = load double, double* %17
%25 = call double @cos(double %24)
store double %25, double* %13
%26 = load double, double* %17
%27 = call double @sin(double %26)
store double %27, double* %15
%28 = load double, double* %13
%29 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 0, i64 0
store double %28, double* %30
%31 = load double, double* %15
%32 = fneg double %31
%33 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%34 = getelementptr inbounds [3 x double], [3 x double]* %33, i64 0, i64 1
store double %32, double* %34
%35 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%36 = getelementptr inbounds [3 x double], [3 x double]* %35, i64 0, i64 2
store double 0.000000e+00, double* %36
%37 = load double, double* %15
%38 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 1
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 0
store double %37, double* %39
%40 = load double, double* %13
%41 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 1
%42 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 1
store double %40, double* %42
%43 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 1
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 0, i64 2
store double 0.000000e+00, double* %44
%45 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 2
%46 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 0, i64 0
store double 0.000000e+00, double* %46
%47 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 2
%48 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 0, i64 1
store double 0.000000e+00, double* %48
%49 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 2
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 0, i64 2
store double 1.000000e+00, double* %50
%51 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%52 = bitcast [3 x double]* %51 to double**
%53 = load double*, double** %6
%54 = load double*, double** %9
%55 = call i32 @matvec(double** %52, double* %53, double* %54)
%56 = load double, double* %18
%57 = load double, double* %17
%58 = call double @cos(double %57)
%59 = fmul double %56, %58
store double %59, double* %14
%60 = load double, double* %18
%61 = load double, double* %17
%62 = call double @sin(double %61)
%63 = fmul double %60, %62
store double %63, double* %16
%64 = load double, double* %16
%65 = fneg double %64
%66 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%67 = getelementptr inbounds [3 x double], [3 x double]* %66, i64 0, i64 0
store double %65, double* %67
%68 = load double, double* %14
%69 = fneg double %68
%70 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%71 = getelementptr inbounds [3 x double], [3 x double]* %70, i64 0, i64 1
store double %69, double* %71
%72 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%73 = getelementptr inbounds [3 x double], [3 x double]* %72, i64 0, i64 2
store double 0.000000e+00, double* %73
%74 = load double, double* %14
%75 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 1
%76 = getelementptr inbounds [3 x double], [3 x double]* %75, i64 0, i64 0
store double %74, double* %76
%77 = load double, double* %16
%78 = fneg double %77
%79 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 1
%80 = getelementptr inbounds [3 x double], [3 x double]* %79, i64 0, i64 1
store double %78, double* %80
%81 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 1
%82 = getelementptr inbounds [3 x double], [3 x double]* %81, i64 0, i64 2
store double 0.000000e+00, double* %82
%83 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 2
%84 = getelementptr inbounds [3 x double], [3 x double]* %83, i64 0, i64 0
store double 0.000000e+00, double* %84
%85 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 2
%86 = getelementptr inbounds [3 x double], [3 x double]* %85, i64 0, i64 1
store double 0.000000e+00, double* %86
%87 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 2
%88 = getelementptr inbounds [3 x double], [3 x double]* %87, i64 0, i64 2
store double 0.000000e+00, double* %88
%89 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%90 = bitcast [3 x double]* %89 to double**
%91 = load double*, double** %6
%92 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%93 = call i32 @matvec(double** %90, double* %91, double* %92)
%94 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %11, i64 0, i64 0
%95 = bitcast [3 x double]* %94 to double**
%96 = load double*, double** %7
%97 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 0
%98 = call i32 @matvec(double** %95, double* %96, double* %97)
store i32 0, i32* %21
br label %99
99: ; preds = %116, %5
%100 = load i32, i32* %21
%101 = icmp slt i32 %100, 3
br i1 %101, label %102, label %119
102: ; preds = %99
%103 = load i32, i32* %21
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 %104
%106 = load double, double* %105
%107 = load i32, i32* %21
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [3 x double], [3 x double]* %20, i64 0, i64 %108
%110 = load double, double* %109
%111 = fadd double %106, %110
%112 = load double*, double** %10
%113 = load i32, i32* %21
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %112, i64 %114
store double %111, double* %115
br label %116
116: ; preds = %102
%117 = load i32, i32* %21
%118 = add nsw i32 %117, 1
store i32 %118, i32* %21
br label %99
119: ; preds = %99
ret void
}

LLVM IR (-O2):
define void @ecr2eci(double* %0, double* %1, double %2, double* %3, double* nocapture writeonly %4) {
%6 = alloca [3 x [3 x double]]
%7 = alloca [3 x [3 x double]]
%8 = alloca double
%9 = alloca double
%10 = alloca [3 x double]
%11 = alloca [3 x double]
%12 = bitcast [3 x [3 x double]]* %6 to i8*
%13 = bitcast [3 x [3 x double]]* %7 to i8*
%14 = bitcast double* %8 to i8*
%15 = bitcast double* %9 to i8*
%16 = bitcast [3 x double]* %10 to i8*
%17 = bitcast [3 x double]* %11 to i8*
%18 = call i32 @gmst(double %2, double* %8, double* %9)
%19 = load double, double* %8
%20 = call double @cos(double %19)
%21 = load double, double* %8
%22 = call double @sin(double %21)
%23 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 0, i64 0
store double %20, double* %23
%24 = fneg double %22
%25 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 0, i64 1
store double %24, double* %25
%26 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 0, i64 2
store double 0.000000e+00, double* %26
%27 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 1, i64 0
store double %22, double* %27
%28 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 1, i64 1
store double %20, double* %28
%29 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 1, i64 2
%30 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 2, i64 2
%31 = bitcast double* %29 to i8*
store double 1.000000e+00, double* %30
%32 = bitcast [3 x [3 x double]]* %6 to double**
%33 = call i32 @matvec(double** %32, double* %0, double* %3)
%34 = load double, double* %9
%35 = load double, double* %8
%36 = call double @cos(double %35)
%37 = fmul double %34, %36
%38 = load double, double* %9
%39 = load double, double* %8
%40 = call double @sin(double %39)
%41 = fneg double %38
%42 = fmul double %40, %41
%43 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 0
store double %42, double* %43
%44 = fneg double %37
%45 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 1
store double %44, double* %45
%46 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 2
store double 0.000000e+00, double* %46
%47 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 0
store double %37, double* %47
%48 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 1
store double %42, double* %48
%49 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 2
%50 = bitcast [3 x [3 x double]]* %7 to double**
%51 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%52 = bitcast double* %49 to i8*
%53 = call i32 @matvec(double** %50, double* %0, double* %51)
%54 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%55 = call i32 @matvec(double** %32, double* %1, double* %54)
%56 = bitcast [3 x double]* %10 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = bitcast [3 x double]* %11 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = fadd <2 x double> %57, %59
%61 = bitcast double* %4 to <2 x double>*
store <2 x double> %60, <2 x double>* %61
%62 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%63 = load double, double* %62
%64 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%65 = load double, double* %64
%66 = fadd double %63, %65
%67 = getelementptr inbounds double, double* %4, i64 2
store double %66, double* %67
ret void
}