#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*/ printf(char *);
int main() {
  char input, last = 'A', answer = '?';
  printf("Enter a word: ");
  while ((input = getchar()) != '\n') {
    if (input >= 'a' && input <= 'z') {
      input -= 'a' - 'A';
    }
    if (input >= 'A' && input <= 'Z') {
      if (input >= last) {
        last = input;
        answer = 'y';
      } else {
        answer = 'n';
        break;
      }
    } else {
      answer = '?';
      break;
    }
  }
  switch (answer) {
  case ('y'):
    printf("\nThe word is in alphabetical order");
    break;
  case ('n'):
    printf("\nThe word is NOT in alphabetical order");
    break;
  case ('?'):
    printf("\nThat's not a word!");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x41,-0x6(%rbp)
movb   $0x3f,-0x7(%rbp)
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11d2 <main+0xb2>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     117d <main+0x5d>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jg     117d <main+0x5d>
movsbl -0x5(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     11c4 <main+0xa4>
movsbl -0x5(%rbp),%eax
cmp    $0x5a,%eax
jg     11c4 <main+0xa4>
movsbl -0x5(%rbp),%eax
movsbl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jl     11b6 <main+0x96>
mov    -0x5(%rbp),%al
mov    %al,-0x6(%rbp)
movb   $0x79,-0x7(%rbp)
jmp    11bf <main+0x9f>
movb   $0x6e,-0x7(%rbp)
jmp    11d2 <main+0xb2>
jmp    11cd <main+0xad>
movb   $0x3f,-0x7(%rbp)
jmp    11d2 <main+0xb2>
jmp    1143 <main+0x23>
movsbl -0x7(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x3f,%eax
je     122b <main+0x10b>
jmp    11e7 <main+0xc7>
mov    -0xc(%rbp),%eax
sub    $0x6e,%eax
je     121a <main+0xfa>
jmp    11f8 <main+0xd8>
mov    -0xc(%rbp),%eax
sub    $0x79,%eax
jne    1237 <main+0x117>
jmp    1209 <main+0xe9>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
jmp    1237 <main+0x117>
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
jmp    1237 <main+0x117>
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0xf17(%rip),%r12
cmp    $0xa,%al
je     1193 <main+0x73>
mov    $0x41,%cl
lea    0xee3(%rip),%r14
lea    0xeb9(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
lea    -0x61(%rax),%edx
lea    -0x20(%rax),%esi
cmp    $0x1a,%dl
movzbl %al,%eax
movzbl %sil,%ebx
cmovae %eax,%ebx
lea    -0x41(%rbx),%eax
cmp    $0x19,%al
ja     1193 <main+0x73>
cmp    %cl,%bl
jb     1190 <main+0x70>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebx,%ecx
cmp    $0xa,%al
jne    1160 <main+0x40>
mov    %r15,%r12
jmp    1193 <main+0x73>
mov    %r14,%r12
mov    %r12,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter a word: \00"
@.str.1 = [35 x i8] c"\0AThe word is in alphabetical order\00"
@.str.2 = [39 x i8] c"\0AThe word is NOT in alphabetical order\00"
@.str.3 = [20 x i8] c"\0AThat's not a word!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i32 0, i32* %1
store i8 65, i8* %3
store i8 63, i8* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %42, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %43
10: ; preds = %6
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp sge i32 %12, 97
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp sle i32 %16, 122
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = sub nsw i32 %20, 32
%22 = trunc i32 %21 to i8
store i8 %22, i8* %2
br label %23
23: ; preds = %18, %14, %10
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp sge i32 %25, 65
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i8, i8* %2
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 90
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = load i8, i8* %2
%33 = sext i8 %32 to i32
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %33, %35
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = load i8, i8* %2
store i8 %38, i8* %3
store i8 121, i8* %4
br label %40
39: ; preds = %31
store i8 110, i8* %4
br label %43
40: ; preds = %37
br label %42
41: ; preds = %27, %23
store i8 63, i8* %4
br label %43
42: ; preds = %40
br label %6
43: ; preds = %41, %39, %6
%44 = load i8, i8* %4
%45 = sext i8 %44 to i32
switch i32 %45, label %52 [
i32 121, label %46
i32 110, label %48
i32 63, label %50
]
46: ; preds = %43
%47 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %52
48: ; preds = %43
%49 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %52
50: ; preds = %43
%51 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %52
52: ; preds = %43, %50, %48, %46
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter a word: \00"
@.str.1 = [35 x i8] c"\0AThe word is in alphabetical order\00"
@.str.2 = [39 x i8] c"\0AThe word is NOT in alphabetical order\00"
@.str.3 = [20 x i8] c"\0AThat's not a word!\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %18, label %7
4: ; preds = %16
%5 = tail call signext i8 (...) @getchar()
%6 = icmp eq i8 %5, 10
br i1 %6, label %18, label %7
7: ; preds = %0, %4
%8 = phi i8 [ %5, %4 ], [ %2, %0 ]
%9 = phi i8 [ %13, %4 ], [ 65, %0 ]
%10 = add i8 %8, -97
%11 = icmp ult i8 %10, 26
%12 = add i8 %8, -32
%13 = select i1 %11, i8 %12, i8 %8
%14 = add i8 %13, -65
%15 = icmp ult i8 %14, 26
br i1 %15, label %16, label %18
16: ; preds = %7
%17 = icmp ult i8 %13, %9
br i1 %17, label %18, label %4
18: ; preds = %7, %16, %4, %0
%19 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), %16 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %7 ]
%20 = tail call i32 @printf(i8* dereferenceable(1) %19)
ret i32 0
}