#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 rand();
int selection(int *fronts, int number_of_individuals, float percent) {
  int iterator_solution;
  int actual_parent;
  int posible_parent;
  actual_parent = rand() % (number_of_individuals);
  for (iterator_solution = 0;
       iterator_solution < (number_of_individuals * percent);
       iterator_solution++) {
    posible_parent = rand() % (number_of_individuals);
    if (fronts[actual_parent] > fronts[posible_parent]) {
      actual_parent = posible_parent;
    }
  }
  return actual_parent;
}


x86 assembly (clang, -O0):
<selection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm1
cvtsi2ssl -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1194 <selection+0x84>
mov    $0x0,%al
call   1030 <rand@plt>
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1181 <selection+0x71>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <selection+0x76>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <selection+0x29>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selection>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
mov    %esi,%r14d
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %r14d
mov    %edx,%ebp
cvtsi2ss %r14d,%xmm1
mulss  0x4(%rsp),%xmm1
xorps  %xmm0,%xmm0
movss  %xmm1,0x4(%rsp)
ucomiss %xmm0,%xmm1
jbe    1186 <selection+0x76>
mov    $0x1,%ebx
jmp    1167 <selection+0x57>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
add    $0x1,%ebx
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
mov    %edx,%ebp
jbe    1188 <selection+0x78>
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %r14d
movslq %ebp,%rax
mov    (%r15,%rax,4),%eax
movslq %edx,%rcx
cmp    (%r15,%rcx,4),%eax
jg     1150 <selection+0x40>
mov    %ebp,%edx
jmp    1150 <selection+0x40>
mov    %ebp,%edx
mov    %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @selection(i32* %0, i32 %1, float %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store float %2, float* %6
%10 = call i32 (...) @rand()
%11 = load i32, i32* %5
%12 = srem i32 %10, %11
store i32 %12, i32* %8
store i32 0, i32* %7
br label %13
13: ; preds = %39, %3
%14 = load i32, i32* %7
%15 = sitofp i32 %14 to float
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to float
%18 = load float, float* %6
%19 = fmul float %17, %18
%20 = fcmp olt float %15, %19
br i1 %20, label %21, label %42
21: ; preds = %13
%22 = call i32 (...) @rand()
%23 = load i32, i32* %5
%24 = srem i32 %22, %23
store i32 %24, i32* %9
%25 = load i32*, i32** %4
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32*, i32** %4
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = icmp sgt i32 %29, %34
br i1 %35, label %36, label %38
36: ; preds = %21
%37 = load i32, i32* %9
store i32 %37, i32* %8
br label %38
38: ; preds = %36, %21
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %13
42: ; preds = %13
%43 = load i32, i32* %8
ret i32 %43
}

LLVM IR (-O2):
define i32 @selection(i32* nocapture %0, i32 %1, float %2) {
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, %1
%6 = sitofp i32 %1 to float
%7 = fmul float %6, %2
%8 = fcmp ogt float %7, 0.000000e+00
br i1 %8, label %9, label %25
9: ; preds = %3, %9
%10 = phi i32 [ %22, %9 ], [ 0, %3 ]
%11 = phi i32 [ %21, %9 ], [ %5, %3 ]
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, %1
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = sext i32 %13 to i64
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = icmp sgt i32 %16, %19
%21 = select i1 %20, i32 %13, i32 %11
%22 = add nuw nsw i32 %10, 1
%23 = sitofp i32 %22 to float
%24 = fcmp ogt float %7, %23
br i1 %24, label %9, label %25
25: ; preds = %9, %3
%26 = phi i32 [ %5, %3 ], [ %21, %9 ]
ret i32 %26
}