#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char word[500];
  int length = 0;
  int i;
  int error = 0;
  printf("Enter a word:");
  scanf("%[^\n]s", word);
  while (word[length] != '\0')
    length++;
  for (i = 0; i < length; i++) {
    if (word[i] != word[length - 1 - i]) {
      error = 1;
      break;
    }
  }
  if (error == 1)
    printf("%s is not a palindrome", word);
  else
    printf("%s is a palindrome", word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x204(%rbp)
movl   $0x0,-0x20c(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x200(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x204(%rbp),%rax
movsbl -0x200(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1193 <main+0x73>
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    1167 <main+0x47>
movl   $0x0,-0x208(%rbp)
mov    -0x208(%rbp),%eax
cmp    -0x204(%rbp),%eax
jge    1208 <main+0xe8>
movslq -0x208(%rbp),%rax
movsbl -0x200(%rbp,%rax,1),%eax
ff
mov    -0x204(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x208(%rbp),%ecx
movslq %ecx,%rcx
movsbl -0x200(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
je     11ef <main+0xcf>
movl   $0x1,-0x20c(%rbp)
jmp    1208 <main+0xe8>
jmp    11f4 <main+0xd4>
mov    -0x208(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208(%rbp)
jmp    119d <main+0x7d>
cmpl   $0x1,-0x20c(%rbp)
jne    122f <main+0x10f>
lea    -0x200(%rbp),%rsi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x124>
lea    -0x200(%rbp),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x200,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
movabs $0xfffffffe00000000,%rsi
ff ff ff
mov    $0xffffffff,%ecx
movabs $0x100000000,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %rdx,%rsi
add    $0x1,%ecx
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <main+0x50>
lea    0xea6(%rip),%rdi
test   %ecx,%ecx
je     11c1 <main+0xa1>
mov    %ecx,%ecx
xor    %edx,%edx
lea    0xe80(%rip),%r8
movabs $0xffffffff00000000,%r9
ff ff ff
nop
movzbl (%rsp,%rdx,1),%ebx
mov    %rsi,%rax
sar    $0x20,%rax
cmp    (%rsp,%rax,1),%bl
jne    11be <main+0x9e>
add    $0x1,%rdx
add    %r9,%rsi
cmp    %rdx,%rcx
jne    11a0 <main+0x80>
jmp    11c1 <main+0xa1>
mov    %r8,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter a word:\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [23 x i8] c"%s is not a palindrome\00"
@.str.3 = [19 x i8] c"%s is a palindrome\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %16, %0
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %9
19: ; preds = %9
store i32 0, i32* %4
br label %20
20: ; preds = %41, %19
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %44
24: ; preds = %20
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 1
%32 = load i32, i32* %4
%33 = sub nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %29, %37
br i1 %38, label %39, label %40
39: ; preds = %24
store i32 1, i32* %5
br label %44
40: ; preds = %24
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %20
44: ; preds = %39, %20
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %48)
br label %53
50: ; preds = %44
%51 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %50, %47
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter a word:\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [23 x i8] c"%s is not a palindrome\00"
@.str.3 = [19 x i8] c"%s is a palindrome\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ %10, %5 ], [ 0, %0 ]
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = add nuw i64 %6, 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %11
%15 = and i64 %6, 4294967295
br label %18
16: ; preds = %18
%17 = icmp eq i64 %29, %15
br i1 %17, label %30, label %18
18: ; preds = %14, %16
%19 = phi i64 [ 0, %14 ], [ %29, %16 ]
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = xor i64 %19, -1
%23 = add i64 %6, %22
%24 = shl i64 %23, 32
%25 = ashr exact i64 %24, 32
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %21, %27
%29 = add nuw nsw i64 %19, 1
br i1 %28, label %16, label %30
30: ; preds = %16, %18, %11
%31 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %18 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %16 ]
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %31, i8* %2)
ret i32 0
}