#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(int, double);
double sin(double);
double sqrt(double);
double f(double x) {
  if (x < -2)
    return x * x - sin(x);
  else if (x <= 2)
    return pow(2, x) + x;
  else
    return sqrt(x * x + x + 1);
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xebb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a4 <f+0x74>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x20(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1202 <f+0xd2>
movsd  0xe5c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11d5 <f+0xa5>
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1202 <f+0xd2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rax
movapd %xmm0,%xmm1
movsd  0xec3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1164 <f+0x34>
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret
movsd  0xe9c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    1196 <f+0x66>
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xe8a(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b0 <f+0x80>
sqrtsd %xmm0,%xmm0
pop    %rax
ret
mov    $0x2,%edi
movapd %xmm1,%xmm0
movsd  %xmm1,(%rsp)
call   1040 <pow@plt>
addsd  (%rsp),%xmm0
pop    %rax
ret
pop    %rax
jmp    1050 <sqrt@plt>

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, -2.000000e+00
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load double, double* %3
%8 = load double, double* %3
%9 = load double, double* %3
%10 = call double @sin(double %9)
%11 = fneg double %10
%12 = call double @llvm.fmuladd.f64(double %7, double %8, double %11)
store double %12, double* %2
br label %28
13: ; preds = %1
%14 = load double, double* %3
%15 = fcmp ole double %14, 2.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load double, double* %3
%18 = call double @pow(i32 2, double %17)
%19 = load double, double* %3
%20 = fadd double %18, %19
store double %20, double* %2
br label %28
21: ; preds = %13
%22 = load double, double* %3
%23 = load double, double* %3
%24 = load double, double* %3
%25 = call double @llvm.fmuladd.f64(double %22, double %23, double %24)
%26 = fadd double %25, 1.000000e+00
%27 = call double @sqrt(double %26)
store double %27, double* %2
br label %28
28: ; preds = %21, %16, %6
%29 = load double, double* %2
ret double %29
}

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