#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 EXIT_SUCCESS;
char *calloc(int, int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdout;
size_t strlen(char *);
int main(int argc, char *argv[]) {
  char *first, *last;
  size_t len;
  char *str = calloc(20, sizeof(char));
  fputs("entry string: ", stdout);
  scanf("%19s", str);
  len = strlen(str);
  first = str;
  last = &str[len - 1];
  while (first < last) {
    if (*first != *last)
      break;
    first++;
    last--;
  }
  if (first >= last)
    fputs("The string is Palindrome", stdout);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x14,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
lea    0xe87(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x30(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11fc <main+0xbc>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x20(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11df <main+0x9f>
jmp    11fc <main+0xbc>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11b6 <main+0x76>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     121f <main+0xdf>
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
lea    0xdfa(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x14,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    0x2e83(%rip),%r14
mov    (%r14),%esi
lea    0xe99(%rip),%rdi
call   1040 <fputs@plt>
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    -0x1(%rax),%rcx
test   %rcx,%rcx
jle    11b8 <main+0x78>
add    %rbx,%rax
add    $0xfffffffffffffffe,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%ecx
cmp    0x1(%rax),%cl
jne    11c7 <main+0x87>
add    $0x1,%rbx
lea    -0x1(%rax),%rcx
cmp    %rax,%rbx
mov    %rcx,%rax
jb     11a0 <main+0x60>
mov    (%r14),%esi
lea    0xe52(%rip),%rdi
call   1040 <fputs@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"entry string: \00"
@stdout = global i32 0
@.str.1 = [5 x i8] c"%19s\00"
@.str.2 = [25 x i8] c"The string is Palindrome\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i8* @calloc(i32 20, i32 1)
store i8* %10, i8** %9
%11 = load i32, i32* @stdout
%12 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i8*, i8** %9
%14 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %9
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %8
%17 = load i8*, i8** %9
store i8* %17, i8** %6
%18 = load i8*, i8** %9
%19 = load i64, i64* %8
%20 = sub i64 %19, 1
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8* %21, i8** %7
br label %22
22: ; preds = %35, %2
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = icmp ult i8* %23, %24
br i1 %25, label %26, label %40
26: ; preds = %22
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %29, %32
br i1 %33, label %34, label %35
34: ; preds = %26
br label %40
35: ; preds = %26
%36 = load i8*, i8** %6
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %6
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i32 -1
store i8* %39, i8** %7
br label %22
40: ; preds = %34, %22
%41 = load i8*, i8** %6
%42 = load i8*, i8** %7
%43 = icmp uge i8* %41, %42
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* @stdout
%46 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %40
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}

LLVM IR (-O2):
@.str = [15 x i8] c"entry string: \00"
@stdout = global i32 0
@.str.1 = [5 x i8] c"%19s\00"
@.str.2 = [25 x i8] c"The string is Palindrome\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(20) i8* @calloc(i32 20, i32 1)
%4 = load i32, i32* @stdout
%5 = tail call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%8 = add i64 %7, -1
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %2
%11 = getelementptr inbounds i8, i8* %3, i64 %8
br label %12
12: ; preds = %10, %18
%13 = phi i8* [ %19, %18 ], [ %3, %10 ]
%14 = phi i8* [ %20, %18 ], [ %11, %10 ]
%15 = load i8, i8* %13
%16 = load i8, i8* %14
%17 = icmp eq i8 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %13, i64 1
%20 = getelementptr inbounds i8, i8* %14, i64 -1
%21 = icmp ult i8* %19, %20
br i1 %21, label %12, label %22
22: ; preds = %18, %2
%23 = load i32, i32* @stdout
%24 = tail call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %12, %22
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}