#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 acos(double);
double asin(double);
double atan(double);
double cbrt(double);
double cos(double);
double deg(double);
double exp(double);
double log(double);
double rad(double);
double rnd(double);
double sin(double);
double sqrt(double);
double tan(double);
int /*<<< orphan*/ yyerror(char *);
double function(int func, double number) {
  double ans;
  switch (func) {
  case 1:
    ans = sqrt(number);
    break;
  case 2:
    ans = cbrt(number);
    break;
  case 3:
    ans = log(number);
    break;
  case 4:
    ans = exp(number);
    break;
  case 5:
    ans = cos(number);
    break;
  case 6:
    ans = sin(number);
    break;
  case 7:
    ans = tan(number);
    break;
  case 8:
    ans = acos(number);
    break;
  case 9:
    ans = asin(number);
    break;
  case 10:
    ans = atan(number);
    break;
  case 11:
    ans = rad(number);
    break;
  case 12:
    ans = deg(number);
    break;
  case 13:
    ans = rnd(number);
    break;
  default:
    yyerror("function error");
  }
  return ans;
}


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xc,%eax
ja     131d <function+0x13d>
mov    -0x20(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
call   1100 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   10c0 <cbrt@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   10f0 <log@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   10a0 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   10d0 <cos@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   1070 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   10b0 <tan@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   1050 <acos@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   1090 <asin@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   1080 <atan@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   10e0 <rad@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   1040 <deg@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
movsd  -0x10(%rbp),%xmm0
call   1060 <rnd@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1329 <function+0x149>
lea    0xd10(%rip),%rdi
call   1030 <yyerror@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
push   %rax
add    $0xffffffff,%edi
cmp    $0xc,%edi
ja     1233 <function+0x53>
lea    0xe10(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     125f <function+0x7f>
sqrtsd %xmm0,%xmm0
pop    %rax
ret
pop    %rax
jmp    10f0 <log@plt>
pop    %rax
jmp    10a0 <exp@plt>
pop    %rax
jmp    10d0 <cos@plt>
pop    %rax
jmp    1050 <acos@plt>
pop    %rax
jmp    1080 <atan@plt>
pop    %rax
jmp    1040 <deg@plt>
pop    %rax
jmp    1060 <rnd@plt>
lea    0xdfa(%rip),%rdi
call   1030 <yyerror@plt>
pop    %rax
ret
pop    %rax
jmp    10c0 <cbrt@plt>
pop    %rax
jmp    1070 <sin@plt>
pop    %rax
jmp    10b0 <tan@plt>
pop    %rax
jmp    1090 <asin@plt>
pop    %rax
jmp    10e0 <rad@plt>
pop    %rax
jmp    1100 <sqrt@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"function error\00"
define double @function(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 %0, i32* %3
store double %1, double* %4
%6 = load i32, i32* %3
switch i32 %6, label %46 [
i32 1, label %7
i32 2, label %10
i32 3, label %13
i32 4, label %16
i32 5, label %19
i32 6, label %22
i32 7, label %25
i32 8, label %28
i32 9, label %31
i32 10, label %34
i32 11, label %37
i32 12, label %40
i32 13, label %43
]
7: ; preds = %2
%8 = load double, double* %4
%9 = call double @sqrt(double %8)
store double %9, double* %5
br label %48
10: ; preds = %2
%11 = load double, double* %4
%12 = call double @cbrt(double %11)
store double %12, double* %5
br label %48
13: ; preds = %2
%14 = load double, double* %4
%15 = call double @log(double %14)
store double %15, double* %5
br label %48
16: ; preds = %2
%17 = load double, double* %4
%18 = call double @exp(double %17)
store double %18, double* %5
br label %48
19: ; preds = %2
%20 = load double, double* %4
%21 = call double @cos(double %20)
store double %21, double* %5
br label %48
22: ; preds = %2
%23 = load double, double* %4
%24 = call double @sin(double %23)
store double %24, double* %5
br label %48
25: ; preds = %2
%26 = load double, double* %4
%27 = call double @tan(double %26)
store double %27, double* %5
br label %48
28: ; preds = %2
%29 = load double, double* %4
%30 = call double @acos(double %29)
store double %30, double* %5
br label %48
31: ; preds = %2
%32 = load double, double* %4
%33 = call double @asin(double %32)
store double %33, double* %5
br label %48
34: ; preds = %2
%35 = load double, double* %4
%36 = call double @atan(double %35)
store double %36, double* %5
br label %48
37: ; preds = %2
%38 = load double, double* %4
%39 = call double @rad(double %38)
store double %39, double* %5
br label %48
40: ; preds = %2
%41 = load double, double* %4
%42 = call double @deg(double %41)
store double %42, double* %5
br label %48
43: ; preds = %2
%44 = load double, double* %4
%45 = call double @rnd(double %44)
store double %45, double* %5
br label %48
46: ; preds = %2
%47 = call i32 @yyerror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %48
48: ; preds = %46, %43, %40, %37, %34, %31, %28, %25, %22, %19, %16, %13, %10, %7
%49 = load double, double* %5
ret double %49
}

LLVM IR (-O2):
@.str = [15 x i8] c"function error\00"
define double @function(i32 %0, double %1) {
switch i32 %0, label %29 [
i32 1, label %3
i32 2, label %5
i32 3, label %7
i32 4, label %9
i32 5, label %11
i32 6, label %13
i32 7, label %15
i32 8, label %17
i32 9, label %19
i32 10, label %21
i32 11, label %23
i32 12, label %25
i32 13, label %27
]
3: ; preds = %2
%4 = tail call double @sqrt(double %1)
br label %31
5: ; preds = %2
%6 = tail call double @cbrt(double %1)
br label %31
7: ; preds = %2
%8 = tail call double @log(double %1)
br label %31
9: ; preds = %2
%10 = tail call double @exp(double %1)
br label %31
11: ; preds = %2
%12 = tail call double @cos(double %1)
br label %31
13: ; preds = %2
%14 = tail call double @sin(double %1)
br label %31
15: ; preds = %2
%16 = tail call double @tan(double %1)
br label %31
17: ; preds = %2
%18 = tail call double @acos(double %1)
br label %31
19: ; preds = %2
%20 = tail call double @asin(double %1)
br label %31
21: ; preds = %2
%22 = tail call double @atan(double %1)
br label %31
23: ; preds = %2
%24 = tail call double @rad(double %1)
br label %31
25: ; preds = %2
%26 = tail call double @deg(double %1)
br label %31
27: ; preds = %2
%28 = tail call double @rnd(double %1)
br label %31
29: ; preds = %2
%30 = tail call i32 @yyerror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3
%32 = phi double [ undef, %29 ], [ %28, %27 ], [ %26, %25 ], [ %24, %23 ], [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
ret double %32
}