#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int /*<<< orphan*/ stdin;
int Menu(char texto[], int n) {
  int opcion;
  do {
    printf("%s ", texto);
    do {
      fflush(stdin);
      if (scanf("%d", &opcion) != 1) {
        printf("Error en la entrada, elije una opcion\n");
        continue;
      }
      break;
    } while (1);
    if (opcion < 1 || opcion > n)
      printf("Error: Opci%cn no v%clida...\n", 162, 160);
  } while (opcion < 1 || opcion > n);
  return opcion;
}


x86 assembly (clang, -O0):
<Menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xe9e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     118b <Menu+0x5b>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1190 <Menu+0x60>
jmp    119f <Menu+0x6f>
mov    $0x1,%al
test   $0x1,%al
jne    1151 <Menu+0x21>
jmp    119f <Menu+0x6f>
cmpl   $0x1,-0x10(%rbp)
jl     11b5 <Menu+0x85>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11cd <Menu+0x9d>
lea    0xe72(%rip),%rdi
mov    $0xa2,%esi
mov    $0xa0,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <Menu+0xa2>
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jl     11ed <Menu+0xbd>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113f <Menu+0xf>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %rdi,%r14
mov    0x2e90(%rip),%r15
lea    0xea5(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xeba(%rip),%r13
nopl   0x0(%rax,%rax,1)
lea    0xe89(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
call   1050 <fflush@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     11c0 <Menu+0x80>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    1190 <Menu+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11e0 <Menu+0xa0>
cmp    %r12d,%eax
jg     11e0 <Menu+0xa0>
test   %eax,%eax
jle    1170 <Menu+0x30>
cmp    %r12d,%eax
jg     1170 <Menu+0x30>
jmp    1205 <Menu+0xc5>
nopl   0x0(%rax,%rax,1)
lea    0xe20(%rip),%rdi
mov    $0xa2,%esi
mov    $0xa0,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jg     11d1 <Menu+0x91>
jmp    1170 <Menu+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Error en la entrada, elije una opcion\0A\00"
@.str.3 = [30 x i8] c"Error: Opci%cn no v%clida...\0A\00"
define i32 @Menu(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %35, %2
%7 = load i8*, i8** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %17, %6
%10 = load i32, i32* @stdin
%11 = call i32 @fflush(i32 %10)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %17
16: ; preds = %9
br label %18
17: ; preds = %14
br i1 true, label %9, label %18
18: ; preds = %17, %16
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 1
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21, %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 162, i32 160)
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 1
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = icmp sgt i32 %32, %33
br label %35
35: ; preds = %31, %28
%36 = phi i1 [ true, %28 ], [ %34, %31 ]
br i1 %36, label %6, label %37
37: ; preds = %35
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [30 x i8] c"Error: Opci%cn no v%clida...\0A\00"
@str = [38 x i8] c"Error en la entrada, elije una opcion\00"
define i32 @Menu(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %25, %2
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = load i32, i32* @stdin
%8 = call i32 @fflush(i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %17, label %11
11: ; preds = %5, %11
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @fflush(i32 %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %11
17: ; preds = %11, %5
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 1
%20 = icmp sgt i32 %18, %1
%21 = or i1 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 162, i32 160)
%24 = load i32, i32* %3
br label %25
25: ; preds = %17, %22
%26 = phi i32 [ %18, %17 ], [ %24, %22 ]
%27 = icmp slt i32 %26, 1
%28 = icmp sgt i32 %26, %1
%29 = or i1 %27, %28
br i1 %29, label %5, label %30
30: ; preds = %25
ret i32 %26
}