#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();
int /*<<< orphan*/ printf(char *);
int main(void) {
  char msg[100], *p, *beginn_ptr, *end_ptr;
  printf("Enter a message: ");
  for (p = msg; p < &msg[100]; p++) {
    *p = getchar();
    if (*p == '\n')
      break;
  }
  beginn_ptr = msg;
  end_ptr = p - 1;
  while (*beginn_ptr == *end_ptr) {
    beginn_ptr++;
    end_ptr--;
  }
  if (end_ptr + 1 == msg)
    printf("Palindrome\n");
  else
    printf("Not a palindrome\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
lea    -0x70(%rbp),%rcx
add    $0x64,%rcx
cmp    %rcx,%rax
jae    1195 <main+0x75>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,%cl
mov    -0x78(%rbp),%rax
mov    %cl,(%rax)
mov    -0x78(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    117f <main+0x5f>
jmp    1195 <main+0x75>
jmp    1184 <main+0x64>
mov    -0x78(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x78(%rbp)
jmp    1146 <main+0x26>
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x88(%rbp)
mov    -0x80(%rbp),%rax
movsbl (%rax),%eax
mov    -0x88(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11e8 <main+0xc8>
mov    -0x80(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
mov    -0x88(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x88(%rbp)
jmp    11ac <main+0x8c>
mov    -0x88(%rbp),%rax
add    $0x1,%rax
lea    -0x70(%rbp),%rcx
cmp    %rcx,%rax
jne    1211 <main+0xf1>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
jmp    121d <main+0xfd>
lea    0xe06(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsp,%rbx
lea    0xebf(%rip),%rdi
call   1040 <printf@plt>
lea    0x64(%rsp),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%rbx)
cmp    $0xa,%al
je     1166 <main+0x36>
add    $0x1,%rbx
cmp    %r14,%rbx
jb     1150 <main+0x20>
mov    %rsp,%rax
add    $0x1,%rbx
nopl   (%rax)
mov    %rbx,%rcx
movzbl (%rax),%edx
add    $0x1,%rax
add    $0xffffffffffffffff,%rbx
cmp    -0x2(%rcx),%dl
je     1170 <main+0x40>
mov    %rsp,%rax
cmp    %rax,%rbx
lea    0xe93(%rip),%rax
lea    0xe7b(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a message: \00"
@str = [17 x i8] c"Not a palindrome\00"
@str.3 = [11 x i8] c"Palindrome\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 100
br label %5
5: ; preds = %0, %9
%6 = phi i8* [ %2, %0 ], [ %10, %9 ]
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %6
%8 = icmp eq i8 %7, 10
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = icmp ult i8* %10, %4
br i1 %11, label %5, label %12
12: ; preds = %5, %9
%13 = phi i8* [ %10, %9 ], [ %6, %5 ]
br label %14
14: ; preds = %12, %14
%15 = phi i8* [ %21, %14 ], [ %2, %12 ]
%16 = phi i8* [ %17, %14 ], [ %13, %12 ]
%17 = getelementptr inbounds i8, i8* %16, i64 -1
%18 = load i8, i8* %15
%19 = load i8, i8* %17
%20 = icmp eq i8 %18, %19
%21 = getelementptr inbounds i8, i8* %15, i64 1
br i1 %20, label %14, label %22
22: ; preds = %14
%23 = icmp eq i8* %16, %2
%24 = select i1 %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0)
%25 = call i32 @puts(i8* dereferenceable(1) %24)
ret i32 0
}