#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 getchar();
int /*<<< orphan*/ gotoxy(int, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
unsigned get_option(unsigned size, int begchar) {
  unsigned opt;
  gotoxy(10, 15);
  printf("%s", "Ingrese opcion: ");
  do {
    opt = getchar() - begchar;
    if (opt >= size)
      putchar('\a');
  } while (opt >= size);
  return opt;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0xa,%edi
mov    $0xf,%esi
call   1060 <gotoxy@plt>
lea    0xe9c(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jb     1193 <get_option+0x53>
mov    $0x7,%edi
call   1030 <putchar@plt>
jmp    1198 <get_option+0x58>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1170 <get_option+0x30>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_option>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0xa,%edi
mov    $0xf,%esi
call   1060 <gotoxy@plt>
lea    0xea3(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <printf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
sub    %ebx,%eax
cmp    %ebp,%eax
jb     1189 <get_option+0x49>
mov    $0x7,%edi
call   1030 <putchar@plt>
jmp    1170 <get_option+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"Ingrese opcion: \00"
define i32 @get_option(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = call i32 @gotoxy(i32 10, i32 15)
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %18, %2
%9 = call i32 (...) @getchar()
%10 = load i32, i32* %4
%11 = sub nsw i32 %9, %10
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp uge i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = call i32 @putchar(i8 signext 7)
br label %17
17: ; preds = %15, %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp uge i32 %19, %20
br i1 %21, label %8, label %22
22: ; preds = %18
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"Ingrese opcion: \00"
define i32 @get_option(i32 %0, i32 %1) {
%3 = tail call i32 @gotoxy(i32 10, i32 15)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (...) @getchar()
%6 = sub nsw i32 %5, %1
%7 = icmp ult i32 %6, %0
br i1 %7, label %13, label %8
8: ; preds = %2, %8
%9 = tail call i32 @putchar(i8 signext 7)
%10 = tail call i32 (...) @getchar()
%11 = sub nsw i32 %10, %1
%12 = icmp ult i32 %11, %0
br i1 %12, label %13, label %8
13: ; preds = %8, %2
%14 = phi i32 [ %6, %2 ], [ %11, %8 ]
ret i32 %14
}