#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*/ keybFlush();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, char *);
int getInt() {
  int val;
  char nl = 'x';
  while (nl != '\n') {
    scanf("%d%c", &val, &nl);
    if (nl != '\n') {
      keybFlush();
      printf("Invalid Integer, please try again: ");
    }
  }
  return val;
}


x86 assembly (clang, -O0):
<getInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x78,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     1182 <getInt+0x52>
lea    0xeb0(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x5(%rbp),%rdx
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     117d <getInt+0x4d>
mov    $0x0,%al
call   1040 <keybFlush@plt>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    113c <getInt+0xc>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movb   $0x78,0x3(%rsp)
lea    0xebc(%rip),%r14
lea    0x4(%rsp),%r15
lea    0x3(%rsp),%r12
lea    0xeb0(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <scanf@plt>
cmpb   $0xa,0x3(%rsp)
je     118b <getInt+0x5b>
xor    %eax,%eax
call   1040 <keybFlush@plt>
mov    %rbx,%rdi
call   1030 <printf@plt>
cmpb   $0xa,0x3(%rsp)
jne    1160 <getInt+0x30>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%c\00"
@.str.1 = [36 x i8] c"Invalid Integer, please try again: \00"
define i32 @getInt() {
%1 = alloca i32
%2 = alloca i8
store i8 120, i8* %2
br label %3
3: ; preds = %15, %0
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = icmp ne i32 %5, 10
br i1 %6, label %7, label %16
7: ; preds = %3
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i8* %2)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = call i32 (...) @keybFlush()
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %12, %7
br label %3
16: ; preds = %3
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%c\00"
@.str.1 = [36 x i8] c"Invalid Integer, please try again: \00"
define i32 @getInt() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i8 120, i8* %2
br label %4
4: ; preds = %0, %8
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i8* %2)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 10
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = call i32 (...) @keybFlush()
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%11 = load i8, i8* %2
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %4
13: ; preds = %4, %8
%14 = load i32, i32* %1
ret i32 %14
}