#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 pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(char);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
void main() {
  system("clear");
  char str[100];
  int i, count = 0, len;
  printf("Enter string to check it is palindrome or not : ");
  scanf("%s", str);
  len = strlen(str);
  for (i = 0; i < len; i++) {
    push(str[i]);
  }
  for (i = 0; i < len; i++) {
    if (str[i] == pop())
      count++;
  }
  if (count == len)
    printf("\"%s\" is a Palindrome string\n", str);
  else
    printf("\"%s\" is not a palindrome string\n", str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xe8e(%rip),%rdi
call   1040 <system@plt>
movl   $0x0,-0x78(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x7c(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    11d7 <main+0x77>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1080 <push@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11af <main+0x4f>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jge    1229 <main+0xc9>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
mov    %eax,-0x80(%rbp)
mov    $0x0,%al
call   1060 <pop@plt>
mov    %al,%cl
mov    -0x80(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
jne    1216 <main+0xb6>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    121b <main+0xbb>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11de <main+0x7e>
mov    -0x78(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jne    124c <main+0xec>
lea    -0x70(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    125e <main+0xfe>
lea    -0x70(%rbp),%rsi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
lea    0xe8d(%rip),%rdi
call   1040 <system@plt>
lea    0xe87(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    11f3 <main+0x93>
mov    %r14d,%r15d
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl (%rsp,%rbx,1),%edi
call   1080 <push@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11b0 <main+0x50>
test   %r14d,%r14d
jle    11f1 <main+0x91>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%r12d
xor    %eax,%eax
call   1060 <pop@plt>
xor    %ecx,%ecx
cmp    %al,%r12b
sete   %cl
add    %ecx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11d0 <main+0x70>
jmp    11f3 <main+0x93>
xor    %ebp,%ebp
cmp    %r14d,%ebp
lea    0xe3d(%rip),%rax
lea    0xe53(%rip),%rdi
cmove  %rax,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.1 = [49 x i8] c"Enter string to check it is palindrome or not : \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [29 x i8] c"\22%s\22 is a Palindrome string\0A\00"
@.str.4 = [33 x i8] c"\22%s\22 is not a palindrome string\0A\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%6 = call i32 @strlen(i8* %3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %31
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %13
10: ; preds = %13
br i1 %7, label %11, label %31
11: ; preds = %10
%12 = zext i32 %6 to i64
br label %20
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %18, %13 ]
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = call i32 @push(i8 signext %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %10, label %13
20: ; preds = %11, %20
%21 = phi i64 [ 0, %11 ], [ %29, %20 ]
%22 = phi i32 [ 0, %11 ], [ %28, %20 ]
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %21
%24 = load i8, i8* %23
%25 = call signext i8 (...) @pop()
%26 = icmp eq i8 %24, %25
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %22, %27
%29 = add nuw nsw i64 %21, 1
%30 = icmp eq i64 %29, %12
br i1 %30, label %31, label %20
31: ; preds = %20, %0, %10
%32 = phi i32 [ 0, %10 ], [ 0, %0 ], [ %28, %20 ]
%33 = icmp eq i32 %32, %6
%34 = select i1 %33, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34, i8* %3)
ret void
}