#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 /*<<< orphan*/ executar(int, int, int, int, float);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
void menu() {
  int funcao = 0;
  int total_individuos = 0;
  int descarte = 0;
  int geracoes = 0;
  float prob_mutacao = 0.0;
  printf("\n\nAlgoritmos Geneticos\n");
  printf("========== =========\n\n");
  printf("1) De Jongs\n");
  printf("2) Rastrigin\n");
  printf("3) DropWave\n");
  printf("4) Griegwangk\n");
  printf("5) Shubert\n\n");
  printf("Selecione a funcao a minimizar : ");
  scanf("%d", &funcao);
  if (funcao < 1 || funcao > 5) {
    printf("\nOpcao Invalida! Opcoes possiveis: 1-5 !!!\n");
    return;
  }
  printf("Total de individuos da populacao : ");
  scanf("%d", &total_individuos);
  if (total_individuos < 1) {
    printf("\nErro! O tamanho da populacao deve ser maior do que zero !!!\n");
    return;
  }
  printf("Total de descendentes a descartar : ");
  scanf("%d", &descarte);
  if (descarte < 1) {
    printf("\nErro! O total de descendentes a descartar deve ser maior do que "
           "zero !!!\n");
    return;
  }
  printf("Total de geracoes a evoluir : ");
  scanf("%d", &geracoes);
  if (geracoes < 1) {
    printf("\nErro! O total de geracoes a evoluir deve ser maior do que zero "
           "!!!\n");
    return;
  }
  printf("Probabilidade de mutacao : ");
  scanf("%f", &prob_mutacao);
  if (prob_mutacao < 0 || prob_mutacao > 1) {
    printf("\nErro! A probabilidade de mutacao deve estar no intervalo entre 0 "
           "e 1 !!!\n");
    return;
  }
  executar(funcao, total_individuos, descarte, geracoes, prob_mutacao);
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     11e2 <menu+0xb2>
cmpl   $0x5,-0x4(%rbp)
jle    11f3 <menu+0xc3>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1306 <menu+0x1d6>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jge    122c <menu+0xfc>
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
jmp    1306 <menu+0x1d6>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jge    1265 <menu+0x135>
lea    0xef4(%rip),%rdi
call   1030 <printf@plt>
jmp    1306 <menu+0x1d6>
lea    0xf2e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0x10(%rbp)
jge    129e <menu+0x16e>
lea    0xf25(%rip),%rdi
call   1030 <printf@plt>
jmp    1306 <menu+0x1d6>
lea    0xf59(%rip),%rdi
call   1030 <printf@plt>
lea    0xf69(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
ucomiss -0x14(%rbp),%xmm0
ja     12df <menu+0x1af>
movss  -0x14(%rbp),%xmm0
movss  0xd2a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    12f0 <menu+0x1c0>
lea    0xf37(%rip),%rdi
call   1030 <printf@plt>
jmp    1306 <menu+0x1d6>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
movss  -0x14(%rbp),%xmm0
call   1040 <executar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xf3d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
lea    0xf53(%rip),%rdi
call   1030 <puts@plt>
lea    0xf53(%rip),%rdi
call   1030 <puts@plt>
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x10(%rsp),%eax
add    $0xfffffffa,%eax
cmp    $0xfffffffa,%eax
ja     11f7 <menu+0xb7>
lea    0x103f(%rip),%rdi
jmp    12df <menu+0x19f>
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe1c(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    12bd <menu+0x17d>
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf2(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    12c6 <menu+0x186>
lea    0xe24(%rip),%rdi
call   1040 <printf@plt>
lea    0xdcc(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    12cf <menu+0x18f>
lea    0xe1d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe2d(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
movss  0x14(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     12d8 <menu+0x198>
ucomiss 0xd5f(%rip),%xmm0
ja     12d8 <menu+0x198>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
call   1050 <executar@plt>
add    $0x18,%rsp
ret
lea    0xf30(%rip),%rdi
jmp    12df <menu+0x19f>
lea    0xedd(%rip),%rdi
jmp    12df <menu+0x19f>
lea    0xe90(%rip),%rdi
jmp    12df <menu+0x19f>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"\0A\0AAlgoritmos Geneticos\0A\00"
@.str.1 = [23 x i8] c"========== =========\0A\0A\00"
@.str.2 = [13 x i8] c"1) De Jongs\0A\00"
@.str.3 = [14 x i8] c"2) Rastrigin\0A\00"
@.str.4 = [13 x i8] c"3) DropWave\0A\00"
@.str.5 = [15 x i8] c"4) Griegwangk\0A\00"
@.str.6 = [13 x i8] c"5) Shubert\0A\0A\00"
@.str.7 = [34 x i8] c"Selecione a funcao a minimizar : \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [44 x i8] c"\0AOpcao Invalida! Opcoes possiveis: 1-5 !!!\0A\00"
@.str.10 = [36 x i8] c"Total de individuos da populacao : \00"
@.str.11 = [62 x i8] c"\0AErro! O tamanho da populacao deve ser maior do que zero !!!\0A\00"
@.str.12 = [37 x i8] c"Total de descendentes a descartar : \00"
@.str.13 = [75 x i8] c"\0AErro! O total de descendentes a descartar deve ser maior do que zero !!!\0A\00"
@.str.14 = [31 x i8] c"Total de geracoes a evoluir : \00"
@.str.15 = [69 x i8] c"\0AErro! O total de geracoes a evoluir deve ser maior do que zero !!!\0A\00"
@.str.16 = [28 x i8] c"Probabilidade de mutacao : \00"
@.str.17 = [3 x i8] c"%f\00"
@.str.18 = [75 x i8] c"\0AErro! A probabilidade de mutacao deve estar no intervalo entre 0 e 1 !!!\0A\00"
define void @menu() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store float 0.000000e+00, float* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %0
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 5
br i1 %19, label %20, label %22
20: ; preds = %17, %0
%21 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
br label %60
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.11, i64 0, i64 0))
br label %60
29: ; preds = %22
%30 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.13, i64 0, i64 0))
br label %60
36: ; preds = %29
%37 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 1
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.15, i64 0, i64 0))
br label %60
43: ; preds = %36
%44 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), float* %5)
%46 = load float, float* %5
%47 = fcmp olt float %46, 0.000000e+00
br i1 %47, label %51, label %48
48: ; preds = %43
%49 = load float, float* %5
%50 = fcmp ogt float %49, 1.000000e+00
br i1 %50, label %51, label %53
51: ; preds = %48, %43
%52 = call i32 @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.18, i64 0, i64 0))
br label %60
53: ; preds = %48
%54 = load i32, i32* %1
%55 = load i32, i32* %2
%56 = load i32, i32* %3
%57 = load i32, i32* %4
%58 = load float, float* %5
%59 = call i32 @executar(i32 %54, i32 %55, i32 %56, i32 %57, float %58)
br label %60
60: ; preds = %53, %51, %41, %34, %27, %20
ret void
}

LLVM IR (-O2):
@.str.7 = [34 x i8] c"Selecione a funcao a minimizar : \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.10 = [36 x i8] c"Total de individuos da populacao : \00"
@.str.12 = [37 x i8] c"Total de descendentes a descartar : \00"
@.str.14 = [31 x i8] c"Total de geracoes a evoluir : \00"
@.str.16 = [28 x i8] c"Probabilidade de mutacao : \00"
@.str.17 = [3 x i8] c"%f\00"
@str = [23 x i8] c"\0A\0AAlgoritmos Geneticos\00"
@str.19 = [22 x i8] c"========== =========\0A\00"
@str.20 = [12 x i8] c"1) De Jongs\00"
@str.21 = [13 x i8] c"2) Rastrigin\00"
@str.22 = [12 x i8] c"3) DropWave\00"
@str.23 = [14 x i8] c"4) Griegwangk\00"
@str.24 = [12 x i8] c"5) Shubert\0A\00"
@str.25 = [74 x i8] c"\0AErro! A probabilidade de mutacao deve estar no intervalo entre 0 e 1 !!!\00"
@str.26 = [68 x i8] c"\0AErro! O total de geracoes a evoluir deve ser maior do que zero !!!\00"
@str.27 = [74 x i8] c"\0AErro! O total de descendentes a descartar deve ser maior do que zero !!!\00"
@str.28 = [61 x i8] c"\0AErro! O tamanho da populacao deve ser maior do que zero !!!\00"
@str.29 = [43 x i8] c"\0AOpcao Invalida! Opcoes possiveis: 1-5 !!!\00"
define void @menu() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%7 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast float* %5 to i8*
store float 0.000000e+00, float* %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.19, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.20, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.21, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.22, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.23, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.24, i64 0, i64 0))
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = add i32 %20, -6
%22 = icmp ult i32 %21, -5
br i1 %22, label %23, label %25
23: ; preds = %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.29, i64 0, i64 0))
br label %61
25: ; preds = %0
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.28, i64 0, i64 0))
br label %61
32: ; preds = %25
%33 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%35 = load i32, i32* %3
%36 = icmp slt i32 %35, 1
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.27, i64 0, i64 0))
br label %61
39: ; preds = %32
%40 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0))
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%42 = load i32, i32* %4
%43 = icmp slt i32 %42, 1
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str.26, i64 0, i64 0))
br label %61
46: ; preds = %39
%47 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0))
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), float* %5)
%49 = load float, float* %5
%50 = fcmp olt float %49, 0.000000e+00
%51 = fcmp ogt float %49, 1.000000e+00
%52 = or i1 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.25, i64 0, i64 0))
br label %61
55: ; preds = %46
%56 = load i32, i32* %1
%57 = load i32, i32* %2
%58 = load i32, i32* %3
%59 = load i32, i32* %4
%60 = call i32 @executar(i32 %56, i32 %57, i32 %58, i32 %59, float %49)
br label %61
61: ; preds = %55, %53, %44, %37, %30, %23
ret void
}