#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 */
int /*<<< orphan*/ divide_array_number_inplace(double *, int, int, int);
int /*<<< orphan*/ subtract_array_array(double *, double *, double *, int, int);
void calculate_velocities(double *vx, double *vy, double *vz, double *xi,
                          double *yi, double *zi, int nlns, int timestep) {
  double *ptr_a, *ptr_b, *ptr_v;
  ptr_v = &(vx[1]);
  ptr_a = &(xi[2]);
  ptr_b = &(xi[0]);
  subtract_array_array(ptr_v, ptr_a, ptr_b, 1, nlns - 2);
  divide_array_number_inplace(ptr_v, 2. * timestep, 1, nlns - 1);
  vx[0] = (xi[1] - xi[0]) / timestep;
  vx[nlns - 1] = (xi[nlns - 1] - xi[nlns - 2]) / timestep;
  ptr_v = &(vy[1]);
  ptr_a = &(yi[2]);
  ptr_b = &(yi[0]);
  subtract_array_array(ptr_v, ptr_a, ptr_b, 1, nlns - 2);
  divide_array_number_inplace(ptr_v, 2. * timestep, 1, nlns - 1);
  vy[0] = (yi[1] - yi[0]) / timestep;
  vy[nlns - 1] = (yi[nlns - 1] - yi[nlns - 2]) / timestep;
  ptr_v = &(vz[1]);
  ptr_a = &(zi[2]);
  ptr_b = &(zi[0]);
  subtract_array_array(ptr_v, ptr_a, ptr_b, 1, nlns - 2);
  divide_array_number_inplace(ptr_v, 2. * timestep, 1, nlns - 1);
  vz[0] = (zi[1] - zi[0]) / timestep;
  vz[nlns - 1] = (zi[nlns - 1] - zi[nlns - 2]) / timestep;
}


x86 assembly (clang, -O0):
<calculate_velocities>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x10(%rbp),%r8d
sub    $0x2,%r8d
mov    $0x1,%ecx
call   1030 <subtract_array_array@plt>
mov    -0x48(%rbp),%rdi
cvtsi2sdl 0x18(%rbp),%xmm1
movsd  0xe6b(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%edx
call   1040 <divide_array_number_inplace@plt>
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
cvtsi2sdl 0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl 0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x10(%rbp),%r8d
sub    $0x2,%r8d
mov    $0x1,%ecx
call   1030 <subtract_array_array@plt>
mov    -0x48(%rbp),%rdi
cvtsi2sdl 0x18(%rbp),%xmm1
movsd  0xda3(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%edx
call   1040 <divide_array_number_inplace@plt>
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  (%rax),%xmm0
cvtsi2sdl 0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl 0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x10(%rbp),%r8d
sub    $0x2,%r8d
mov    $0x1,%ecx
call   1030 <subtract_array_array@plt>
mov    -0x48(%rbp),%rdi
cvtsi2sdl 0x18(%rbp),%xmm1
movsd  0xcdb(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%edx
call   1040 <divide_array_number_inplace@plt>
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
subsd  (%rax),%xmm0
cvtsi2sdl 0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl 0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
mov    0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_velocities>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,%rbp
mov    %rcx,%r12
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r15
movslq 0x60(%rsp),%r13
lea    0x8(%rdi),%r14
lea    0x10(%rcx),%rsi
lea    -0x2(%r13),%r8d
mov    %r8d,0x14(%rsp)
mov    %r14,%rdi
mov    %rcx,%rdx
mov    $0x1,%ecx
call   1030 <subtract_array_array@plt>
cvtsi2sdl 0x68(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%esi
mov    %esi,0x10(%rsp)
lea    -0x1(%r13),%ecx
mov    %ecx,0x4(%rsp)
mov    %r14,%rdi
mov    $0x1,%edx
call   1040 <divide_array_number_inplace@plt>
movsd  0x8(%r12),%xmm0
subsd  (%r12),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
movsd  -0x8(%r12,%r13,8),%xmm0
subsd  -0x10(%r12,%r13,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%r15,%r13,8)
mov    %rbx,%r14
add    $0x8,%rbx
lea    0x10(%rbp),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
mov    $0x1,%ecx
mov    0x14(%rsp),%r15d
mov    %r15d,%r8d
call   1030 <subtract_array_array@plt>
mov    %rbx,%rdi
mov    0x10(%rsp),%r12d
mov    %r12d,%esi
mov    $0x1,%edx
mov    0x4(%rsp),%ecx
call   1040 <divide_array_number_inplace@plt>
movsd  0x8(%rbp),%xmm0
subsd  0x0(%rbp),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
movsd  -0x8(%rbp,%r13,8),%xmm0
subsd  -0x10(%rbp,%r13,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%r14,%r13,8)
mov    0x18(%rsp),%rbp
lea    0x8(%rbp),%rbx
mov    0x20(%rsp),%rdx
lea    0x10(%rdx),%rsi
mov    %rbx,%rdi
mov    %rdx,%r14
mov    $0x1,%ecx
mov    %r15d,%r8d
call   1030 <subtract_array_array@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    0x4(%rsp),%ecx
call   1040 <divide_array_number_inplace@plt>
movsd  0x8(%r14),%xmm0
subsd  (%r14),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp)
movsd  -0x8(%r14,%r13,8),%xmm0
subsd  -0x10(%r14,%r13,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp,%r13,8)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calculate_velocities(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, i32 %6, i32 %7) {
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
store double* %0, double** %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store double* %4, double** %13
store double* %5, double** %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%20 = load double*, double** %9
%21 = getelementptr inbounds double, double* %20, i64 1
store double* %21, double** %19
%22 = load double*, double** %12
%23 = getelementptr inbounds double, double* %22, i64 2
store double* %23, double** %17
%24 = load double*, double** %12
%25 = getelementptr inbounds double, double* %24, i64 0
store double* %25, double** %18
%26 = load double*, double** %19
%27 = load double*, double** %17
%28 = load double*, double** %18
%29 = load i32, i32* %15
%30 = sub nsw i32 %29, 2
%31 = call i32 @subtract_array_array(double* %26, double* %27, double* %28, i32 1, i32 %30)
%32 = load double*, double** %19
%33 = load i32, i32* %16
%34 = sitofp i32 %33 to double
%35 = fmul double 2.000000e+00, %34
%36 = fptosi double %35 to i32
%37 = load i32, i32* %15
%38 = sub nsw i32 %37, 1
%39 = call i32 @divide_array_number_inplace(double* %32, i32 %36, i32 1, i32 %38)
%40 = load double*, double** %12
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = load double*, double** %12
%44 = getelementptr inbounds double, double* %43, i64 0
%45 = load double, double* %44
%46 = fsub double %42, %45
%47 = load i32, i32* %16
%48 = sitofp i32 %47 to double
%49 = fdiv double %46, %48
%50 = load double*, double** %9
%51 = getelementptr inbounds double, double* %50, i64 0
store double %49, double* %51
%52 = load double*, double** %12
%53 = load i32, i32* %15
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %52, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %12
%59 = load i32, i32* %15
%60 = sub nsw i32 %59, 2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %58, i64 %61
%63 = load double, double* %62
%64 = fsub double %57, %63
%65 = load i32, i32* %16
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = load double*, double** %9
%69 = load i32, i32* %15
%70 = sub nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %68, i64 %71
store double %67, double* %72
%73 = load double*, double** %10
%74 = getelementptr inbounds double, double* %73, i64 1
store double* %74, double** %19
%75 = load double*, double** %13
%76 = getelementptr inbounds double, double* %75, i64 2
store double* %76, double** %17
%77 = load double*, double** %13
%78 = getelementptr inbounds double, double* %77, i64 0
store double* %78, double** %18
%79 = load double*, double** %19
%80 = load double*, double** %17
%81 = load double*, double** %18
%82 = load i32, i32* %15
%83 = sub nsw i32 %82, 2
%84 = call i32 @subtract_array_array(double* %79, double* %80, double* %81, i32 1, i32 %83)
%85 = load double*, double** %19
%86 = load i32, i32* %16
%87 = sitofp i32 %86 to double
%88 = fmul double 2.000000e+00, %87
%89 = fptosi double %88 to i32
%90 = load i32, i32* %15
%91 = sub nsw i32 %90, 1
%92 = call i32 @divide_array_number_inplace(double* %85, i32 %89, i32 1, i32 %91)
%93 = load double*, double** %13
%94 = getelementptr inbounds double, double* %93, i64 1
%95 = load double, double* %94
%96 = load double*, double** %13
%97 = getelementptr inbounds double, double* %96, i64 0
%98 = load double, double* %97
%99 = fsub double %95, %98
%100 = load i32, i32* %16
%101 = sitofp i32 %100 to double
%102 = fdiv double %99, %101
%103 = load double*, double** %10
%104 = getelementptr inbounds double, double* %103, i64 0
store double %102, double* %104
%105 = load double*, double** %13
%106 = load i32, i32* %15
%107 = sub nsw i32 %106, 1
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %105, i64 %108
%110 = load double, double* %109
%111 = load double*, double** %13
%112 = load i32, i32* %15
%113 = sub nsw i32 %112, 2
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %111, i64 %114
%116 = load double, double* %115
%117 = fsub double %110, %116
%118 = load i32, i32* %16
%119 = sitofp i32 %118 to double
%120 = fdiv double %117, %119
%121 = load double*, double** %10
%122 = load i32, i32* %15
%123 = sub nsw i32 %122, 1
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds double, double* %121, i64 %124
store double %120, double* %125
%126 = load double*, double** %11
%127 = getelementptr inbounds double, double* %126, i64 1
store double* %127, double** %19
%128 = load double*, double** %14
%129 = getelementptr inbounds double, double* %128, i64 2
store double* %129, double** %17
%130 = load double*, double** %14
%131 = getelementptr inbounds double, double* %130, i64 0
store double* %131, double** %18
%132 = load double*, double** %19
%133 = load double*, double** %17
%134 = load double*, double** %18
%135 = load i32, i32* %15
%136 = sub nsw i32 %135, 2
%137 = call i32 @subtract_array_array(double* %132, double* %133, double* %134, i32 1, i32 %136)
%138 = load double*, double** %19
%139 = load i32, i32* %16
%140 = sitofp i32 %139 to double
%141 = fmul double 2.000000e+00, %140
%142 = fptosi double %141 to i32
%143 = load i32, i32* %15
%144 = sub nsw i32 %143, 1
%145 = call i32 @divide_array_number_inplace(double* %138, i32 %142, i32 1, i32 %144)
%146 = load double*, double** %14
%147 = getelementptr inbounds double, double* %146, i64 1
%148 = load double, double* %147
%149 = load double*, double** %14
%150 = getelementptr inbounds double, double* %149, i64 0
%151 = load double, double* %150
%152 = fsub double %148, %151
%153 = load i32, i32* %16
%154 = sitofp i32 %153 to double
%155 = fdiv double %152, %154
%156 = load double*, double** %11
%157 = getelementptr inbounds double, double* %156, i64 0
store double %155, double* %157
%158 = load double*, double** %14
%159 = load i32, i32* %15
%160 = sub nsw i32 %159, 1
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %158, i64 %161
%163 = load double, double* %162
%164 = load double*, double** %14
%165 = load i32, i32* %15
%166 = sub nsw i32 %165, 2
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %164, i64 %167
%169 = load double, double* %168
%170 = fsub double %163, %169
%171 = load i32, i32* %16
%172 = sitofp i32 %171 to double
%173 = fdiv double %170, %172
%174 = load double*, double** %11
%175 = load i32, i32* %15
%176 = sub nsw i32 %175, 1
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %174, i64 %177
store double %173, double* %178
ret void
}

LLVM IR (-O2):
define void @calculate_velocities(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, i32 %6, i32 %7) {
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = getelementptr inbounds double, double* %3, i64 2
%11 = add nsw i32 %6, -2
%12 = tail call i32 @subtract_array_array(double* %9, double* %10, double* %3, i32 1, i32 %11)
%13 = sitofp i32 %7 to double
%14 = fmul double %13, 2.000000e+00
%15 = fptosi double %14 to i32
%16 = add nsw i32 %6, -1
%17 = tail call i32 @divide_array_number_inplace(double* %9, i32 %15, i32 1, i32 %16)
%18 = getelementptr inbounds double, double* %3, i64 1
%19 = load double, double* %18
%20 = load double, double* %3
%21 = fsub double %19, %20
%22 = fdiv double %21, %13
store double %22, double* %0
%23 = sext i32 %16 to i64
%24 = getelementptr inbounds double, double* %3, i64 %23
%25 = load double, double* %24
%26 = sext i32 %11 to i64
%27 = getelementptr inbounds double, double* %3, i64 %26
%28 = load double, double* %27
%29 = fsub double %25, %28
%30 = fdiv double %29, %13
%31 = getelementptr inbounds double, double* %0, i64 %23
store double %30, double* %31
%32 = getelementptr inbounds double, double* %1, i64 1
%33 = getelementptr inbounds double, double* %4, i64 2
%34 = tail call i32 @subtract_array_array(double* %32, double* %33, double* %4, i32 1, i32 %11)
%35 = tail call i32 @divide_array_number_inplace(double* %32, i32 %15, i32 1, i32 %16)
%36 = getelementptr inbounds double, double* %4, i64 1
%37 = load double, double* %36
%38 = load double, double* %4
%39 = fsub double %37, %38
%40 = fdiv double %39, %13
store double %40, double* %1
%41 = getelementptr inbounds double, double* %4, i64 %23
%42 = load double, double* %41
%43 = getelementptr inbounds double, double* %4, i64 %26
%44 = load double, double* %43
%45 = fsub double %42, %44
%46 = fdiv double %45, %13
%47 = getelementptr inbounds double, double* %1, i64 %23
store double %46, double* %47
%48 = getelementptr inbounds double, double* %2, i64 1
%49 = getelementptr inbounds double, double* %5, i64 2
%50 = tail call i32 @subtract_array_array(double* %48, double* %49, double* %5, i32 1, i32 %11)
%51 = tail call i32 @divide_array_number_inplace(double* %48, i32 %15, i32 1, i32 %16)
%52 = getelementptr inbounds double, double* %5, i64 1
%53 = load double, double* %52
%54 = load double, double* %5
%55 = fsub double %53, %54
%56 = fdiv double %55, %13
store double %56, double* %2
%57 = getelementptr inbounds double, double* %5, i64 %23
%58 = load double, double* %57
%59 = getelementptr inbounds double, double* %5, i64 %26
%60 = load double, double* %59
%61 = fsub double %58, %60
%62 = fdiv double %61, %13
%63 = getelementptr inbounds double, double* %2, i64 %23
store double %62, double* %63
ret void
}