#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 str[80];
  int length;
  int i;
  int flag = 0;
  printf("Enter string\n");
  scanf("%s", str);
  length = strlen(str);
  for (i = 0; i < length; i++) {
    if (str[i] != str[length - i - 1]) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    printf("given word is not a palidrome");
  } else
    printf("given word is a palidrome");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    11c2 <main+0x92>
movslq -0x68(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
mov    -0x64(%rbp),%ecx
sub    -0x68(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x60(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11af <main+0x7f>
movl   $0x1,-0x6c(%rbp)
jmp    11c2 <main+0x92>
jmp    11b4 <main+0x84>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1175 <main+0x45>
cmpl   $0x0,-0x6c(%rbp)
je     11dd <main+0xad>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <main+0xb9>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xeaf(%rip),%rdi
test   %eax,%eax
jle    11ad <main+0x6d>
mov    %eax,%ecx
add    $0xffffffff,%eax
xor    %edx,%edx
lea    0xe7f(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rsp,%rdx,1),%ebx
movslq %eax,%rsi
cmp    (%rsp,%rsi,1),%bl
jne    11aa <main+0x6a>
add    $0x1,%rdx
add    $0xffffffff,%eax
cmp    %rdx,%rcx
jne    1190 <main+0x50>
jmp    11ad <main+0x6d>
mov    %r8,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter string\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [30 x i8] c"given word is not a palidrome\00"
@.str.3 = [26 x i8] c"given word is a palidrome\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [80 x i8], [80 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 [80 x i8], [80 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %3
store i32 0, i32* %4
br label %11
11: ; preds = %32, %0
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %20, %28
br i1 %29, label %30, label %31
30: ; preds = %15
store i32 1, i32* %5
br label %35
31: ; preds = %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %11
35: ; preds = %30, %11
%36 = load i32, i32* %5
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %42
40: ; preds = %35
%41 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [30 x i8] c"given word is not a palidrome\00"
@.str.3 = [26 x i8] c"given word is a palidrome\00"
@str = [13 x i8] c"Enter string\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 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 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %0
%8 = zext i32 %5 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %22, %8
br i1 %10, label %23, label %11
11: ; preds = %7, %9
%12 = phi i64 [ 0, %7 ], [ %22, %9 ]
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = trunc i64 %12 to i32
%16 = xor i32 %15, -1
%17 = add i32 %5, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %14, %20
%22 = add nuw nsw i64 %12, 1
br i1 %21, label %9, label %23
23: ; preds = %9, %11, %0
%24 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), %9 ]
%25 = call i32 @printf(i8* dereferenceable(1) %24)
ret i32 0
}