#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void askForMenuNumber(int *choice, int numberOfOptions) {
  do {
    printf("   |   Type number:                                                "
           "         "
           "|\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
           "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
    while (!scanf("%d", choice))
      getchar();
  } while (*choice < 1 || *choice > numberOfOptions);
}


x86 assembly (clang, -O0):
<askForMenuNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xf31(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1170 <askForMenuNumber+0x40>
jmp    117c <askForMenuNumber+0x4c>
mov    $0x0,%al
call   1040 <getchar@plt>
jmp    114b <askForMenuNumber+0x1b>
jmp    1181 <askForMenuNumber+0x51>
mov    -0x8(%rbp),%rcx
mov    $0x1,%al
cmpl   $0x1,(%rcx)
mov    %al,-0xd(%rbp)
jl     11a2 <askForMenuNumber+0x72>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    113f <askForMenuNumber+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askForMenuNumber>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xebc(%rip),%r14
lea    0xf3c(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <printf@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
test   %eax,%eax
jne    1180 <askForMenuNumber+0x50>
xor    %eax,%eax
call   1040 <getchar@plt>
jmp    1160 <askForMenuNumber+0x30>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%eax
test   %eax,%eax
jle    1150 <askForMenuNumber+0x20>
cmp    %r15d,%eax
jg     1150 <askForMenuNumber+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [135 x i8] c" | Type number: |\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\00"
@.str.1 = [3 x i8] c"%d\00"
define void @askForMenuNumber(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %24, %2
%6 = call i32 @printf(i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %12, %5
%8 = load i32*, i32** %3
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (...) @getchar()
br label %7
14: ; preds = %7
br label %15
15: ; preds = %14
%16 = load i32*, i32** %3
%17 = load i32, i32* %16
%18 = icmp slt i32 %17, 1
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
%22 = load i32, i32* %4
%23 = icmp sgt i32 %21, %22
br label %24
24: ; preds = %19, %15
%25 = phi i1 [ true, %15 ], [ %23, %19 ]
br i1 %25, label %5, label %26
26: ; preds = %24
ret void
}

LLVM IR (-O2):
@.str = [135 x i8] c" | Type number: |\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\08\00"
@.str.1 = [3 x i8] c"%d\00"
define void @askForMenuNumber(i32* %0, i32 %1) {
br label %3
3: ; preds = %11, %2
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([135 x i8], [135 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %3, %7
%8 = tail call i32 (...) @getchar()
%9 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %7, label %11
11: ; preds = %7, %3
%12 = load i32, i32* %0
%13 = icmp slt i32 %12, 1
%14 = icmp sgt i32 %12, %1
%15 = or i1 %13, %14
br i1 %15, label %3, label %16
16: ; preds = %11
ret void
}