#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 strlen(char *);
int main() {
  char string[100];
  printf("Please enter the string to be checked as palindrome :\n");
  scanf("%s", string);
  int similar = strlen(string) / 2;
  int j = 0;
  for (int i = 0; i < similar; i++) {
    if (string[i] == string[strlen(string) - (i + 1)])
      j++;
    else
      ;
  }
  if (j == similar)
    printf("%s is a pailndrome string.\n", string);
  else
    printf("%s is NOT a palindrome string.\n", string);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xedc(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    11e6 <main+0xb6>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
mov    %eax,-0x80(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
mov    -0x7c(%rbp),%edx
add    $0x1,%edx
sub    %edx,%ecx
movslq %ecx,%rcx
movsbl -0x70(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11ce <main+0x9e>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11d3 <main+0xa3>
jmp    11d3 <main+0xa3>
jmp    11d8 <main+0xa8>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1182 <main+0x52>
mov    -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
jne    1209 <main+0xd9>
lea    -0x70(%rbp),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121b <main+0xeb>
lea    -0x70(%rbp),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
mov    %ecx,0xc(%rsp)
xor    %r13d,%r13d
cmp    $0x2,%eax
jl     11cb <main+0x8b>
mov    0xc(%rsp),%r12d
xor    %ebp,%ebp
mov    $0xffffffff,%ebx
lea    0x10(%rsp),%r15
xor    %r13d,%r13d
nop
movzbl 0x10(%rsp,%rbp,1),%r14d
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0x1,%rbp
add    %ebx,%eax
cltq
xor    %ecx,%ecx
cmp    0x10(%rsp,%rax,1),%r14b
sete   %cl
add    %ecx,%r13d
add    $0xffffffff,%ebx
cmp    %rbp,%r12
jne    11a0 <main+0x60>
cmp    0xc(%rsp),%r13d
lea    0xe2c(%rip),%rax
lea    0xe41(%rip),%rdi
cmove  %rax,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [28 x i8] c"%s is a pailndrome string.\0A\00"
@.str.3 = [32 x i8] c"%s is NOT a palindrome string.\0A\00"
@str = [54 x i8] c"Please enter the string to be checked as 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = sdiv i32 %5, 2
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %15
10: ; preds = %15, %0
%11 = phi i32 [ 0, %0 ], [ %29, %15 ]
%12 = icmp eq i32 %11, %6
%13 = select i1 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13, i8* %2)
ret i32 0
15: ; preds = %8, %15
%16 = phi i64 [ 0, %8 ], [ %21, %15 ]
%17 = phi i32 [ 0, %8 ], [ %29, %15 ]
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %16
%19 = load i8, i8* %18
%20 = call i32 @strlen(i8* %2)
%21 = add nuw nsw i64 %16, 1
%22 = trunc i64 %21 to i32
%23 = sub nsw i32 %20, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %19, %26
%28 = zext i1 %27 to i32
%29 = add nuw nsw i32 %17, %28
%30 = icmp eq i64 %21, %9
br i1 %30, label %10, label %15
}