double fun_LineSearch(double t, double (*fun)(double x[], int n), double x0[],
                      double p[], double x[], int n) {
  int i;
  for (i = 0; i < n; i++)
    x[i] = x0[i] + t * p[i];
  return ((*fun)(x, n));
}


x86 assembly (clang, -O0):
<fun_LineSearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1176 <fun_LineSearch+0x76>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1128 <fun_LineSearch+0x28>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   *%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun_LineSearch>:
push   %rbp
push   %rbx
mov    %rdi,%r9
test   %r8d,%r8d
jle    129f <fun_LineSearch+0x19f>
mov    %r8d,%r10d
cmp    $0x4,%r8d
jae    1187 <fun_LineSearch+0x87>
xor    %edi,%edi
mov    %rdi,%rax
not    %rax
test   $0x1,%r10b
je     113c <fun_LineSearch+0x3c>
movsd  (%rdx,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsi,%rdi,8),%xmm1
movsd  %xmm1,(%rcx,%rdi,8)
or     $0x1,%rdi
add    %r10,%rax
je     129f <fun_LineSearch+0x19f>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rdx,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsi,%rdi,8),%xmm1
movsd  %xmm1,(%rcx,%rdi,8)
movsd  0x8(%rdx,%rdi,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsi,%rdi,8),%xmm1
movsd  %xmm1,0x8(%rcx,%rdi,8)
add    $0x2,%rdi
cmp    %rdi,%r10
jne    1150 <fun_LineSearch+0x50>
jmp    129f <fun_LineSearch+0x19f>
lea    (%rcx,%r10,8),%rdi
lea    (%rsi,%r10,8),%rax
cmp    %rcx,%rax
seta   %bpl
lea    (%rdx,%r10,8),%rax
cmp    %rsi,%rdi
seta   %bl
cmp    %rcx,%rax
seta   %al
cmp    %rdx,%rdi
seta   %r11b
xor    %edi,%edi
test   %bl,%bpl
jne    1119 <fun_LineSearch+0x19>
and    %r11b,%al
jne    1119 <fun_LineSearch+0x19>
mov    %r10d,%edi
and    $0xfffffffc,%edi
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rdi),%rax
mov    %rax,%r11
shr    $0x2,%r11
add    $0x1,%r11
test   %rax,%rax
je     12aa <fun_LineSearch+0x1aa>
mov    %r11,%rbx
and    $0xfffffffffffffffe,%rbx
xor    %eax,%eax
movupd (%rsi,%rax,8),%xmm2
movupd 0x10(%rsi,%rax,8),%xmm3
movupd (%rdx,%rax,8),%xmm4
movupd 0x10(%rdx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rcx,%rax,8)
movupd %xmm5,0x10(%rcx,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm2
movupd 0x30(%rsi,%rax,8),%xmm3
movupd 0x20(%rdx,%rax,8),%xmm4
movupd 0x30(%rdx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,0x20(%rcx,%rax,8)
movupd %xmm5,0x30(%rcx,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rbx
jne    11f0 <fun_LineSearch+0xf0>
test   $0x1,%r11b
je     1296 <fun_LineSearch+0x196>
movupd (%rsi,%rax,8),%xmm2
movupd 0x10(%rsi,%rax,8),%xmm3
movupd (%rdx,%rax,8),%xmm4
movupd 0x10(%rdx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rcx,%rax,8)
movupd %xmm5,0x10(%rcx,%rax,8)
cmp    %r10,%rdi
jne    1119 <fun_LineSearch+0x19>
mov    %rcx,%rdi
mov    %r8d,%esi
pop    %rbx
pop    %rbp
jmp    *%r9
xor    %eax,%eax
test   $0x1,%r11b
jne    1265 <fun_LineSearch+0x165>
jmp    1296 <fun_LineSearch+0x196>

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

LLVM IR (-O2):
define double @fun_LineSearch(double %0, double (double*, i32)* nocapture %1, double* nocapture %2, double* nocapture %3, double* %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %136
8: ; preds = %6
%9 = zext i32 %5 to i64
%10 = icmp ult i32 %5, 4
br i1 %10, label %102, label %11
11: ; preds = %8
%12 = getelementptr double, double* %4, i64 %9
%13 = getelementptr double, double* %2, i64 %9
%14 = getelementptr double, double* %3, i64 %9
%15 = icmp ugt double* %13, %4
%16 = icmp ugt double* %12, %2
%17 = and i1 %15, %16
%18 = icmp ugt double* %14, %4
%19 = icmp ugt double* %12, %3
%20 = and i1 %18, %19
%21 = or i1 %17, %20
br i1 %21, label %102, label %22
22: ; preds = %11
%23 = and i64 %9, 4294967292
%24 = insertelement <2 x double> poison, double %0, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = insertelement <2 x double> poison, double %0, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = add nsw i64 %23, -4
%29 = lshr exact i64 %28, 2
%30 = add nuw nsw i64 %29, 1
%31 = and i64 %30, 1
%32 = icmp eq i64 %28, 0
br i1 %32, label %78, label %33
33: ; preds = %22
%34 = and i64 %30, 9223372036854775806
br label %35
35: ; preds = %35, %33
%36 = phi i64 [ 0, %33 ], [ %75, %35 ]
%37 = phi i64 [ 0, %33 ], [ %76, %35 ]
%38 = getelementptr inbounds double, double* %2, i64 %36
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %3, i64 %36
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %46, <2 x double> %40)
%51 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %49, <2 x double> %43)
%52 = getelementptr inbounds double, double* %4, i64 %36
%53 = bitcast double* %52 to <2 x double>*
store <2 x double> %50, <2 x double>* %53
%54 = getelementptr inbounds double, double* %52, i64 2
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %51, <2 x double>* %55
%56 = or i64 %36, 4
%57 = getelementptr inbounds double, double* %2, i64 %56
%58 = bitcast double* %57 to <2 x double>*
%59 = load <2 x double>, <2 x double>* %58
%60 = getelementptr inbounds double, double* %57, i64 2
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %3, i64 %56
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %65, <2 x double> %59)
%70 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %68, <2 x double> %62)
%71 = getelementptr inbounds double, double* %4, i64 %56
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %69, <2 x double>* %72
%73 = getelementptr inbounds double, double* %71, i64 2
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %70, <2 x double>* %74
%75 = add nuw i64 %36, 8
%76 = add i64 %37, 2
%77 = icmp eq i64 %76, %34
br i1 %77, label %78, label %35
78: ; preds = %35, %22
%79 = phi i64 [ 0, %22 ], [ %75, %35 ]
%80 = icmp eq i64 %31, 0
br i1 %80, label %100, label %81
81: ; preds = %78
%82 = getelementptr inbounds double, double* %2, i64 %79
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %82, i64 2
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %3, i64 %79
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = getelementptr inbounds double, double* %88, i64 2
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> %90, <2 x double> %84)
%95 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %93, <2 x double> %87)
%96 = getelementptr inbounds double, double* %4, i64 %79
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %94, <2 x double>* %97
%98 = getelementptr inbounds double, double* %96, i64 2
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> %95, <2 x double>* %99
br label %100
100: ; preds = %78, %81
%101 = icmp eq i64 %23, %9
br i1 %101, label %136, label %102
102: ; preds = %11, %8, %100
%103 = phi i64 [ 0, %11 ], [ 0, %8 ], [ %23, %100 ]
%104 = xor i64 %103, -1
%105 = and i64 %9, 1
%106 = icmp eq i64 %105, 0
br i1 %106, label %115, label %107
107: ; preds = %102
%108 = getelementptr inbounds double, double* %2, i64 %103
%109 = load double, double* %108
%110 = getelementptr inbounds double, double* %3, i64 %103
%111 = load double, double* %110
%112 = tail call double @llvm.fmuladd.f64(double %0, double %111, double %109)
%113 = getelementptr inbounds double, double* %4, i64 %103
store double %112, double* %113
%114 = or i64 %103, 1
br label %115
115: ; preds = %107, %102
%116 = phi i64 [ %103, %102 ], [ %114, %107 ]
%117 = sub nsw i64 0, %9
%118 = icmp eq i64 %104, %117
br i1 %118, label %136, label %119
119: ; preds = %115, %119
%120 = phi i64 [ %134, %119 ], [ %116, %115 ]
%121 = getelementptr inbounds double, double* %2, i64 %120
%122 = load double, double* %121
%123 = getelementptr inbounds double, double* %3, i64 %120
%124 = load double, double* %123
%125 = tail call double @llvm.fmuladd.f64(double %0, double %124, double %122)
%126 = getelementptr inbounds double, double* %4, i64 %120
store double %125, double* %126
%127 = add nuw nsw i64 %120, 1
%128 = getelementptr inbounds double, double* %2, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %3, i64 %127
%131 = load double, double* %130
%132 = tail call double @llvm.fmuladd.f64(double %0, double %131, double %129)
%133 = getelementptr inbounds double, double* %4, i64 %127
store double %132, double* %133
%134 = add nuw nsw i64 %120, 2
%135 = icmp eq i64 %134, %9
br i1 %135, label %136, label %119
136: ; preds = %115, %119, %100, %6
%137 = tail call double %1(double* %4, i32 %5)
ret double %137
}