#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*/ _flushall();
int determine_palindrome(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ pause_clear(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove_punc(int, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void checkPalindrome(void) {
  int i = 0, str_length = 0, is_palindrome = 0;
  char input_word[1024] = "", input_word2[1024] = "", input_backup[1024];
  printf("Word/Phrase for Palindrome Checking? ");
  _flushall();
  gets(input_word);
  strcpy(input_backup, input_word);
  for (str_length = 0; input_word[str_length] != '\0'; str_length++)
    ;
  remove_punc(str_length, input_word, input_word2);
  for (str_length = 0; input_word2[str_length] != '\0'; str_length++)
    ;
  is_palindrome = determine_palindrome(0, str_length - 1, input_word2);
  if (is_palindrome)
    printf("The word/sentance inputted, %s, is a palindrome!\n\n",
           input_backup);
  else
    printf("The word/sentance inputted, %s, is not a palindrome!\n\n",
           input_backup);
  pause_clear(1, 1);
}


x86 assembly (clang, -O0):
<checkPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <_flushall@plt>
lea    -0x410(%rbp),%rdi
call   1060 <gets@plt>
lea    -0xc10(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1229 <checkPalindrome+0xa9>
jmp    121b <checkPalindrome+0x9b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1201 <checkPalindrome+0x81>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
lea    -0x810(%rbp),%rdx
call   1090 <remove_punc@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x810(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     126e <checkPalindrome+0xee>
jmp    1260 <checkPalindrome+0xe0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1246 <checkPalindrome+0xc6>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    -0x810(%rbp),%rdx
xor    %edi,%edi
call   10a0 <determine_palindrome@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     12a9 <checkPalindrome+0x129>
lea    -0xc10(%rbp),%rsi
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12be <checkPalindrome+0x13e>
lea    -0xc10(%rbp),%rsi
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1080 <pause_clear@plt>
add    $0xc10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPalindrome>:
push   %r14
push   %rbx
sub    $0xc08,%rsp
lea    0x800(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x400(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <_flushall@plt>
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0xffffffff,%edi
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%edi
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    11f0 <checkPalindrome+0x70>
lea    0x800(%rsp),%rsi
mov    %r14,%rdx
call   1090 <remove_punc@plt>
mov    $0xfffffffe,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%esi
cmpb   $0x0,(%r14)
lea    0x1(%r14),%r14
jne    1220 <checkPalindrome+0xa0>
lea    0x400(%rsp),%rdx
xor    %edi,%edi
call   10a0 <determine_palindrome@plt>
test   %eax,%eax
lea    0xe14(%rip),%rax
lea    0xdda(%rip),%rdi
cmove  %rax,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1080 <pause_clear@plt>
add    $0xc08,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Word/Phrase for Palindrome Checking? \00"
@.str.1 = [51 x i8] c"The word/sentance inputted, %s, is a palindrome!\0A\0A\00"
@.str.2 = [55 x i8] c"The word/sentance inputted, %s, is not a palindrome!\0A\0A\00"
define void @checkPalindrome() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%7 = bitcast [1024 x i8]* %4 to i8*
%8 = bitcast [1024 x i8]* %5 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @_flushall()
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = call i32 @strcpy(i8* %13, i8* %14)
store i32 0, i32* %2
br label %16
16: ; preds = %24, %0
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %16
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %16
27: ; preds = %16
%28 = load i32, i32* %2
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%31 = call i32 @remove_punc(i32 %28, i8* %29, i8* %30)
store i32 0, i32* %2
br label %32
32: ; preds = %40, %27
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %32
br label %40
40: ; preds = %39
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %32
43: ; preds = %32
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 1
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%47 = call i32 @determine_palindrome(i32 0, i32 %45, i8* %46)
store i32 %47, i32* %3
%48 = load i32, i32* %3
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %43
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i8* %51)
br label %56
53: ; preds = %43
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %50
%57 = call i32 @pause_clear(i32 1, i32 1)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Word/Phrase for Palindrome Checking? \00"
@.str.1 = [51 x i8] c"The word/sentance inputted, %s, is a palindrome!\0A\0A\00"
@.str.2 = [55 x i8] c"The word/sentance inputted, %s, is not a palindrome!\0A\0A\00"
define void @checkPalindrome() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @_flushall()
%9 = call i32 @gets(i8* %4)
%10 = call i32 @strcpy(i8* %6, i8* %4)
br label %11
11: ; preds = %11, %0
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = add nuw i64 %12, 1
br i1 %15, label %17, label %11
17: ; preds = %11
%18 = trunc i64 %12 to i32
%19 = call i32 @remove_punc(i32 %18, i8* %4, i8* %5)
br label %20
20: ; preds = %20, %17
%21 = phi i64 [ %25, %20 ], [ 0, %17 ]
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
%25 = add nuw i64 %21, 1
br i1 %24, label %26, label %20
26: ; preds = %20
%27 = trunc i64 %21 to i32
%28 = add nsw i32 %27, -1
%29 = call i32 @determine_palindrome(i32 0, i32 %28, i8* %5)
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %31, i8* %6)
%33 = call i32 @pause_clear(i32 1, i32 1)
ret void
}