#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 */
double pow(double, int);
double composite_potential(double u, double gamma) {
  double c = 1.0 / (gamma - 1.0);
  double ctilde = gamma * c;
  double a0, a1, a2;
  if (u < c) {
    return pow(ctilde - u, -gamma);
  } else {
    a2 = 0.5 * gamma * (1.0 + gamma);
    a1 = gamma - 2 * c * a2;
    a0 = 1 - c * a1 - pow(c, 2) * a2;
    return a0 + a1 * u + a2 * pow(u, 2);
  }
}


x86 assembly (clang, -O0):
<composite_potential>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xed1(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xec5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a0 <composite_potential+0x90>
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <composite_potential+0x1b0>
movsd  0xe68(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xe38(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdd5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  -0x58(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<composite_potential>:
sub    $0x38,%rsp
movapd %xmm0,%xmm3
movsd  0xee0(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  0xedc(%rip),%xmm4
movapd %xmm4,%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm3,%xmm0
jbe    1157 <composite_potential+0x47>
mulsd  %xmm1,%xmm0
subsd  %xmm3,%xmm0
xorpd  0xed6(%rip),%xmm1
cvttsd2si %xmm1,%edi
add    $0x38,%rsp
jmp    1030 <pow@plt>
movsd  0xeb1(%rip),%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm1,%xmm5
addsd  %xmm4,%xmm5
mulsd  %xmm2,%xmm5
movapd %xmm5,0x20(%rsp)
movsd  0xe9b(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm5,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm4
movsd  %xmm4,0x10(%rsp)
mov    $0x2,%edi
movsd  %xmm3,0x18(%rsp)
call   1030 <pow@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
mulsd  0x20(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @composite_potential(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store double %1, double* %5
%11 = load double, double* %5
%12 = fsub double %11, 1.000000e+00
%13 = fdiv double 1.000000e+00, %12
store double %13, double* %6
%14 = load double, double* %5
%15 = load double, double* %6
%16 = fmul double %14, %15
store double %16, double* %7
%17 = load double, double* %4
%18 = load double, double* %6
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %28
20: ; preds = %2
%21 = load double, double* %7
%22 = load double, double* %4
%23 = fsub double %21, %22
%24 = load double, double* %5
%25 = fneg double %24
%26 = fptosi double %25 to i32
%27 = call double @pow(double %23, i32 %26)
store double %27, double* %3
br label %57
28: ; preds = %2
%29 = load double, double* %5
%30 = fmul double 5.000000e-01, %29
%31 = load double, double* %5
%32 = fadd double 1.000000e+00, %31
%33 = fmul double %30, %32
store double %33, double* %10
%34 = load double, double* %5
%35 = load double, double* %6
%36 = fmul double 2.000000e+00, %35
%37 = load double, double* %10
%38 = fneg double %36
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double %34)
store double %39, double* %9
%40 = load double, double* %6
%41 = load double, double* %9
%42 = fneg double %40
%43 = call double @llvm.fmuladd.f64(double %42, double %41, double 1.000000e+00)
%44 = load double, double* %6
%45 = call double @pow(double %44, i32 2)
%46 = load double, double* %10
%47 = fneg double %45
%48 = call double @llvm.fmuladd.f64(double %47, double %46, double %43)
store double %48, double* %8
%49 = load double, double* %8
%50 = load double, double* %9
%51 = load double, double* %4
%52 = call double @llvm.fmuladd.f64(double %50, double %51, double %49)
%53 = load double, double* %10
%54 = load double, double* %4
%55 = call double @pow(double %54, i32 2)
%56 = call double @llvm.fmuladd.f64(double %53, double %55, double %52)
store double %56, double* %3
br label %57
57: ; preds = %28, %20
%58 = load double, double* %3
ret double %58
}

LLVM IR (-O2):
define double @composite_potential(double %0, double %1) {
%3 = fadd double %1, -1.000000e+00
%4 = fdiv double 1.000000e+00, %3
%5 = fcmp ogt double %4, %0
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = fmul double %4, %1
%8 = fsub double %7, %0
%9 = fneg double %1
%10 = fptosi double %9 to i32
%11 = tail call double @pow(double %8, i32 %10)
br label %26
12: ; preds = %2
%13 = fmul double %1, 5.000000e-01
%14 = fadd double %1, 1.000000e+00
%15 = fmul double %13, %14
%16 = fmul double %4, -2.000000e+00
%17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %1)
%18 = fneg double %4
%19 = tail call double @llvm.fmuladd.f64(double %18, double %17, double 1.000000e+00)
%20 = tail call double @pow(double %4, i32 2)
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %15, double %19)
%23 = tail call double @llvm.fmuladd.f64(double %17, double %0, double %22)
%24 = tail call double @pow(double %0, i32 2)
%25 = tail call double @llvm.fmuladd.f64(double %15, double %24, double %23)
br label %26
26: ; preds = %12, %6
%27 = phi double [ %11, %6 ], [ %25, %12 ]
ret double %27
}