#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 f(double x) {
  if (x < 0)
    return 0 - x;
  else if (x < 2)
    return pow(x + 1, 0.5);
  else if (x < 4)
    return pow(x + 2, 5);
  else
    return 2 * x + 5;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    113d <f+0x2d>
xorps  %xmm0,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bc <f+0xac>
movsd  0xebb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    116e <f+0x5e>
movsd  0xec0(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11bc <f+0xac>
movsd  0xe92(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a2 <f+0x92>
movsd  0xe77(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
mov    $0x5,%edi
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11bc <f+0xac>
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe5d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    1123 <f+0x13>
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret
movsd  0xed5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1140 <f+0x30>
addsd  0xedf(%rip),%xmm0
xor    %edi,%edi
jmp    1030 <pow@plt>
movsd  0xec0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1160 <f+0x50>
addsd  0xeaa(%rip),%xmm0
mov    $0x5,%edi
jmp    1030 <pow@plt>
addsd  %xmm0,%xmm0
addsd  0xea4(%rip),%xmm0
ret

LLVM IR (-O0):
define double @f(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load double, double* %3
%8 = fsub double 0.000000e+00, %7
store double %8, double* %2
br label %26
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp olt double %10, 2.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load double, double* %3
%14 = fadd double %13, 1.000000e+00
%15 = call double @pow(double %14, i32 0)
store double %15, double* %2
br label %26
16: ; preds = %9
%17 = load double, double* %3
%18 = fcmp olt double %17, 4.000000e+00
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load double, double* %3
%21 = fadd double %20, 2.000000e+00
%22 = call double @pow(double %21, i32 5)
store double %22, double* %2
br label %26
23: ; preds = %16
%24 = load double, double* %3
%25 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %24, double 5.000000e+00)
store double %25, double* %2
br label %26
26: ; preds = %23, %19, %12, %6
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
define double @f(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = fsub double 0.000000e+00, %0
br label %17
5: ; preds = %1
%6 = fcmp olt double %0, 2.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = fadd double %0, 1.000000e+00
%9 = tail call double @pow(double %8, i32 0)
br label %17
10: ; preds = %5
%11 = fcmp olt double %0, 4.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = fadd double %0, 2.000000e+00
%14 = tail call double @pow(double %13, i32 5)
br label %17
15: ; preds = %10
%16 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double 5.000000e+00)
br label %17
17: ; preds = %15, %12, %7, %3
%18 = phi double [ %4, %3 ], [ %9, %7 ], [ %14, %12 ], [ %16, %15 ]
ret double %18
}