#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*/ exit(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ isalpha(char);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char toupper(char);
int main(void) {
  char input, goal;
  int num;
  srand(time(NULL));
  printf("Guess My Letter Game\n\n");
  do {
    goal = rand() % 26 + 'A';
    num = 0;
    printf("I have a letter between A and Z.\n");
    do {
      num++;
      printf("Guess #%d (A - Z) : ", num);
      do
        input = getchar();
      while (!isalpha(input));
      input = toupper(input);
      if (input != goal) {
        printf("\nNo, my letter comes ");
        if (input < goal)
          printf("AFTER");
        else
          printf("BEFORE");
        printf(" your guess.\n");
      }
    } while (input != goal);
    printf("\nYou got it! It took you %d tries to guess my letter.\n", num);
    if (num >= 4)
      printf("I'm sure you could do better, though.\n");
    printf("\nDo you want to play again? (y/n) ");
    do
      input = getchar();
    while (!isalpha(input));
  } while ((input == 'y') || (input == 'Y'));
  printf("\nGoodbye.\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
add    $0x41,%edx
mov    %dl,%al
mov    %al,-0x6(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1080 <isalpha@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f3 <main+0x73>
movsbl -0x5(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
je     127f <main+0xff>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jge    1263 <main+0xe3>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1271 <main+0xf1>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1284 <main+0x104>
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jne    11d9 <main+0x59>
mov    -0xc(%rbp),%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x4,-0xc(%rbp)
jl     12bd <main+0x13d>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1080 <isalpha@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12cb <main+0x14b>
jmp    12f3 <main+0x173>
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0xd(%rbp)
je     1312 <main+0x192>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11ad <main+0x2d>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xee2(%rip),%rdi
call   1040 <puts@plt>
lea    0xe75(%rip),%r12
lea    0xf36(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
neg    %edx
lea    (%rax,%rdx,1),%r13d
add    $0x41,%r13d
lea    0xea2(%rip),%rdi
xor    %r15d,%r15d
nopl   0x0(%rax)
call   1040 <puts@plt>
lea    0x1(%r15),%ebp
lea    0xde0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <getchar@plt>
movsbl %al,%ebx
mov    %ebx,%edi
call   1090 <isalpha@plt>
test   %eax,%eax
je     1230 <main+0xa0>
mov    %ebx,%edi
call   1030 <toupper@plt>
movsbl %al,%ebx
cmp    %ebx,%r13d
je     1290 <main+0x100>
lea    0xdba(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebx,%r13d
mov    %r12,%rdi
lea    0xdbc(%rip),%rax
cmovg  %rax,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%r15d
jmp    1210 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xda1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x3,%r15d
jb     12b2 <main+0x122>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1090 <isalpha@plt>
test   %eax,%eax
je     12c0 <main+0x130>
and    $0xdf,%bl
cmp    $0x59,%bl
je     11d0 <main+0x40>
lea    0xde1(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Guess My Letter Game\0A\0A\00"
@.str.1 = [34 x i8] c"I have a letter between A and Z.\0A\00"
@.str.2 = [21 x i8] c"Guess #%d (A - Z) : \00"
@.str.3 = [22 x i8] c"\0ANo, my letter comes \00"
@.str.4 = [6 x i8] c"AFTER\00"
@.str.5 = [7 x i8] c"BEFORE\00"
@.str.6 = [14 x i8] c" your guess.\0A\00"
@.str.7 = [55 x i8] c"\0AYou got it! It took you %d tries to guess my letter.\0A\00"
@.str.8 = [39 x i8] c"I'm sure you could do better, though.\0A\00"
@.str.9 = [35 x i8] c"\0ADo you want to play again? (y/n) \00"
@.str.10 = [11 x i8] c"\0AGoodbye.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %79, %0
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 26
%11 = add nsw i32 %10, 65
%12 = trunc i32 %11 to i8
store i8 %12, i8* %3
store i32 0, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %48, %8
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %21, %14
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %2
br label %21
21: ; preds = %19
%22 = load i8, i8* %2
%23 = call i32 @isalpha(i8 signext %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %19, label %26
26: ; preds = %21
%27 = load i8, i8* %2
%28 = call signext i8 @toupper(i8 signext %27)
store i8 %28, i8* %2
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %30, %32
br i1 %33, label %34, label %47
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%36 = load i8, i8* %2
%37 = sext i8 %36 to i32
%38 = load i8, i8* %3
%39 = sext i8 %38 to i32
%40 = icmp slt i32 %37, %39
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %45
43: ; preds = %34
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %26
br label %48
48: ; preds = %47
%49 = load i8, i8* %2
%50 = sext i8 %49 to i32
%51 = load i8, i8* %3
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %50, %52
br i1 %53, label %14, label %54
54: ; preds = %48
%55 = load i32, i32* %4
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %4
%58 = icmp sge i32 %57, 4
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %59, %54
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %63
63: ; preds = %65, %61
%64 = call signext i8 (...) @getchar()
store i8 %64, i8* %2
br label %65
65: ; preds = %63
%66 = load i8, i8* %2
%67 = call i32 @isalpha(i8 signext %66)
%68 = icmp ne i32 %67, 0
%69 = xor i1 %68, true
br i1 %69, label %63, label %70
70: ; preds = %65
br label %71
71: ; preds = %70
%72 = load i8, i8* %2
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 121
br i1 %74, label %79, label %75
75: ; preds = %71
%76 = load i8, i8* %2
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 89
br label %79
79: ; preds = %75, %71
%80 = phi i1 [ true, %71 ], [ %78, %75 ]
br i1 %80, label %8, label %81
81: ; preds = %79
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%83 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"Guess #%d (A - Z) : \00"
@.str.3 = [22 x i8] c"\0ANo, my letter comes \00"
@.str.4 = [6 x i8] c"AFTER\00"
@.str.5 = [7 x i8] c"BEFORE\00"
@.str.7 = [55 x i8] c"\0AYou got it! It took you %d tries to guess my letter.\0A\00"
@.str.9 = [35 x i8] c"\0ADo you want to play again? (y/n) \00"
@str = [22 x i8] c"Guess My Letter Game\0A\00"
@str.11 = [33 x i8] c"I have a letter between A and Z.\00"
@str.12 = [10 x i8] c"\0AGoodbye.\00"
@str.13 = [38 x i8] c"I'm sure you could do better, though.\00"
@str.14 = [13 x i8] c" your guess.\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %38, %0
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 26
%7 = add nsw i32 %6, 65
br label %8
8: ; preds = %22, %4
%9 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.14, i64 0, i64 0), %22 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0), %4 ]
%10 = phi i32 [ %12, %22 ], [ 0, %4 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
%12 = add nuw nsw i32 %10, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %14, %8
%15 = tail call signext i8 (...) @getchar()
%16 = tail call i32 @isalpha(i8 signext %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %14, label %18
18: ; preds = %14
%19 = tail call signext i8 @toupper(i8 signext %15)
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %7, %20
br i1 %21, label %27, label %22
22: ; preds = %18
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp sgt i32 %7, %20
%25 = select i1 %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %25)
br label %8
27: ; preds = %18
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0), i32 %12)
%29 = icmp ugt i32 %10, 2
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.13, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %34
34: ; preds = %34, %32
%35 = tail call signext i8 (...) @getchar()
%36 = tail call i32 @isalpha(i8 signext %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %34, label %38
38: ; preds = %34
%39 = and i8 %35, -33
%40 = icmp eq i8 %39, 89
br i1 %40, label %4, label %41
41: ; preds = %38
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0))
%43 = tail call i32 @exit(i32 0)
unreachable
}