#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ flush_stdin();
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int strlen(char *);
int accept_number_form_user(void) {
  int num = 0;
  char buffer[256] = {0x00};
  do {
    printf("Enter a Number between 1 to 9 : ");
    scanf(" %[^\n]s", buffer);
    if (strlen(buffer) == 1) {
      sscanf(buffer, " %d", &num);
    }
    if (num < 1 || num > 9) {
      printf("Please Try Again...\n");
    }
    flush_stdin();
    memset(buffer, 0x00, sizeof(buffer));
  } while (num < 1 || num > 9);
  return num;
}


x86 assembly (clang, -O0):
<accept_number_form_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1080 <scanf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    11d0 <accept_number_form_user+0x70>
lea    -0x110(%rbp),%rdi
lea    0xe62(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1070 <sscanf@plt>
cmpl   $0x1,-0x4(%rbp)
jl     11e4 <accept_number_form_user+0x84>
cmpl   $0x9,-0x4(%rbp)
jle    11f0 <accept_number_form_user+0x90>
lea    0xe42(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <flush_stdin@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1060 <memset@plt>
mov    $0x1,%al
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x111(%rbp)
jl     1229 <accept_number_form_user+0xc9>
cmpl   $0x9,-0x4(%rbp)
setg   %al
mov    %al,-0x111(%rbp)
mov    -0x111(%rbp),%al
test   $0x1,%al
jne    1185 <accept_number_form_user+0x25>
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_number_form_user>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xe02(%rip),%r14
lea    0xe1c(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xe18(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xe10(%rip),%rbp
jmp    1242 <accept_number_form_user+0xd2>
nop
xor    %eax,%eax
call   1030 <flush_stdin@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    0xc(%rsp),%eax
lea    -0xa(%rax),%ecx
cmp    $0xfffffff7,%ecx
jae    1286 <accept_number_form_user+0x116>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jne    1270 <accept_number_form_user+0x100>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffff6,%eax
cmp    $0xfffffff6,%eax
ja     1220 <accept_number_form_user+0xb0>
mov    %rbp,%rdi
call   1040 <puts@plt>
jmp    1220 <accept_number_form_user+0xb0>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter a Number between 1 to 9 : \00"
@.str.1 = [8 x i8] c" %[^\0A]s\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [21 x i8] c"Please Try Again...\0A\00"
define i32 @accept_number_form_user() {
%1 = alloca i32
%2 = alloca [256 x i8]
store i32 0, i32* %1
%3 = bitcast [256 x i8]* %2 to i8*
br label %4
4: ; preds = %32, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
br label %14
14: ; preds = %11, %4
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %1
%19 = icmp sgt i32 %18, 9
br i1 %19, label %20, label %22
20: ; preds = %17, %14
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = call i32 (...) @flush_stdin()
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 256)
br label %26
26: ; preds = %22
%27 = load i32, i32* %1
%28 = icmp slt i32 %27, 1
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %1
%31 = icmp sgt i32 %30, 9
br label %32
32: ; preds = %29, %26
%33 = phi i1 [ true, %26 ], [ %31, %29 ]
br i1 %33, label %4, label %34
34: ; preds = %32
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter a Number between 1 to 9 : \00"
@.str.1 = [8 x i8] c" %[^\0A]s\00"
@.str.2 = [4 x i8] c" %d\00"
@str = [20 x i8] c"Please Try Again...\00"
define i32 @accept_number_form_user() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %18, %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 @strlen(i8* %4)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
br label %12
12: ; preds = %10, %5
%13 = load i32, i32* %1
%14 = add i32 %13, -10
%15 = icmp ult i32 %14, -9
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %12, %16
%19 = call i32 (...) @flush_stdin()
%20 = call i32 @memset(i8* %4, i32 0, i32 256)
%21 = load i32, i32* %1
%22 = add i32 %21, -10
%23 = icmp ult i32 %22, -9
br i1 %23, label %5, label %24
24: ; preds = %18
ret i32 %21
}