#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 RAND_MAX;
double pow(double, int);
int rand();
double sqrt(int);
double change_path(int x, double y[10], double v[10]) {
  double delta = 0.25, y_trial, dy2, dist, t_init, t_trial;
  y_trial = y[x] + (2 * rand() * 1.0 / RAND_MAX) * delta;
  dy2 = pow(y[x] - y[x + 1], 2);
  dist = sqrt(1 + dy2);
  t_init = dist / v[x + 1];
  dy2 = pow(y[x] - y[x - 1], 2);
  dist = sqrt(1 + dy2);
  t_init += dist / v[x];
  dy2 = pow(y_trial - y[x + 1], 2);
  dist = sqrt(1 + dy2);
  t_trial = dist / v[x + 1];
  dy2 = pow(y_trial - y[x - 1], 2);
  dist = sqrt(1 + dy2);
  t_trial += dist / v[x];
  if (t_trial < t_init)
    return y_trial;
  else
    return y[x];
}


x86 assembly (clang, -O0):
<change_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  0xebd(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    $0x0,%al
call   1050 <rand@plt>
movsd  -0x58(%rbp),%xmm1
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe83(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    0x2e60(%rip),%rax
cvtsi2sdl (%rax),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe28(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xdc3(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xd66(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xd09(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1349 <change_path+0x219>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    135b <change_path+0x22b>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_path>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
movslq %edi,%rbx
movsd  (%rsi,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <rand@plt>
add    %eax,%eax
cvtsi2sd %eax,%xmm1
mov    0x2e87(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
divsd  %xmm0,%xmm1
mulsd  0xe8c(%rip),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm0
subsd  0x8(%r15,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0xe69(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd %xmm0,0x20(%rsp)
movsd  (%r15,%rbx,8),%xmm0
subsd  -0x8(%r15,%rbx,8),%xmm0
movsd  0x8(%r14,%rbx,8),%xmm1
movaps %xmm1,0x10(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0xe2f(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
movhpd (%r14,%rbx,8),%xmm2
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  %xmm2,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x8(%r15,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0xde7(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  -0x8(%r15,%rbx,8),%xmm0
movsd  0x8(%r14,%rbx,8),%xmm1
movaps %xmm1,0x30(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
addsd  0xdad(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movapd 0x30(%rsp),%xmm1
movhpd (%r14,%rbx,8),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm1,%xmm2
movapd %xmm2,%xmm0
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm1,%xmm0
unpckhpd %xmm1,%xmm2
addpd  %xmm0,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
ucomisd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm0
ja     12ae <change_path+0x17e>
movsd  (%r15,%rbx,8),%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global i32 0
define double @change_path(i32 %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double 2.500000e-01, double* %8
%14 = load double*, double** %6
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = call i32 (...) @rand()
%20 = mul nsw i32 2, %19
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 1.000000e+00
%23 = load i32, i32* @RAND_MAX
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = load double, double* %8
%27 = call double @llvm.fmuladd.f64(double %25, double %26, double %18)
store double %27, double* %9
%28 = load double*, double** %6
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %6
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %33, i64 %36
%38 = load double, double* %37
%39 = fsub double %32, %38
%40 = call double @pow(double %39, i32 2)
store double %40, double* %10
%41 = load double, double* %10
%42 = fadd double 1.000000e+00, %41
%43 = fptosi double %42 to i32
%44 = call double @sqrt(i32 %43)
store double %44, double* %11
%45 = load double, double* %11
%46 = load double*, double** %7
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %46, i64 %49
%51 = load double, double* %50
%52 = fdiv double %45, %51
store double %52, double* %12
%53 = load double*, double** %6
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = load double*, double** %6
%59 = load i32, i32* %5
%60 = sub nsw i32 %59, 1
%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 = call double @pow(double %64, i32 2)
store double %65, double* %10
%66 = load double, double* %10
%67 = fadd double 1.000000e+00, %66
%68 = fptosi double %67 to i32
%69 = call double @sqrt(i32 %68)
store double %69, double* %11
%70 = load double, double* %11
%71 = load double*, double** %7
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = fdiv double %70, %75
%77 = load double, double* %12
%78 = fadd double %77, %76
store double %78, double* %12
%79 = load double, double* %9
%80 = load double*, double** %6
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %80, i64 %83
%85 = load double, double* %84
%86 = fsub double %79, %85
%87 = call double @pow(double %86, i32 2)
store double %87, double* %10
%88 = load double, double* %10
%89 = fadd double 1.000000e+00, %88
%90 = fptosi double %89 to i32
%91 = call double @sqrt(i32 %90)
store double %91, double* %11
%92 = load double, double* %11
%93 = load double*, double** %7
%94 = load i32, i32* %5
%95 = add nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %93, i64 %96
%98 = load double, double* %97
%99 = fdiv double %92, %98
store double %99, double* %13
%100 = load double, double* %9
%101 = load double*, double** %6
%102 = load i32, i32* %5
%103 = sub nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double, double* %101, i64 %104
%106 = load double, double* %105
%107 = fsub double %100, %106
%108 = call double @pow(double %107, i32 2)
store double %108, double* %10
%109 = load double, double* %10
%110 = fadd double 1.000000e+00, %109
%111 = fptosi double %110 to i32
%112 = call double @sqrt(i32 %111)
store double %112, double* %11
%113 = load double, double* %11
%114 = load double*, double** %7
%115 = load i32, i32* %5
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %114, i64 %116
%118 = load double, double* %117
%119 = fdiv double %113, %118
%120 = load double, double* %13
%121 = fadd double %120, %119
store double %121, double* %13
%122 = load double, double* %13
%123 = load double, double* %12
%124 = fcmp olt double %122, %123
br i1 %124, label %125, label %127
125: ; preds = %3
%126 = load double, double* %9
store double %126, double* %4
br label %133
127: ; preds = %3
%128 = load double*, double** %6
%129 = load i32, i32* %5
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds double, double* %128, i64 %130
%132 = load double, double* %131
store double %132, double* %4
br label %133
133: ; preds = %127, %125
%134 = load double, double* %4
ret double %134
}

LLVM IR (-O2):
@RAND_MAX = global i32 0
define double @change_path(i32 %0, double* nocapture %1, double* nocapture %2) {
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds double, double* %1, i64 %4
%6 = load double, double* %5
%7 = tail call i32 (...) @rand()
%8 = shl nsw i32 %7, 1
%9 = sitofp i32 %8 to double
%10 = load i32, i32* @RAND_MAX
%11 = sitofp i32 %10 to double
%12 = fdiv double %9, %11
%13 = tail call double @llvm.fmuladd.f64(double %12, double 2.500000e-01, double %6)
%14 = load double, double* %5
%15 = add nsw i32 %0, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %1, i64 %16
%18 = load double, double* %17
%19 = fsub double %14, %18
%20 = tail call double @pow(double %19, i32 2)
%21 = fadd double %20, 1.000000e+00
%22 = fptosi double %21 to i32
%23 = tail call double @sqrt(i32 %22)
%24 = getelementptr inbounds double, double* %2, i64 %16
%25 = load double, double* %24
%26 = load double, double* %5
%27 = add nsw i32 %0, -1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %1, i64 %28
%30 = load double, double* %29
%31 = fsub double %26, %30
%32 = tail call double @pow(double %31, i32 2)
%33 = fadd double %32, 1.000000e+00
%34 = fptosi double %33 to i32
%35 = tail call double @sqrt(i32 %34)
%36 = getelementptr inbounds double, double* %2, i64 %4
%37 = load double, double* %36
%38 = insertelement <2 x double> poison, double %23, i64 0
%39 = insertelement <2 x double> %38, double %35, i64 1
%40 = insertelement <2 x double> poison, double %25, i64 0
%41 = insertelement <2 x double> %40, double %37, i64 1
%42 = fdiv <2 x double> %39, %41
%43 = load double, double* %17
%44 = fsub double %13, %43
%45 = tail call double @pow(double %44, i32 2)
%46 = fadd double %45, 1.000000e+00
%47 = fptosi double %46 to i32
%48 = tail call double @sqrt(i32 %47)
%49 = load double, double* %24
%50 = load double, double* %29
%51 = fsub double %13, %50
%52 = tail call double @pow(double %51, i32 2)
%53 = fadd double %52, 1.000000e+00
%54 = fptosi double %53 to i32
%55 = tail call double @sqrt(i32 %54)
%56 = load double, double* %36
%57 = insertelement <2 x double> poison, double %48, i64 0
%58 = insertelement <2 x double> %57, double %55, i64 1
%59 = insertelement <2 x double> poison, double %49, i64 0
%60 = insertelement <2 x double> %59, double %56, i64 1
%61 = fdiv <2 x double> %58, %60
%62 = shufflevector <2 x double> %61, <2 x double> %42, <2 x i32> <i32 0, i32 2>
%63 = shufflevector <2 x double> %61, <2 x double> %42, <2 x i32> <i32 1, i32 3>
%64 = fadd <2 x double> %62, %63
%65 = extractelement <2 x double> %64, i64 0
%66 = extractelement <2 x double> %64, i64 1
%67 = fcmp olt double %65, %66
br i1 %67, label %70, label %68
68: ; preds = %3
%69 = load double, double* %5
br label %70
70: ; preds = %3, %68
%71 = phi double [ %69, %68 ], [ %13, %3 ]
ret double %71
}