#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 cos(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
float sin(float);
float sqrt(float);
int main() {
  float x, y;
  printf("Please input the value of x:\n");
  scanf("%f", &x);
  if (x < 1)
    y = 2 + cos(x);
  else if (x >= 2)
    y = sqrt(x - 2);
  else
    y = x * x + sin(x);
  printf("f(%.2f)=%.2f\n", x, y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movss  0xe7b(%rip),%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11aa <main+0x5a>
movss  -0x8(%rbp),%xmm0
call   1060 <cos@plt>
add    $0x2,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    121d <main+0xcd>
movss  -0x8(%rbp),%xmm0
movss  0xe4d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11e0 <main+0x90>
movss  -0x8(%rbp),%xmm0
movss  0xe37(%rip),%xmm1
subss  %xmm1,%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0xc(%rbp)
jmp    1218 <main+0xc8>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movss  -0x14(%rbp),%xmm2
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    121d <main+0xcd>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdf3(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
movss  (%rsp),%xmm1
movss  0xe77(%rip),%xmm0
ucomiss %xmm1,%xmm0
jbe    11a2 <main+0x42>
movaps %xmm1,%xmm0
call   1070 <cos@plt>
add    $0x2,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
jmp    11ea <main+0x8a>
ucomiss 0xe5b(%rip),%xmm1
jae    11c9 <main+0x69>
movaps %xmm1,%xmm0
movss  %xmm1,0x4(%rsp)
call   1050 <sin@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
jmp    11ea <main+0x8a>
addss  0xe37(%rip),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jb     11df <main+0x7f>
sqrtss %xmm1,%xmm1
jmp    11ea <main+0x8a>
movaps %xmm1,%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xe11(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Please input the value of x:\0A\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [14 x i8] c"f(%.2f)=%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%6 = load float, float* %2
%7 = fcmp olt float %6, 1.000000e+00
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load float, float* %2
%10 = call i32 @cos(float %9)
%11 = add nsw i32 2, %10
%12 = sitofp i32 %11 to float
store float %12, float* %3
br label %27
13: ; preds = %0
%14 = load float, float* %2
%15 = fcmp oge float %14, 2.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load float, float* %2
%18 = fsub float %17, 2.000000e+00
%19 = call float @sqrt(float %18)
store float %19, float* %3
br label %26
20: ; preds = %13
%21 = load float, float* %2
%22 = load float, float* %2
%23 = load float, float* %2
%24 = call float @sin(float %23)
%25 = call float @llvm.fmuladd.f32(float %21, float %22, float %24)
store float %25, float* %3
br label %26
26: ; preds = %20, %16
br label %27
27: ; preds = %26, %8
%28 = load float, float* %2
%29 = fpext float %28 to double
%30 = load float, float* %3
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %29, double %31)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [14 x i8] c"f(%.2f)=%.2f\0A\00"
@str = [29 x i8] c"Please input the value of x:\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fcmp olt float %5, 1.000000e+00
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @cos(float %5)
%9 = add nsw i32 %8, 2
%10 = sitofp i32 %9 to float
br label %19
11: ; preds = %0
%12 = fcmp ult float %5, 2.000000e+00
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = fadd float %5, -2.000000e+00
%15 = call float @sqrt(float %14)
br label %19
16: ; preds = %11
%17 = call float @sin(float %5)
%18 = call float @llvm.fmuladd.f32(float %5, float %5, float %17)
br label %19
19: ; preds = %13, %16, %7
%20 = phi float [ %10, %7 ], [ %15, %13 ], [ %18, %16 ]
%21 = load float, float* %1
%22 = fpext float %21 to double
%23 = fpext float %20 to double
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %22, double %23)
ret i32 0
}