#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*/ free(char *);
scalar_t__ palindrome(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char **);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  printf("Enter word: ");
  char *word;
  scanf(" %m[^\n]", &word);
  if (palindrome(word, strlen(word))) {
    printf("`%s' is a palindrome\n", word);
  } else {
    printf("`%s' is not a palindrome\n", word);
  }
  free(word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1060 <palindrome@plt>
cmp    $0x0,%rax
je     11ba <main+0x6a>
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11cc <main+0x7c>
mov    -0x10(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <palindrome@plt>
test   %rax,%rax
mov    0x8(%rsp),%rsi
lea    0xe91(%rip),%rax
lea    0xe74(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Enter word: \00"
@.str.1 = [8 x i8] c" %m[^\0A]\00"
@.str.2 = [22 x i8] c"`%s' is a palindrome\0A\00"
@.str.3 = [26 x i8] c"`%s' is not a palindrome\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2)
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = call i64 @palindrome(i8* %5, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i8*, i8** %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %16
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %10
%17 = load i8*, i8** %2
%18 = call i32 @free(i8* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Enter word: \00"
@.str.1 = [8 x i8] c" %m[^\0A]\00"
@.str.2 = [22 x i8] c"`%s' is a palindrome\0A\00"
@.str.3 = [26 x i8] c"`%s' is not a palindrome\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i8** %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%5 = load i8*, i8** %1
%6 = call i32 @strlen(i8* %5)
%7 = call i64 @palindrome(i8* %5, i32 %6)
%8 = icmp eq i64 %7, 0
%9 = load i8*, i8** %1
%10 = select i1 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10, i8* %9)
%12 = load i8*, i8** %1
%13 = call i32 @free(i8* %12)
ret i32 0
}