#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 */
scalar_t__ checkPalindrome(char *);
int /*<<< orphan*/ free(char *);
char *getUserInput(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
char *strtok(char *, char *);
int main() {
  char *str = NULL;
  printf("Please input your words/sentences to be checked for palindromes.\n"
         "Separate each entity with a comma.\n\n");
  str = getUserInput(str);
  char *part;
  part = strtok(str, ",");
  printf("\n\nPalindromes:\n-------------------\n");
  while (part != NULL) {
    printf(part);
    if (checkPalindrome(str))
      printf("\tpalindrome\n\n");
    else
      printf("\tnot a palindrome\n\n");
    part = strtok(NULL, ",");
  }
  printf("\n\n-------------------\n");
  free(str);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getUserInput@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xecb(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    0xebd(%rip),%rdi
call   1050 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     120d <main+0xad>
mov    -0x18(%rbp),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <checkPalindrome@plt>
cmp    $0x0,%rax
je     11e8 <main+0x88>
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
jmp    11f4 <main+0x94>
lea    0xeab(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe67(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    11b0 <main+0x50>
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xe82(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1080 <getUserInput@plt>
mov    %rax,%r15
lea    0xe6a(%rip),%rsi
mov    %rax,%rdi
call   1090 <strtok@plt>
mov    %rax,%rbx
lea    0xebf(%rip),%rdi
call   1050 <puts@plt>
test   %rbx,%rbx
je     1201 <main+0x91>
lea    0xee7(%rip),%r12
lea    0xef3(%rip),%r13
lea    0xe39(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <checkPalindrome@plt>
test   %rax,%rax
mov    %r13,%rdi
cmove  %r12,%rdi
call   1050 <puts@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1090 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11d0 <main+0x60>
lea    0xe82(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [102 x i8] c"Please input your words/sentences to be checked for palindromes.\0ASeparate each entity with a comma.\0A\0A\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [36 x i8] c"\0A\0APalindromes:\0A-------------------\0A\00"
@.str.3 = [14 x i8] c"\09palindrome\0A\0A\00"
@.str.4 = [20 x i8] c"\09not a palindrome\0A\0A\00"
@.str.5 = [23 x i8] c"\0A\0A-------------------\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %2
%6 = call i8* @getUserInput(i8* %5)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %3
%9 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %23, %0
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* %14)
%16 = load i8*, i8** %2
%17 = call i64 @checkPalindrome(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %23
21: ; preds = %13
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %24, i8** %3
br label %10
25: ; preds = %10
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%27 = load i8*, i8** %2
%28 = call i32 @free(i8* %27)
%29 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c",\00"
@str = [101 x i8] c"Please input your words/sentences to be checked for palindromes.\0ASeparate each entity with a comma.\0A\00"
@str.6 = [35 x i8] c"\0A\0APalindromes:\0A-------------------\00"
@str.7 = [22 x i8] c"\0A\0A-------------------\00"
@str.8 = [19 x i8] c"\09not a palindrome\0A\00"
@str.9 = [13 x i8] c"\09palindrome\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([101 x i8], [101 x i8]* @str, i64 0, i64 0))
%2 = tail call i8* @getUserInput(i8* null)
%3 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.6, i64 0, i64 0))
%5 = icmp eq i8* %3, null
br i1 %5, label %15, label %6
6: ; preds = %0, %6
%7 = phi i8* [ %13, %6 ], [ %3, %0 ]
%8 = tail call i32 @printf(i8* %7)
%9 = tail call i64 @checkPalindrome(i8* %2)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %6
15: ; preds = %6, %0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%17 = tail call i32 @free(i8* %2)
%18 = tail call i32 (...) @getchar()
ret i32 0
}