#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 */
char getchar();
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ printf(char *);
char tolower(char);
char getCharFromUser() {
  char guess;
  do {
    printf("Please enter your next guess: ");
    guess = getchar();
  } while (!isalpha(guess));
  while (getchar() != '\n')
    ;
  printf("\n\n");
  return tolower(guess);
}


x86 assembly (clang, -O0):
<getCharFromUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1148 <getCharFromUser+0x8>
jmp    117c <getCharFromUser+0x3c>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1194 <getCharFromUser+0x54>
jmp    117c <getCharFromUser+0x3c>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x1(%rbp),%edi
call   1050 <tolower@plt>
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCharFromUser>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%ebx
mov    %ebx,%edi
call   1070 <isalpha@plt>
test   %eax,%eax
je     1160 <getCharFromUser+0x10>
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1180 <getCharFromUser+0x30>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <tolower@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Please enter your next guess: \00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define signext i8 @getCharFromUser() {
%1 = alloca i8
br label %2
2: ; preds = %5, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %1
br label %5
5: ; preds = %2
%6 = load i8, i8* %1
%7 = call i32 @isalpha(i8 signext %6)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
br i1 %9, label %2, label %10
10: ; preds = %5
br label %11
11: ; preds = %15, %10
%12 = call signext i8 (...) @getchar()
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %11
br label %11
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8, i8* %1
%19 = call signext i8 @tolower(i8 signext %18)
ret i8 %19
}

LLVM IR (-O2):
@.str = [31 x i8] c"Please enter your next guess: \00"
@str = [2 x i8] c"\0A\00"
define signext i8 @getCharFromUser() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%3 = tail call signext i8 (...) @getchar()
%4 = tail call i32 @isalpha(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %1, label %6
6: ; preds = %1, %6
%7 = tail call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 10
br i1 %8, label %9, label %6
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%11 = tail call signext i8 @tolower(i8 signext %3)
ret i8 %11
}