double Ficalc(int dimen, double *V, double *P) {
  double ftilde(int dimen, int shift, double *P, double *V);
  int signdP;
  double Fi;
  signdP = (P[1] - P[-1] > 0) * 2 - 1;
  Fi = ((ftilde(dimen, 0, V, P)) >= (ftilde(dimen, -signdP, V, P))
            ? (ftilde(dimen, 0, V, P))
            : (ftilde(dimen, -signdP, V, P)));
  return (Fi);
}


x86 assembly (clang, -O0):
<Ficalc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  -0x8(%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
call   1030 <ftilde@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
sub    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1030 <ftilde@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11a7 <Ficalc+0x97>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
call   1030 <ftilde@plt>
movsd  %xmm0,-0x38(%rbp)
jmp    11c1 <Ficalc+0xb1>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
sub    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1030 <ftilde@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ficalc>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
movsd  0x8(%rdx),%xmm0
subsd  -0x8(%rdx),%xmm0
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %rsi,%r14
mov    %edi,%r12d
setbe  %al
lea    (%rax,%rax,1),%r15d
add    $0xffffffff,%r15d
xor    %ebp,%ebp
xor    %esi,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <ftilde@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%edi
mov    %r15d,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <ftilde@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
cmovb  %r15d,%ebp
mov    %r12d,%edi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <ftilde@plt>

LLVM IR (-O0):
define double @Ficalc(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double*, double** %6
%10 = getelementptr inbounds double, double* %9, i64 1
%11 = load double, double* %10
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 -1
%14 = load double, double* %13
%15 = fsub double %11, %14
%16 = fcmp ogt double %15, 0.000000e+00
%17 = zext i1 %16 to i32
%18 = mul nsw i32 %17, 2
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %7
%20 = load i32, i32* %4
%21 = load double*, double** %5
%22 = load double*, double** %6
%23 = call double @ftilde(i32 %20, i32 0, double* %21, double* %22)
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = sub nsw i32 0, %25
%27 = load double*, double** %5
%28 = load double*, double** %6
%29 = call double @ftilde(i32 %24, i32 %26, double* %27, double* %28)
%30 = fcmp oge double %23, %29
br i1 %30, label %31, label %36
31: ; preds = %3
%32 = load i32, i32* %4
%33 = load double*, double** %5
%34 = load double*, double** %6
%35 = call double @ftilde(i32 %32, i32 0, double* %33, double* %34)
br label %43
36: ; preds = %3
%37 = load i32, i32* %4
%38 = load i32, i32* %7
%39 = sub nsw i32 0, %38
%40 = load double*, double** %5
%41 = load double*, double** %6
%42 = call double @ftilde(i32 %37, i32 %39, double* %40, double* %41)
br label %43
43: ; preds = %36, %31
%44 = phi double [ %35, %31 ], [ %42, %36 ]
store double %44, double* %8
%45 = load double, double* %8
ret double %45
}

LLVM IR (-O2):
define double @Ficalc(i32 %0, double* %1, double* %2) {
%4 = getelementptr inbounds double, double* %2, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %2, i64 -1
%7 = load double, double* %6
%8 = fsub double %5, %7
%9 = fcmp ogt double %8, 0.000000e+00
%10 = select i1 %9, i32 -1, i32 1
%11 = tail call double @ftilde(i32 %0, i32 0, double* %1, double* %2)
%12 = tail call double @ftilde(i32 %0, i32 %10, double* %1, double* %2)
%13 = fcmp ult double %11, %12
%14 = select i1 %13, i32 %10, i32 0
%15 = tail call double @ftilde(i32 %0, i32 %14, double* %1, double* %2)
ret double %15
}