#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 de_jongs(float, float);
float drop_wave(float, float);
float griewangk(float, float);
int /*<<< orphan*/ printf(char *);
float rastrigin(float, float);
float shubert(float, float);
float obter_fitness(int funcao, float x1, float x2) {
  float fitness = 0.0;
  switch (funcao) {
  case 1:
    fitness = de_jongs(x1, x2);
    break;
  case 2:
    fitness = rastrigin(x1, x2);
    break;
  case 3:
    fitness = drop_wave(x1, x2);
    break;
  case 4:
    fitness = griewangk(x1, x2);
    break;
  case 5:
    fitness = shubert(x1, x2);
    break;
  default:
    printf("\nERRO!\n");
  }
  return fitness;
}


x86 assembly (clang, -O0):
<obter_fitness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1222 <obter_fitness+0xc2>
mov    -0x18(%rbp),%rax
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1040 <de_jongs@plt>
movss  %xmm0,-0x10(%rbp)
jmp    122e <obter_fitness+0xce>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1070 <rastrigin@plt>
movss  %xmm0,-0x10(%rbp)
jmp    122e <obter_fitness+0xce>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1060 <drop_wave@plt>
movss  %xmm0,-0x10(%rbp)
jmp    122e <obter_fitness+0xce>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <griewangk@plt>
movss  %xmm0,-0x10(%rbp)
jmp    122e <obter_fitness+0xce>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1080 <shubert@plt>
movss  %xmm0,-0x10(%rbp)
jmp    122e <obter_fitness+0xce>
lea    0xdeb(%rip),%rdi
call   1050 <printf@plt>
movss  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obter_fitness>:
push   %rax
add    $0xffffffff,%edi
cmp    $0x4,%edi
ja     117f <obter_fitness+0x1f>
lea    0xe90(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
pop    %rax
jmp    1050 <de_jongs@plt>
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret
pop    %rax
jmp    1070 <rastrigin@plt>
pop    %rax
jmp    1060 <drop_wave@plt>
pop    %rax
jmp    1030 <griewangk@plt>
pop    %rax
jmp    1080 <shubert@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"\0AERRO!\0A\00"
define float @obter_fitness(i32 %0, float %1, float %2) {
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 %0, i32* %4
store float %1, float* %5
store float %2, float* %6
store float 0.000000e+00, float* %7
%8 = load i32, i32* %4
switch i32 %8, label %29 [
i32 1, label %9
i32 2, label %13
i32 3, label %17
i32 4, label %21
i32 5, label %25
]
9: ; preds = %3
%10 = load float, float* %5
%11 = load float, float* %6
%12 = call float @de_jongs(float %10, float %11)
store float %12, float* %7
br label %31
13: ; preds = %3
%14 = load float, float* %5
%15 = load float, float* %6
%16 = call float @rastrigin(float %14, float %15)
store float %16, float* %7
br label %31
17: ; preds = %3
%18 = load float, float* %5
%19 = load float, float* %6
%20 = call float @drop_wave(float %18, float %19)
store float %20, float* %7
br label %31
21: ; preds = %3
%22 = load float, float* %5
%23 = load float, float* %6
%24 = call float @griewangk(float %22, float %23)
store float %24, float* %7
br label %31
25: ; preds = %3
%26 = load float, float* %5
%27 = load float, float* %6
%28 = call float @shubert(float %26, float %27)
store float %28, float* %7
br label %31
29: ; preds = %3
%30 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %25, %21, %17, %13, %9
%32 = load float, float* %7
ret float %32
}

LLVM IR (-O2):
@str = [7 x i8] c"\0AERRO!\00"
define float @obter_fitness(i32 %0, float %1, float %2) {
switch i32 %0, label %14 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
]
4: ; preds = %3
%5 = tail call float @de_jongs(float %1, float %2)
br label %16
6: ; preds = %3
%7 = tail call float @rastrigin(float %1, float %2)
br label %16
8: ; preds = %3
%9 = tail call float @drop_wave(float %1, float %2)
br label %16
10: ; preds = %3
%11 = tail call float @griewangk(float %1, float %2)
br label %16
12: ; preds = %3
%13 = tail call float @shubert(float %1, float %2)
br label %16
14: ; preds = %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %6, %4
%17 = phi float [ 0.000000e+00, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
ret float %17
}