#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 word[20];
  int i = 0;
  int length = 0;
  int flag = 0;
  printf("enter word=");
  scanf("%s", word);
  length = strlen(word);
  for (i = 0; i < length; i++) {
    if (word[i] == word[length - 1]) {
      flag = 1;
    } else {
      printf("0");
      break;
    }
    length--;
  }
  if (flag == 1) {
    printf("%d", flag);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11e6 <main+0xb6>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11bc <main+0x8c>
movl   $0x1,-0x2c(%rbp)
jmp    11cf <main+0x9f>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e6 <main+0xb6>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1185 <main+0x55>
cmpl   $0x1,-0x2c(%rbp)
jne    1201 <main+0xd1>
mov    -0x2c(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11d8 <main+0x98>
mov    %eax,%eax
mov    (%rsp),%bpl
mov    -0x1(%rsp,%rax,1),%bl
cmp    %bl,%bpl
jne    11ce <main+0x8e>
add    $0xffffffffffffffff,%rax
mov    $0x1,%ecx
nopw   0x0(%rax,%rax,1)
cmp    %rax,%rcx
jge    11b9 <main+0x79>
movzbl (%rsp,%rcx,1),%edx
lea    -0x1(%rax),%rsi
add    $0x1,%rcx
cmp    -0x1(%rsp,%rax,1),%dl
mov    %rsi,%rax
je     1190 <main+0x50>
mov    $0x30,%edi
call   1030 <putchar@plt>
cmp    %bl,%bpl
jne    11d8 <main+0x98>
lea    0xe4f(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11d8 <main+0x98>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"enter word=\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 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 %33
7: ; preds = %0
%8 = zext i32 %5 to i64
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%10 = load i8, i8* %9
%11 = add nsw i64 %8, -1
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %10, %13
br i1 %14, label %15, label %31
15: ; preds = %7, %19
%16 = phi i64 [ %26, %19 ], [ 1, %7 ]
%17 = phi i64 [ %22, %19 ], [ %11, %7 ]
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %16
%21 = load i8, i8* %20
%22 = add nsw i64 %17, -1
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %21, %24
%26 = add nuw nsw i64 %16, 1
br i1 %25, label %15, label %27
27: ; preds = %19
%28 = call i32 @putchar(i32 48)
br i1 %14, label %29, label %33
29: ; preds = %15, %27
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %33
31: ; preds = %7
%32 = call i32 @putchar(i32 48)
br label %33
33: ; preds = %31, %0, %29, %27
ret i32 0
}