#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 /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char w[150], w_rev[150], temp;
  int i = 0, k = 0, len = 0, status = 0;
  printf("Enter text:\n");
  gets(w);
  strcpy(w_rev, w);
  len = strlen(w) - 1;
  while (i < len) {
    temp = w_rev[i];
    w_rev[i] = w_rev[len];
    w_rev[len] = temp;
    i++;
    len--;
  }
  printf("\n");
  len = strlen(w) - 1;
  while (k <= len) {
    if (w[k] == w_rev[k]) {
      status = 1;
    } else {
      status = 0;
    }
    k++;
  }
  printf("%d\n", status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x148(%rbp)
movl   $0x0,-0x14c(%rbp)
movl   $0x0,-0x150(%rbp)
movl   $0x0,-0x154(%rbp)
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x140(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x150(%rbp)
mov    -0x148(%rbp),%eax
cmp    -0x150(%rbp),%eax
jge    1235 <main+0xf5>
movslq -0x148(%rbp),%rax
mov    -0x140(%rbp,%rax,1),%al
mov    %al,-0x141(%rbp)
movslq -0x150(%rbp),%rax
mov    -0x140(%rbp,%rax,1),%cl
movslq -0x148(%rbp),%rax
mov    %cl,-0x140(%rbp,%rax,1)
mov    -0x141(%rbp),%cl
movslq -0x150(%rbp),%rax
mov    %cl,-0x140(%rbp,%rax,1)
mov    -0x148(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x148(%rbp)
mov    -0x150(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x150(%rbp)
jmp    11bc <main+0x7c>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x150(%rbp)
mov    -0x14c(%rbp),%eax
cmp    -0x150(%rbp),%eax
jg     12bd <main+0x17d>
movslq -0x14c(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
movslq -0x14c(%rbp),%rcx
movsbl -0x140(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    129f <main+0x15f>
movl   $0x1,-0x154(%rbp)
jmp    12a9 <main+0x169>
movl   $0x0,-0x154(%rbp)
mov    -0x14c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14c(%rbp)
jmp    1258 <main+0x118>
mov    -0x154(%rbp),%esi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x140,%rsp
lea    0xe95(%rip),%rdi
call   1050 <puts@plt>
lea    0xa0(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <gets@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x2,%eax
jl     11d0 <main+0x70>
mov    %eax,%eax
add    $0xfffffffffffffffe,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rsp,%rcx,1),%edx
movzbl 0x1(%rsp,%rax,1),%ebx
mov    %bl,(%rsp,%rcx,1)
mov    %dl,0x1(%rsp,%rax,1)
add    $0x1,%rcx
lea    -0x1(%rax),%rdx
cmp    %rax,%rcx
mov    %rdx,%rax
jl     11b0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xa0(%rsp),%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1200 <main+0xa0>
add    $0xffffffff,%eax
mov    0xa0(%rsp,%rax,1),%cl
xor    %esi,%esi
cmp    (%rsp,%rax,1),%cl
sete   %sil
jmp    1202 <main+0xa2>
xor    %esi,%esi
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Enter text:\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [150 x i8]
%3 = alloca [150 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %7
br label %18
18: ; preds = %22, %0
%19 = load i32, i32* %5
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
store i8 %26, i8* %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 %32
store i8 %30, i8* %33
%34 = load i8, i8* %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 %36
store i8 %34, i8* %37
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = load i32, i32* %7
%41 = add nsw i32 %40, -1
store i32 %41, i32* %7
br label %18
42: ; preds = %18
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = sub nsw i32 %45, 1
store i32 %46, i32* %7
br label %47
47: ; preds = %65, %42
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = icmp sle i32 %48, %49
br i1 %50, label %51, label %68
51: ; preds = %47
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %56, %61
br i1 %62, label %63, label %64
63: ; preds = %51
store i32 1, i32* %8
br label %65
64: ; preds = %51
store i32 0, i32* %8
br label %65
65: ; preds = %64, %63
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %47
68: ; preds = %47
%69 = load i32, i32* %8
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %69)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [12 x i8] c"Enter text:\00"
define i32 @main() {
%1 = alloca [150 x i8]
%2 = alloca [150 x i8]
%3 = getelementptr inbounds [150 x i8], [150 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
%7 = call i32 @strcpy(i8* %4, i8* %3)
%8 = call i32 @strlen(i8* %3)
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %23
10: ; preds = %0
%11 = zext i32 %8 to i64
%12 = add nsw i64 %11, -1
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %20, %13 ]
%15 = phi i64 [ %12, %10 ], [ %21, %13 ]
%16 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 %14
%17 = load i8, i8* %16
%18 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 %15
%19 = load i8, i8* %18
store i8 %19, i8* %16
store i8 %17, i8* %18
%20 = add nuw nsw i64 %14, 1
%21 = add nsw i64 %15, -1
%22 = icmp slt i64 %20, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %0
%24 = call i32 @putchar(i32 10)
%25 = call i32 @strlen(i8* %3)
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = add nsw i32 %25, -1
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [150 x i8], [150 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 %29
%33 = load i8, i8* %32
%34 = icmp eq i8 %31, %33
%35 = zext i1 %34 to i32
br label %36
36: ; preds = %27, %23
%37 = phi i32 [ %35, %27 ], [ 0, %23 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %37)
ret i32 0
}