#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 getNumber() {
  int n1, read;
  char enter;
  while (1) {
    printf("Insert whole integer: ");
    read = scanf("%d%c", &n1, &enter);
    if (read != 2 || enter != '\n' || n1 < 0) {
      printf("Incorrect value, try again\n");
      clean_stdin();
    } else {
      return n1;
    }
  }
}


x86 assembly (clang, -O0):
<getNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x9(%rbp),%rdx
call   1050 <scanf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    117c <getNumber+0x4c>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    117c <getNumber+0x4c>
cmpl   $0x0,-0x4(%rbp)
jge    1194 <getNumber+0x64>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <clean_stdin@plt>
jmp    119d <getNumber+0x6d>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
jmp    1138 <getNumber+0x8>

x86 assembly (clang, -O2):
<getNumber>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0xb(%rsp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    1183 <getNumber+0x43>
cmpb   $0xa,0xb(%rsp)
jne    1183 <getNumber+0x43>
mov    0xc(%rsp),%eax
test   %eax,%eax
jns    11e9 <getNumber+0xa9>
lea    0xe92(%rip),%r14
lea    0xe6f(%rip),%r15
lea    0xe7f(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xb(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <clean_stdin@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    11b0 <getNumber+0x70>
cmpb   $0xa,0xb(%rsp)
jne    11b0 <getNumber+0x70>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     11b0 <getNumber+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Insert whole integer: \00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [28 x i8] c"Incorrect value, try again\0A\00"
define i32 @getNumber() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
br label %4
4: ; preds = %0, %21
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i8* %3)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 2
br i1 %8, label %16, label %9
9: ; preds = %4
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 10
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %9, %4
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (...) @clean_stdin()
br label %21
19: ; preds = %13
%20 = load i32, i32* %1
ret i32 %20
21: ; preds = %16
br label %4
}

LLVM IR (-O2):
@.str = [23 x i8] c"Insert whole integer: \00"
@.str.1 = [5 x i8] c"%d%c\00"
@str = [27 x i8] c"Incorrect value, try again\00"
define i32 @getNumber() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i8* %2)
%6 = icmp ne i32 %5, 2
%7 = load i8, i8* %2
%8 = icmp ne i8 %7, 10
%9 = select i1 %6, i1 true, i1 %8
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 0
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %13, label %25
13: ; preds = %0, %13
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = call i32 (...) @clean_stdin()
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, 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
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 0
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %13, label %25
25: ; preds = %13, %0
%26 = phi i32 [ %10, %0 ], [ %22, %13 ]
ret i32 %26
}