#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
void velocidad(int *velNum, int *velDen, int *iteraciones) {
  int seleccion = 6;
  char caracter = '6';
  while (seleccion > 5) {
    printf(
        "seleccione modo y pulse intro:\n\E[0;32m 1:muy facil\E[00m\n\E[0;35m "
        "2:facil\E[00m\n\E[0;36m 3:normal\E[00m\n\E[0;34m "
        "4:dificil\E[00m\n\E[0;31m 5:imposible\E[00m\n ");
    caracter = getchar();
    if (caracter == '1' || caracter == '2' || caracter == '3' ||
        caracter == '4' || caracter == '5')
      seleccion = caracter - 48;
  }
  switch (seleccion) {
  case (1):
    *iteraciones = 50;
    *velNum = 3;
    *velDen = 4;
    break;
  case (2):
    *iteraciones = 60;
    break;
  case (3):
    *iteraciones = 100;
    break;
  case (4):
    *iteraciones = 150;
    *velNum = 1;
    *velDen = 3;
    break;
  case (5):
    *iteraciones = 200;
    *velNum = 1;
    *velDen = 3;
    break;
  }
}


x86 assembly (clang, -O0):
<velocidad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x6,-0x1c(%rbp)
movb   $0x36,-0x1d(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jle    11af <velocidad+0x8f>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x31,%eax
je     11a0 <velocidad+0x80>
movsbl -0x1d(%rbp),%eax
cmp    $0x32,%eax
je     11a0 <velocidad+0x80>
movsbl -0x1d(%rbp),%eax
cmp    $0x33,%eax
je     11a0 <velocidad+0x80>
movsbl -0x1d(%rbp),%eax
cmp    $0x34,%eax
je     11a0 <velocidad+0x80>
movsbl -0x1d(%rbp),%eax
cmp    $0x35,%eax
jne    11aa <velocidad+0x8a>
movsbl -0x1d(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <velocidad+0x1f>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     125a <velocidad+0x13a>
mov    -0x28(%rbp),%rax
lea    0xe31(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movl   $0x32,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
jmp    125a <velocidad+0x13a>
mov    -0x18(%rbp),%rax
movl   $0x3c,(%rax)
jmp    125a <velocidad+0x13a>
mov    -0x18(%rbp),%rax
movl   $0x64,(%rax)
jmp    125a <velocidad+0x13a>
mov    -0x18(%rbp),%rax
movl   $0x96,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
jmp    125a <velocidad+0x13a>
mov    -0x18(%rbp),%rax
movl   $0xc8,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<velocidad>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x6,%ebx
lea    0xed6(%rip),%r13
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl %al,%ecx
add    $0xcf,%al
add    $0xffffffd0,%ecx
cmp    $0x5,%al
cmovb  %ecx,%ebx
cmp    $0x5,%ebx
jg     1140 <velocidad+0x20>
add    $0xffffffff,%ebx
cmp    $0x4,%ebx
ja     11c5 <velocidad+0xa5>
lea    0xe90(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
movl   $0x32,(%r12)
movl   $0x3,(%r15)
movl   $0x4,(%r14)
jmp    11c5 <velocidad+0xa5>
movl   $0x3c,(%r12)
jmp    11c5 <velocidad+0xa5>
movl   $0x64,(%r12)
jmp    11c5 <velocidad+0xa5>
movl   $0x96,(%r12)
jmp    11b7 <velocidad+0x97>
movl   $0xc8,(%r12)
movl   $0x1,(%r15)
movl   $0x3,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [149 x i8] c"seleccione modo y pulse intro:\0A\1B[0;32m 1:muy facil\1B[00m\0A\1B[0;35m 2:facil\1B[00m\0A\1B[0;36m 3:normal\1B[00m\0A\1B[0;34m 4:dificil\1B[00m\0A\1B[0;31m 5:imposible\1B[00m\0A \00"
define void @velocidad(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 6, i32* %7
store i8 54, i8* %8
br label %9
9: ; preds = %38, %3
%10 = load i32, i32* %7
%11 = icmp sgt i32 %10, 5
br i1 %11, label %12, label %39
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0))
%14 = call signext i8 (...) @getchar()
store i8 %14, i8* %8
%15 = load i8, i8* %8
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 49
br i1 %17, label %34, label %18
18: ; preds = %12
%19 = load i8, i8* %8
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 50
br i1 %21, label %34, label %22
22: ; preds = %18
%23 = load i8, i8* %8
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 51
br i1 %25, label %34, label %26
26: ; preds = %22
%27 = load i8, i8* %8
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 52
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 53
br i1 %33, label %34, label %38
34: ; preds = %30, %26, %22, %18, %12
%35 = load i8, i8* %8
%36 = sext i8 %35 to i32
%37 = sub nsw i32 %36, 48
store i32 %37, i32* %7
br label %38
38: ; preds = %34, %30
br label %9
39: ; preds = %9
%40 = load i32, i32* %7
switch i32 %40, label %57 [
i32 1, label %41
i32 2, label %45
i32 3, label %47
i32 4, label %49
i32 5, label %53
]
41: ; preds = %39
%42 = load i32*, i32** %6
store i32 50, i32* %42
%43 = load i32*, i32** %4
store i32 3, i32* %43
%44 = load i32*, i32** %5
store i32 4, i32* %44
br label %57
45: ; preds = %39
%46 = load i32*, i32** %6
store i32 60, i32* %46
br label %57
47: ; preds = %39
%48 = load i32*, i32** %6
store i32 100, i32* %48
br label %57
49: ; preds = %39
%50 = load i32*, i32** %6
store i32 150, i32* %50
%51 = load i32*, i32** %4
store i32 1, i32* %51
%52 = load i32*, i32** %5
store i32 3, i32* %52
br label %57
53: ; preds = %39
%54 = load i32*, i32** %6
store i32 200, i32* %54
%55 = load i32*, i32** %4
store i32 1, i32* %55
%56 = load i32*, i32** %5
store i32 3, i32* %56
br label %57
57: ; preds = %39, %53, %49, %47, %45, %41
ret void
}

LLVM IR (-O2):
@.str = [149 x i8] c"seleccione modo y pulse intro:\0A\1B[0;32m 1:muy facil\1B[00m\0A\1B[0;35m 2:facil\1B[00m\0A\1B[0;36m 3:normal\1B[00m\0A\1B[0;34m 4:dificil\1B[00m\0A\1B[0;31m 5:imposible\1B[00m\0A \00"
define void @velocidad(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
br label %4
4: ; preds = %3, %4
%5 = phi i32 [ 6, %3 ], [ %12, %4 ]
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0))
%7 = tail call signext i8 (...) @getchar()
%8 = add i8 %7, -49
%9 = icmp ult i8 %8, 5
%10 = sext i8 %7 to i32
%11 = add nsw i32 %10, -48
%12 = select i1 %9, i32 %11, i32 %5
%13 = icmp sgt i32 %12, 5
br i1 %13, label %4, label %14
14: ; preds = %4
switch i32 %12, label %20 [
i32 1, label %15
i32 2, label %16
i32 3, label %17
i32 4, label %18
i32 5, label %19
]
15: ; preds = %14
store i32 50, i32* %2
store i32 3, i32* %0
store i32 4, i32* %1
br label %20
16: ; preds = %14
store i32 60, i32* %2
br label %20
17: ; preds = %14
store i32 100, i32* %2
br label %20
18: ; preds = %14
store i32 150, i32* %2
store i32 1, i32* %0
store i32 3, i32* %1
br label %20
19: ; preds = %14
store i32 200, i32* %2
store i32 1, i32* %0
store i32 3, i32* %1
br label %20
20: ; preds = %14, %19, %18, %17, %16, %15
ret void
}