#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 */
float cos(float);
float exp(float);
int get_count(char *);
float log(float);
float sin(float);
float sqrt(float);
float DoUnary(float x, char a[]) {
  int i, j;
  int cnt;
  i = get_count(a);
  switch (i) {
  case 3:
    return (-x);
  case 5:
    return sqrt(x);
  case 6:
    return exp(x);
  case 7:
    return log(x);
  case 8:
    return log(x);
  case 9:
    return sin(x);
  case 10:
    return cos(x);
  }
}


x86 assembly (clang, -O0):
<DoUnary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <get_count@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xfffffffd,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x7,%eax
ja     1235 <DoUnary+0xd5>
mov    -0x28(%rbp),%rax
lea    0xe63(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1235 <DoUnary+0xd5>
movss  -0x8(%rbp),%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0x4(%rbp)
jmp    1235 <DoUnary+0xd5>
movss  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movss  %xmm0,-0x4(%rbp)
jmp    1235 <DoUnary+0xd5>
movss  -0x8(%rbp),%xmm0
call   1060 <log@plt>
movss  %xmm0,-0x4(%rbp)
jmp    1235 <DoUnary+0xd5>
movss  -0x8(%rbp),%xmm0
call   1060 <log@plt>
movss  %xmm0,-0x4(%rbp)
jmp    1235 <DoUnary+0xd5>
movss  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,-0x4(%rbp)
jmp    1235 <DoUnary+0xd5>
movss  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoUnary>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1080 <get_count@plt>
movaps (%rsp),%xmm0
add    $0xfffffffd,%eax
cmp    $0x7,%eax
ja     11b3 <DoUnary+0x53>
lea    0xe90(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x18,%rsp
jmp    1060 <log@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11ca <DoUnary+0x6a>
sqrtss %xmm0,%xmm0
add    $0x18,%rsp
ret
add    $0x18,%rsp
jmp    1030 <sin@plt>
xorps  0xe4d(%rip),%xmm0
add    $0x18,%rsp
ret
add    $0x18,%rsp
jmp    1040 <exp@plt>
add    $0x18,%rsp
jmp    1050 <cos@plt>
add    $0x18,%rsp
jmp    1070 <sqrt@plt>

LLVM IR (-O0):
define float @DoUnary(float %0, i8* %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store float %0, float* %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @get_count(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
switch i32 %11, label %33 [
i32 3, label %12
i32 5, label %15
i32 6, label %18
i32 7, label %21
i32 8, label %24
i32 9, label %27
i32 10, label %30
]
12: ; preds = %2
%13 = load float, float* %4
%14 = fneg float %13
store float %14, float* %3
br label %33
15: ; preds = %2
%16 = load float, float* %4
%17 = call float @sqrt(float %16)
store float %17, float* %3
br label %33
18: ; preds = %2
%19 = load float, float* %4
%20 = call float @exp(float %19)
store float %20, float* %3
br label %33
21: ; preds = %2
%22 = load float, float* %4
%23 = call float @log(float %22)
store float %23, float* %3
br label %33
24: ; preds = %2
%25 = load float, float* %4
%26 = call float @log(float %25)
store float %26, float* %3
br label %33
27: ; preds = %2
%28 = load float, float* %4
%29 = call float @sin(float %28)
store float %29, float* %3
br label %33
30: ; preds = %2
%31 = load float, float* %4
%32 = call float @cos(float %31)
store float %32, float* %3
br label %33
33: ; preds = %12, %15, %18, %21, %24, %27, %30, %2
%34 = load float, float* %3
ret float %34
}

LLVM IR (-O2):
define float @DoUnary(float %0, i8* %1) {
%3 = tail call i32 @get_count(i8* %1)
switch i32 %3, label %18 [
i32 3, label %4
i32 5, label %6
i32 6, label %8
i32 7, label %10
i32 8, label %12
i32 9, label %14
i32 10, label %16
]
4: ; preds = %2
%5 = fneg float %0
br label %18
6: ; preds = %2
%7 = tail call float @sqrt(float %0)
br label %18
8: ; preds = %2
%9 = tail call float @exp(float %0)
br label %18
10: ; preds = %2
%11 = tail call float @log(float %0)
br label %18
12: ; preds = %2
%13 = tail call float @log(float %0)
br label %18
14: ; preds = %2
%15 = tail call float @sin(float %0)
br label %18
16: ; preds = %2
%17 = tail call float @cos(float %0)
br label %18
18: ; preds = %2, %16, %14, %12, %10, %8, %6, %4
%19 = phi float [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ undef, %2 ]
ret float %19
}