#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*/ fscanf(int /*<<< orphan*/, char *, char *);
char getchar();
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
char tolower(char);
char getLetter(void) {
  char c = '\0';
  fscanf(stdin, " %c", &c);
  while (!isalpha(c)) {
    while (getchar() != '\n')
      ;
    printf("Please enter a valid letter: ");
    fscanf(stdin, " %c", &c);
  }
  while (getchar() != '\n')
    ;
  return tolower(c);
}


x86 assembly (clang, -O0):
<getLetter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x0,-0x1(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
lea    -0x1(%rbp),%rdx
call   1040 <fscanf@plt>
movsbl -0x1(%rbp),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1193 <getLetter+0x43>
jmp    11da <getLetter+0x8a>
jmp    1198 <getLetter+0x48>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11b0 <getLetter+0x60>
jmp    1198 <getLetter+0x48>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
lea    -0x1(%rbp),%rdx
call   1040 <fscanf@plt>
jmp    1175 <getLetter+0x25>
jmp    11df <getLetter+0x8f>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11f7 <getLetter+0xa7>
jmp    11df <getLetter+0x8f>
movsbl -0x1(%rbp),%edi
call   1060 <tolower@plt>
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLetter>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movb   $0x0,0x7(%rsp)
mov    0x2e84(%rip),%r12
mov    (%r12),%edi
lea    0xe91(%rip),%rsi
lea    0x7(%rsp),%rdx
call   1040 <fscanf@plt>
movsbl 0x7(%rsp),%edi
call   1070 <isalpha@plt>
test   %eax,%eax
jne    11d0 <getLetter+0x80>
lea    0xe76(%rip),%r14
lea    0xe6b(%rip),%r15
lea    0x7(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11a0 <getLetter+0x50>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    (%r12),%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
movsbl 0x7(%rsp),%edi
call   1070 <isalpha@plt>
test   %eax,%eax
je     11a0 <getLetter+0x50>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    11d0 <getLetter+0x80>
movsbl 0x7(%rsp),%edi
call   1060 <tolower@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c" %c\00"
@.str.1 = [30 x i8] c"Please enter a valid letter: \00"
define signext i8 @getLetter() {
%1 = alloca i8
store i8 0, i8* %1
%2 = load i32, i32* @stdin
%3 = call i32 @fscanf(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %4
4: ; preds = %15, %0
%5 = load i8, i8* %1
%6 = call i32 @isalpha(i8 signext %5)
%7 = icmp ne i32 %6, 0
%8 = xor i1 %7, true
br i1 %8, label %9, label %19
9: ; preds = %4
br label %10
10: ; preds = %14, %9
%11 = call signext i8 (...) @getchar()
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i32 @fscanf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %4
19: ; preds = %4
br label %20
20: ; preds = %24, %19
%21 = call signext i8 (...) @getchar()
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %20
br label %20
25: ; preds = %20
%26 = load i8, i8* %1
%27 = call signext i8 @tolower(i8 signext %26)
ret i8 %27
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c" %c\00"
@.str.1 = [30 x i8] c"Please enter a valid letter: \00"
define signext i8 @getLetter() {
%1 = alloca i8
store i8 0, i8* %1
%2 = load i32, i32* @stdin
%3 = call i32 @fscanf(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = call i32 @isalpha(i8 signext %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %0, %10
%8 = call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 10
br i1 %9, label %11, label %10
10: ; preds = %7, %11
br label %7
11: ; preds = %7
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @fscanf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
%15 = load i8, i8* %1
%16 = call i32 @isalpha(i8 signext %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %10, label %18
18: ; preds = %11, %0
br label %19
19: ; preds = %18, %19
%20 = call signext i8 (...) @getchar()
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %19
22: ; preds = %19
%23 = load i8, i8* %1
%24 = call signext i8 @tolower(i8 signext %23)
ret i8 %24
}