#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int strcmp(char *, char *);
int main() {
  char ar[10];
  char ar1[10];
  int i, j, v;
  printf("enter a string");
  gets(ar);
  for (i = 0; ar[i] != '\0'; i++) {
    ar1[j] = ar[i];
  }
  ar1[j] = '\0';
  v = strcmp(ar, ar1);
  if (v == 0)
    printf("palindrome");
  else
    printf("not palindrome");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     118b <main+0x5b>
movslq -0x1c(%rbp),%rax
mov    -0xe(%rbp,%rax,1),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x18(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <main+0x2b>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x18(%rbp,%rax,1)
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11bf <main+0x8f>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
jmp    11cb <main+0x9b>
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
lea    0x16(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
movb   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
lea    0xeaa(%rip),%rax
lea    0xe9f(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"enter a string\00"
@.str.1 = [11 x i8] c"palindrome\00"
@.str.2 = [15 x i8] c"not palindrome\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
store i32 0, i32* %4
br label %10
10: ; preds = %25, %0
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %10
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %23
store i8 %21, i8* %24
br label %25
25: ; preds = %17
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %30
store i8 0, i8* %31
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%34 = call i32 @strcmp(i8* %32, i8* %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %41
39: ; preds = %28
%40 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"enter a string\00"
@.str.1 = [11 x i8] c"palindrome\00"
@.str.2 = [15 x i8] c"not palindrome\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
store i8 0, i8* %4
%7 = call i32 @strcmp(i8* %3, i8* %4)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0)
%10 = call i32 @printf(i8* dereferenceable(1) %9)
ret i32 0
}