#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 */
typedef int /*<<< orphan*/ in_line;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getc(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  char in_line[10];
  int i;
  fprintf(stdout, "WAITING\n");
  fflush(stdout);
  for (i = 0; i < sizeof(in_line);) {
    in_line[i] = getc(stdin);
    if ((in_line[i] < 'a') || (in_line[i] > 'z'))
      i = 0;
    else if (strncmp(in_line, "exit", 4) == 0)
      exit(0);
    else
      i++;
  }
  fprintf(stderr, "Invalid input\n");
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    $0xa,%rax
jae    121f <main+0xcf>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1070 <getc@plt>
mov    %al,%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x1a(%rbp,%rax,1)
movslq -0x20(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     11da <main+0x8a>
movslq -0x20(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jle    11e6 <main+0x96>
movl   $0x0,-0x20(%rbp)
jmp    121a <main+0xca>
lea    -0x1a(%rbp),%rdi
lea    0xe18(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    120c <main+0xbc>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121a <main+0xca>
jmp    1190 <main+0x40>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e6d(%rip),%rbx
mov    (%rbx),%edi
lea    0xe94(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
xor    %ebp,%ebp
mov    0x2e67(%rip),%r12
lea    0xe81(%rip),%r14
lea    0x6(%rsp),%r15
jmp    1197 <main+0x47>
nop
mov    %ecx,%ebp
cmp    $0xa,%ecx
jae    11cd <main+0x7d>
mov    %ebp,%ebx
mov    (%r12),%edi
call   1070 <getc@plt>
mov    %al,0x6(%rsp,%rbx,1)
add    $0x85,%al
mov    $0x0,%ecx
cmp    $0xe6,%al
jb     1190 <main+0x40>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ec <main+0x9c>
add    $0x1,%ebp
mov    %ebp,%ecx
jmp    1190 <main+0x40>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [9 x i8] c"WAITING\0A\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"exit\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"Invalid input\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @stdout
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
store i32 0, i32* %7
br label %12
12: ; preds = %46, %2
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = icmp ult i64 %14, 10
br i1 %15, label %16, label %47
16: ; preds = %12
%17 = load i32, i32* @stdin
%18 = call signext i8 @getc(i32 %17)
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp slt i32 %26, 97
br i1 %27, label %35, label %28
28: ; preds = %16
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sgt i32 %33, 122
br i1 %34, label %35, label %36
35: ; preds = %28, %16
store i32 0, i32* %7
br label %46
36: ; preds = %28
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @exit(i32 0)
unreachable
42: ; preds = %36
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %45
45: ; preds = %42
br label %46
46: ; preds = %45, %35
br label %12
47: ; preds = %12
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [9 x i8] c"WAITING\0A\00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"exit\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"Invalid input\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdout
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = tail call i32 @fflush(i32 %7)
br label %9
9: ; preds = %2, %24
%10 = phi i32 [ 0, %2 ], [ %25, %24 ]
%11 = zext i32 %10 to i64
%12 = load i32, i32* @stdin
%13 = call signext i8 @getc(i32 %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %11
store i8 %13, i8* %14
%15 = add i8 %13, -123
%16 = icmp ult i8 %15, -26
br i1 %16, label %24, label %17
17: ; preds = %9
%18 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %17
%23 = add nuw nsw i32 %10, 1
br label %24
24: ; preds = %9, %22
%25 = phi i32 [ %23, %22 ], [ 0, %9 ]
%26 = icmp ult i32 %25, 10
br i1 %26, label %9, label %27
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
}