#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*/ clean_stdin();
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *, char *);
int requestMenuOption() {
  int option, read;
  char enter;
  printf("******************************\n");
  printf("*      SELECT AN OPTION      *\n");
  printf("*----------------------------*\n");
  printf("*  0.- End Execution         *\n");
  printf("*  1.- Number of Rows        *\n");
  printf("*  2.- Number of Columns     *\n");
  printf("*  3.- Number of Characters  *\n");
  printf("*  4.- Longest Row           *\n");
  printf("*  5.- Print Row             *\n");
  printf("*  6.- Print File            *\n");
  printf("******************************\n");
  while (1) {
    printf("Insert option number: ");
    read = scanf("%d%c", &option, &enter);
    if (read != 2 || enter != '\n') {
      printf("Incorrect value, please try again.\n");
      clean_stdin();
    } else if (option < 0 || option > 6) {
      printf("Value out of range, please try again.\n");
    } else {
      return option;
    }
  }
}


x86 assembly (clang, -O0):
<requestMenuOption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
lea    0xefd(%rip),%rdi
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
lea    0xf25(%rip),%rdi
call   1030 <printf@plt>
lea    0xf39(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf61(%rip),%rdi
call   1030 <printf@plt>
lea    0xf75(%rip),%rdi
call   1030 <printf@plt>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
lea    0xf7d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf88(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x9(%rbp),%rdx
call   1050 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11f6 <requestMenuOption+0xc6>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     120e <requestMenuOption+0xde>
lea    0xf5f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <clean_stdin@plt>
jmp    1241 <requestMenuOption+0x111>
cmpl   $0x0,-0x4(%rbp)
jl     1222 <requestMenuOption+0xf2>
cmpl   $0x6,-0x4(%rbp)
jle    1233 <requestMenuOption+0x103>
lea    0xf57(%rip),%rdi
call   1030 <printf@plt>
jmp    123c <requestMenuOption+0x10c>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
jmp    1241 <requestMenuOption+0x111>
jmp    11bc <requestMenuOption+0x8c>

x86 assembly (clang, -O2):
<requestMenuOption>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xfe1(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf40(%rip),%rdi
call   1030 <puts@plt>
lea    0xf53(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe2b(%rip),%r14
lea    0xe3b(%rip),%r15
lea    0x4(%rsp),%r12
lea    0x3(%rsp),%rbx
lea    0xf8b(%rip),%r13
lea    0xf5e(%rip),%rbp
jmp    120f <requestMenuOption+0xcf>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <clean_stdin@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    1200 <requestMenuOption+0xc0>
cmpb   $0xa,0x3(%rsp)
jne    1200 <requestMenuOption+0xc0>
mov    0x4(%rsp),%eax
cmp    $0x7,%eax
jb     1244 <requestMenuOption+0x104>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    120f <requestMenuOption+0xcf>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"******************************\0A\00"
@.str.1 = [32 x i8] c"* SELECT AN OPTION *\0A\00"
@.str.2 = [32 x i8] c"*----------------------------*\0A\00"
@.str.3 = [32 x i8] c"* 0.- End Execution *\0A\00"
@.str.4 = [32 x i8] c"* 1.- Number of Rows *\0A\00"
@.str.5 = [32 x i8] c"* 2.- Number of Columns *\0A\00"
@.str.6 = [32 x i8] c"* 3.- Number of Characters *\0A\00"
@.str.7 = [32 x i8] c"* 4.- Longest Row *\0A\00"
@.str.8 = [32 x i8] c"* 5.- Print Row *\0A\00"
@.str.9 = [32 x i8] c"* 6.- Print File *\0A\00"
@.str.10 = [23 x i8] c"Insert option number: \00"
@.str.11 = [5 x i8] c"%d%c\00"
@.str.12 = [36 x i8] c"Incorrect value, please try again.\0A\00"
@.str.13 = [39 x i8] c"Value out of range, please try again.\0A\00"
define i32 @requestMenuOption() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %0, %38
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32* %1, i8* %3)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 2
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %27
24: ; preds = %20, %15
%25 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0))
%26 = call i32 (...) @clean_stdin()
br label %38
27: ; preds = %20
%28 = load i32, i32* %1
%29 = icmp slt i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* %1
%32 = icmp sgt i32 %31, 6
br i1 %32, label %33, label %35
33: ; preds = %30, %27
%34 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.13, i64 0, i64 0))
br label %37
35: ; preds = %30
%36 = load i32, i32* %1
ret i32 %36
37: ; preds = %33
br label %38
38: ; preds = %37, %24
br label %15
}

LLVM IR (-O2):
@.str.10 = [23 x i8] c"Insert option number: \00"
@.str.11 = [5 x i8] c"%d%c\00"
@str.14 = [31 x i8] c"* SELECT AN OPTION *\00"
@str.15 = [31 x i8] c"*----------------------------*\00"
@str.16 = [31 x i8] c"* 0.- End Execution *\00"
@str.17 = [31 x i8] c"* 1.- Number of Rows *\00"
@str.18 = [31 x i8] c"* 2.- Number of Columns *\00"
@str.19 = [31 x i8] c"* 3.- Number of Characters *\00"
@str.20 = [31 x i8] c"* 4.- Longest Row *\00"
@str.21 = [31 x i8] c"* 5.- Print Row *\00"
@str.22 = [31 x i8] c"* 6.- Print File *\00"
@str.23 = [31 x i8] c"******************************\00"
@str.24 = [38 x i8] c"Value out of range, please try again.\00"
@str.25 = [35 x i8] c"Incorrect value, please try again.\00"
define i32 @requestMenuOption() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.23, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.14, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.15, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.16, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.18, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.19, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.20, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.21, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.22, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.23, i64 0, i64 0))
br label %15
15: ; preds = %30, %0
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32* %1, i8* %2)
%18 = icmp ne i32 %17, 2
%19 = load i8, i8* %2
%20 = icmp ne i8 %19, 10
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.25, i64 0, i64 0))
%24 = call i32 (...) @clean_stdin()
br label %30
25: ; preds = %15
%26 = load i32, i32* %1
%27 = icmp ugt i32 %26, 6
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.24, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
br label %15
31: ; preds = %25
ret i32 %26
}