#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 EOF;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char getInput(char *input) {
  do {
    fflush(stdin);
    fflush(stdout);
    printf(input);
    int temp = 0;
    int err = scanf("%c", &temp);
    if (err == EOF) {
      printf("Please enter valid input.\n");
    } else {
      return temp;
    }
  } while (1);
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
lea    0xe91(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%eax
jne    119e <getInput+0x6e>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
jmp    11a9 <getInput+0x79>
mov    -0x14(%rbp),%eax
mov    %al,-0x1(%rbp)
jmp    11bd <getInput+0x8d>
jmp    11ae <getInput+0x7e>
mov    $0x1,%al
test   $0x1,%al
jne    113c <getInput+0xc>
jmp    11bd <getInput+0x8d>
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e6d(%rip),%rbp
mov    0x0(%rbp),%edi
call   1050 <fflush@plt>
mov    %rbx,%rdi
call   1040 <printf@plt>
movl   $0x0,0x4(%rsp)
lea    0xe7e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e4d(%rip),%r13
cmp    0x0(%r13),%eax
jne    11ef <getInput+0xaf>
lea    0xe63(%rip),%r14
lea    0xe59(%rip),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x0(%rbp),%edi
call   1050 <fflush@plt>
mov    %rbx,%rdi
call   1040 <printf@plt>
movl   $0x0,0x4(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
cmp    0x0(%r13),%eax
je     11b0 <getInput+0x70>
mov    0x4(%rsp),%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@.str = [3 x i8] c"%c\00"
@EOF = global i32 0
@.str.1 = [27 x i8] c"Please enter valid input.\0A\00"
define signext i8 @getInput(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
br label %6
6: ; preds = %23, %1
%7 = load i32, i32* @stdin
%8 = call i32 @fflush(i32 %7)
%9 = load i32, i32* @stdout
%10 = call i32 @fflush(i32 %9)
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* %11)
store i32 0, i32* %4
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %6
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %22
19: ; preds = %6
%20 = load i32, i32* %4
%21 = trunc i32 %20 to i8
store i8 %21, i8* %2
br label %24
22: ; preds = %17
br label %23
23: ; preds = %22
br i1 true, label %6, label %24
24: ; preds = %19, %23
%25 = load i8, i8* %2
ret i8 %25
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@.str = [3 x i8] c"%c\00"
@EOF = global i32 0
@str = [26 x i8] c"Please enter valid input.\00"
define signext i8 @getInput(i8* nocapture %0) {
%2 = alloca i32
%3 = load i32, i32* @stdin
%4 = call i32 @fflush(i32 %3)
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = call i32 @printf(i8* dereferenceable(1) %0)
%8 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %1, %12
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @stdin
%15 = call i32 @fflush(i32 %14)
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
%18 = call i32 @printf(i8* dereferenceable(1) %0)
store i32 0, i32* %2
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %12, label %22
22: ; preds = %12, %1
%23 = load i32, i32* %2
%24 = trunc i32 %23 to i8
ret i8 %24
}