#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();
scalar_t__ isPalindrome(char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  printf("This program checks for palindromes.\n");
  printf("Indicate the end of the input with a blank line.\n");
  char str[100];
  do {
    char c;
    int i = 0;
    printf("Enter a string: ");
    while ((c = getchar()) != '\n') {
      if (isalpha(c)) {
        str[i] = c;
        i++;
      }
    }
    str[i] = '\n';
    if (str[0] != '\n')
      printf("%s", isPalindrome(str) ? "That is a palindrome.\n"
                                     : "That is not a palindrome\n");
  } while (str[0] != '\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x88(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x81(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11e1 <main+0xa1>
movsbl -0x81(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     11dc <main+0x9c>
mov    -0x81(%rbp),%cl
movslq -0x88(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    118d <main+0x4d>
movslq -0x88(%rbp),%rax
movb   $0xa,-0x80(%rbp,%rax,1)
movsbl -0x80(%rbp),%eax
cmp    $0xa,%eax
je     122a <main+0xea>
lea    -0x80(%rbp),%rdi
call   1060 <isPalindrome@plt>
mov    %rax,%rcx
lea    0xe76(%rip),%rsi
lea    0xe58(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122f <main+0xef>
movsbl -0x80(%rbp),%eax
cmp    $0xa,%eax
jne    1175 <main+0x35>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%r12
mov    %rsp,%r14
lea    0xe8d(%rip),%rbp
lea    0xe83(%rip),%r15
xchg   %ax,%ax
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x0,%r13d
cmp    $0xa,%al
jne    11f0 <main+0xa0>
movslq %r13d,%rax
movb   $0xa,(%rsp,%rax,1)
cmpb   $0xa,(%rsp)
je     1227 <main+0xd7>
mov    %r14,%rdi
call   1070 <isPalindrome@plt>
test   %rax,%rax
mov    %rbp,%rsi
lea    0xe5e(%rip),%rax
cmove  %rax,%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpb   $0xa,(%rsp)
jne    1190 <main+0x40>
jmp    1227 <main+0xd7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%ebx
xor    %r13d,%r13d
jmp    120d <main+0xbd>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    $0xa,%al
je     11ab <main+0x5b>
movsbl %bl,%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     1200 <main+0xb0>
movslq %r13d,%r13
mov    %bl,(%rsp,%r13,1)
add    $0x1,%r13d
jmp    1200 <main+0xb0>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"This program checks for palindromes.\0A\00"
@.str.1 = [50 x i8] c"Indicate the end of the input with a blank line.\0A\00"
@.str.2 = [17 x i8] c"Enter a string: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [23 x i8] c"That is a palindrome.\0A\00"
@.str.5 = [26 x i8] c"That is not a palindrome\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %45, %2
store i32 0, i32* %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %28, %11
%14 = call signext i8 (...) @getchar()
store i8 %14, i8* %7
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i8, i8* %7
%19 = call i64 @isalpha(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i8, i8* %7
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %28
28: ; preds = %21, %17
br label %13
29: ; preds = %13
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %31
store i8 10, i8* %32
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 10
br i1 %36, label %37, label %44
37: ; preds = %29
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%39 = call i64 @isPalindrome(i8* %38)
%40 = icmp ne i64 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %37, %29
br label %45
45: ; preds = %44
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 10
br i1 %49, label %11, label %50
50: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [17 x i8] c"Enter a string: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [23 x i8] c"That is a palindrome.\0A\00"
@.str.5 = [26 x i8] c"That is not a palindrome\0A\00"
@str = [37 x i8] c"This program checks for palindromes.\00"
@str.6 = [49 x i8] c"Indicate the end of the input with a blank line.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.6, i64 0, i64 0))
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %30, %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %24, label %11
11: ; preds = %7, %20
%12 = phi i8 [ %22, %20 ], [ %9, %7 ]
%13 = phi i32 [ %21, %20 ], [ 0, %7 ]
%14 = call i64 @isalpha(i8 signext %12)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = sext i32 %13 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %17
store i8 %12, i8* %18
%19 = add nsw i32 %13, 1
br label %20
20: ; preds = %16, %11
%21 = phi i32 [ %19, %16 ], [ %13, %11 ]
%22 = call signext i8 (...) @getchar()
%23 = icmp eq i8 %22, 10
br i1 %23, label %24, label %11
24: ; preds = %20, %7
%25 = phi i32 [ 0, %7 ], [ %21, %20 ]
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %26
store i8 10, i8* %27
%28 = load i8, i8* %6
%29 = icmp eq i8 %28, 10
br i1 %29, label %37, label %30
30: ; preds = %24
%31 = call i64 @isPalindrome(i8* %6)
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = load i8, i8* %6
%36 = icmp eq i8 %35, 10
br i1 %36, label %37, label %7
37: ; preds = %24, %30
ret i32 0
}