void Ray_in_n_Space(double v[], double initial_pt[], double direction[],
                    double distance, int n) {
  for (--n; n >= 0; n--)
    v[n] = initial_pt[n] + distance * direction[n];
}


x86 assembly (clang, -O0):
<Ray_in_n_Space>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     116d <Ray_in_n_Space+0x6d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1121 <Ray_in_n_Space+0x21>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ray_in_n_Space>:
push   %r15
push   %r14
push   %rbx
test   %ecx,%ecx
jle    1230 <Ray_in_n_Space+0x130>
mov    %ecx,%r8d
cmp    $0x4,%ecx
jb     11fc <Ray_in_n_Space+0xfc>
lea    -0x1(%r8),%r10
add    $0xffffffff,%ecx
cmp    %r10d,%ecx
jb     11fc <Ray_in_n_Space+0xfc>
mov    %r10,%rax
shr    $0x20,%rax
jne    11fc <Ray_in_n_Space+0xfc>
mov    %r8,%rax
neg    %rax
add    %rcx,%rax
add    $0x1,%rax
lea    (%rdi,%rax,8),%r9
lea    0x8(%rdi,%rcx,8),%r11
lea    (%rsi,%rax,8),%r14
lea    (%rsi,%rcx,8),%rbx
add    $0x8,%rbx
lea    (%rdx,%rax,8),%r15
lea    (%rdx,%rcx,8),%rax
add    $0x8,%rax
cmp    %rbx,%r9
setb   %bl
cmp    %r11,%r14
setb   %cl
cmp    %rax,%r9
setb   %al
cmp    %r11,%r15
setb   %r9b
test   %cl,%bl
jne    11fc <Ray_in_n_Space+0xfc>
and    %r9b,%al
jne    11fc <Ray_in_n_Space+0xfc>
mov    %r8d,%r9d
and    $0xfffffffc,%r9d
mov    %r8d,%ecx
and    $0x3,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
shufpd $0x1,%xmm1,%xmm1
mov    %r9,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r10d,%ebx
shl    $0x3,%rbx
movupd -0x18(%rsi,%rbx,1),%xmm2
movupd -0x8(%rsi,%rbx,1),%xmm3
movupd -0x18(%rdx,%rbx,1),%xmm4
movupd -0x8(%rdx,%rbx,1),%xmm5
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm5,-0x8(%rdi,%rbx,1)
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
movupd %xmm4,-0x18(%rdi,%rbx,1)
add    $0xfffffffffffffffc,%r10
add    $0xfffffffffffffffc,%rax
jne    11b0 <Ray_in_n_Space+0xb0>
cmp    %r8,%r9
jne    11ff <Ray_in_n_Space+0xff>
jmp    1230 <Ray_in_n_Space+0x130>
mov    %r8,%rcx
add    $0x1,%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x2(%rcx),%eax
movsd  (%rdx,%rax,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsi,%rax,8),%xmm1
movsd  %xmm1,(%rdi,%rax,8)
add    $0xffffffffffffffff,%rcx
cmp    $0x1,%rcx
ja     1210 <Ray_in_n_Space+0x110>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @Ray_in_n_Space(double* %0, double* %1, double* %2, double %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double %3, double* %9
store i32 %4, i32* %10
%11 = load i32, i32* %10
%12 = add nsw i32 %11, -1
store i32 %12, i32* %10
br label %13
13: ; preds = %33, %5
%14 = load i32, i32* %10
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %36
16: ; preds = %13
%17 = load double*, double** %7
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load double, double* %9
%23 = load double*, double** %8
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = call double @llvm.fmuladd.f64(double %22, double %27, double %21)
%29 = load double*, double** %6
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %16
%34 = load i32, i32* %10
%35 = add nsw i32 %34, -1
store i32 %35, i32* %10
br label %13
36: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @Ray_in_n_Space(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2, double %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %95
7: ; preds = %5
%8 = zext i32 %4 to i64
%9 = icmp ult i32 %4, 4
br i1 %9, label %82, label %10
10: ; preds = %7
%11 = add nsw i64 %8, -1
%12 = add i32 %4, -1
%13 = trunc i64 %11 to i32
%14 = icmp ult i32 %12, %13
%15 = icmp ugt i64 %11, 4294967295
%16 = or i1 %14, %15
br i1 %16, label %82, label %17
17: ; preds = %10
%18 = add i32 %4, -1
%19 = zext i32 %18 to i64
%20 = add nuw nsw i64 %19, 1
%21 = sub nsw i64 %20, %8
%22 = getelementptr double, double* %0, i64 %21
%23 = add nuw nsw i64 %19, 1
%24 = getelementptr double, double* %0, i64 %23
%25 = getelementptr double, double* %1, i64 %21
%26 = getelementptr double, double* %1, i64 %23
%27 = getelementptr double, double* %2, i64 %21
%28 = getelementptr double, double* %2, i64 %23
%29 = icmp ult double* %22, %26
%30 = icmp ult double* %25, %24
%31 = and i1 %29, %30
%32 = icmp ult double* %22, %28
%33 = icmp ult double* %27, %24
%34 = and i1 %32, %33
%35 = or i1 %31, %34
br i1 %35, label %82, label %36
36: ; preds = %17
%37 = and i64 %8, 4294967292
%38 = and i64 %8, 3
%39 = insertelement <2 x double> poison, double %3, i64 0
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> zeroinitializer
%41 = insertelement <2 x double> poison, double %3, i64 0
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
br label %43
43: ; preds = %43, %36
%44 = phi i64 [ 0, %36 ], [ %78, %43 ]
%45 = xor i64 %44, -1
%46 = add i64 %45, %8
%47 = and i64 %46, 4294967295
%48 = getelementptr inbounds double, double* %1, i64 %47
%49 = getelementptr inbounds double, double* %48, i64 -1
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = shufflevector <2 x double> %51, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%53 = getelementptr inbounds double, double* %48, i64 -2
%54 = getelementptr inbounds double, double* %53, i64 -1
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%58 = getelementptr inbounds double, double* %2, i64 %47
%59 = getelementptr inbounds double, double* %58, i64 -1
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = shufflevector <2 x double> %61, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%63 = getelementptr inbounds double, double* %58, i64 -2
%64 = getelementptr inbounds double, double* %63, i64 -1
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = shufflevector <2 x double> %66, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%68 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %40, <2 x double> %62, <2 x double> %52)
%69 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %67, <2 x double> %57)
%70 = getelementptr inbounds double, double* %0, i64 %47
%71 = shufflevector <2 x double> %68, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%72 = getelementptr inbounds double, double* %70, i64 -1
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> %71, <2 x double>* %73
%74 = shufflevector <2 x double> %69, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%75 = getelementptr inbounds double, double* %70, i64 -2
%76 = getelementptr inbounds double, double* %75, i64 -1
%77 = bitcast double* %76 to <2 x double>*
store <2 x double> %74, <2 x double>* %77
%78 = add nuw i64 %44, 4
%79 = icmp eq i64 %78, %37
br i1 %79, label %80, label %43
80: ; preds = %43
%81 = icmp eq i64 %37, %8
br i1 %81, label %95, label %82
82: ; preds = %17, %10, %7, %80
%83 = phi i64 [ %8, %17 ], [ %8, %10 ], [ %8, %7 ], [ %38, %80 ]
br label %84
84: ; preds = %82, %84
%85 = phi i64 [ %86, %84 ], [ %83, %82 ]
%86 = add nsw i64 %85, -1
%87 = and i64 %86, 4294967295
%88 = getelementptr inbounds double, double* %1, i64 %87
%89 = load double, double* %88
%90 = getelementptr inbounds double, double* %2, i64 %87
%91 = load double, double* %90
%92 = tail call double @llvm.fmuladd.f64(double %3, double %91, double %89)
%93 = getelementptr inbounds double, double* %0, i64 %87
store double %92, double* %93
%94 = icmp ugt i64 %85, 1
br i1 %94, label %84, label %95
95: ; preds = %84, %80, %5
ret void
}