#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 LJfunc(int);
double potential(double x) {
  double V = 5 * (2 * LJfunc(2 / (x - 4.0))) + 10;
  V = (x > -2.2) ? V : 10.0;
  V = (V < 10.0) ? V : 10.0;
  return V;
}


x86 assembly (clang, -O0):
<potential>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  0xee6(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xed2(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <LJfunc@plt>
shl    $0x1,%eax
imul   $0x5,%eax,%eax
add    $0xa,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117b <potential+0x6b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118d <potential+0x7d>
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118d <potential+0x7d>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe79(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b9 <potential+0xa9>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11cb <potential+0xbb>
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11cb <potential+0xbb>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<potential>:
push   %rax
movsd  %xmm0,(%rsp)
movsd  0xee2(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0xede(%rip),%xmm1
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <LJfunc@plt>
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    $0xa,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xec2(%rip),%xmm0
cmpltsd (%rsp),%xmm0
andpd  %xmm0,%xmm1
movsd  0xeb8(%rip),%xmm2
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
minsd  %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @potential(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fsub double %4, 4.000000e+00
%6 = fdiv double 2.000000e+00, %5
%7 = fptosi double %6 to i32
%8 = call i32 @LJfunc(i32 %7)
%9 = mul nsw i32 2, %8
%10 = mul nsw i32 5, %9
%11 = add nsw i32 %10, 10
%12 = sitofp i32 %11 to double
store double %12, double* %3
%13 = load double, double* %2
%14 = fcmp ogt double %13, -2.200000e+00
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = load double, double* %3
br label %18
17: ; preds = %1
br label %18
18: ; preds = %17, %15
%19 = phi double [ %16, %15 ], [ 1.000000e+01, %17 ]
store double %19, double* %3
%20 = load double, double* %3
%21 = fcmp olt double %20, 1.000000e+01
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load double, double* %3
br label %25
24: ; preds = %18
br label %25
25: ; preds = %24, %22
%26 = phi double [ %23, %22 ], [ 1.000000e+01, %24 ]
store double %26, double* %3
%27 = load double, double* %3
ret double %27
}

LLVM IR (-O2):
define double @potential(double %0) {
%2 = fadd double %0, -4.000000e+00
%3 = fdiv double 2.000000e+00, %2
%4 = fptosi double %3 to i32
%5 = tail call i32 @LJfunc(i32 %4)
%6 = mul nsw i32 %5, 10
%7 = add nsw i32 %6, 10
%8 = sitofp i32 %7 to double
%9 = fcmp ogt double %0, -2.200000e+00
%10 = select i1 %9, double %8, double 1.000000e+01
%11 = fcmp olt double %10, 1.000000e+01
%12 = select i1 %11, double %10, double 1.000000e+01
ret double %12
}