#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 *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char str[100], tmp, cpy[100];
  printf("Enter a string: ");
  gets(str);
  strcpy(cpy, str);
  int len = strlen(str);
  for (size_t i = 0, j = len - 1; i < len / 2; i++, j--) {
    tmp = str[i];
    str[i] = str[j];
    str[j] = tmp;
  }
  if (strcmp(str, cpy) == 0) {
    printf("Palindrome!");
  } else
    printf("Not Palindrome!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1070 <gets@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xe4(%rbp)
movq   $0x0,-0xf0(%rbp)
mov    -0xe4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %rax,-0xf8(%rbp)
mov    -0xf0(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0xe4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x100(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
jae    123f <main+0xef>
mov    -0xf0(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x71(%rbp)
mov    -0xf8(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
mov    -0xf0(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x71(%rbp),%cl
mov    -0xf8(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0xf0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0xf8(%rbp)
jmp    11b3 <main+0x63>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    126a <main+0x11a>
lea    0xdb5(%rip),%rdi
call   1050 <printf@plt>
jmp    1276 <main+0x126>
lea    0xda0(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xe0,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
jb     11ff <main+0xaf>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
add    $0xffffffff,%eax
cltq
mov    $0x1,%edx
cmp    $0x2,%ecx
cmovae %ecx,%edx
movslq %edx,%rdi
jae    11ae <main+0x5e>
xor    %edx,%edx
jmp    11ed <main+0x9d>
mov    %rdi,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movzbl (%rsp,%rdx,1),%ebx
movzbl (%rsp,%rax,1),%ecx
mov    %cl,(%rsp,%rdx,1)
mov    %bl,(%rsp,%rax,1)
movzbl 0x1(%rsp,%rdx,1),%ecx
movzbl -0x1(%rsp,%rax,1),%ebx
mov    %bl,0x1(%rsp,%rdx,1)
mov    %cl,-0x1(%rsp,%rax,1)
add    $0x2,%rdx
add    $0xfffffffffffffffe,%rax
cmp    %rdx,%rsi
jne    11c0 <main+0x70>
test   $0x1,%dil
je     11ff <main+0xaf>
mov    (%rsp,%rdx,1),%cl
mov    (%rsp,%rax,1),%bl
mov    %bl,(%rsp,%rdx,1)
mov    %cl,(%rsp,%rax,1)
mov    %rsp,%rdi
lea    0x70(%rsp),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
lea    0xdff(%rip),%rax
lea    0xdf4(%rip),%rdi
cmove  %rax,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a string: \00"
@.str.1 = [12 x i8] c"Palindrome!\00"
@.str.2 = [16 x i8] c"Not Palindrome!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = call i32 @gets(i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %5
store i64 0, i64* %6
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
store i64 %18, i64* %7
br label %19
19: ; preds = %37, %0
%20 = load i64, i64* %6
%21 = load i32, i32* %5
%22 = sdiv i32 %21, 2
%23 = sext i32 %22 to i64
%24 = icmp ult i64 %20, %23
br i1 %24, label %25, label %42
25: ; preds = %19
%26 = load i64, i64* %6
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
store i8 %28, i8* %3
%29 = load i64, i64* %7
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i64, i64* %6
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
store i8 %31, i8* %33
%34 = load i8, i8* %3
%35 = load i64, i64* %7
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %35
store i8 %34, i8* %36
br label %37
37: ; preds = %25
%38 = load i64, i64* %6
%39 = add i64 %38, 1
store i64 %39, i64* %6
%40 = load i64, i64* %7
%41 = add i64 %40, -1
store i64 %41, i64* %7
br label %19
42: ; preds = %19
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%45 = call i64 @strcmp(i8* %43, i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %51
49: ; preds = %42
%50 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a string: \00"
@.str.1 = [12 x i8] c"Palindrome!\00"
@.str.2 = [16 x i8] c"Not Palindrome!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 = add i32 %8, 1
%10 = icmp ult i32 %9, 3
br i1 %10, label %30, label %11
11: ; preds = %0
%12 = sdiv i32 %8, 2
%13 = add nsw i32 %8, -1
%14 = sext i32 %13 to i64
%15 = call i32 @llvm.umax.i32(i32 %12, i32 1)
%16 = sext i32 %15 to i64
%17 = and i64 %16, 1
%18 = icmp ult i32 %12, 2
br i1 %18, label %21, label %19
19: ; preds = %11
%20 = and i64 %16, -2
br label %35
21: ; preds = %35, %11
%22 = phi i64 [ %14, %11 ], [ %50, %35 ]
%23 = phi i64 [ 0, %11 ], [ %49, %35 ]
%24 = icmp eq i64 %17, 0
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %23
%27 = load i8, i8* %26
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %22
%29 = load i8, i8* %28
store i8 %29, i8* %26
store i8 %27, i8* %28
br label %30
30: ; preds = %25, %21, %0
%31 = call i64 @strcmp(i8* %3, i8* %4)
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0)
%34 = call i32 @printf(i8* dereferenceable(1) %33)
ret i32 0
35: ; preds = %35, %19
%36 = phi i64 [ %14, %19 ], [ %50, %35 ]
%37 = phi i64 [ 0, %19 ], [ %49, %35 ]
%38 = phi i64 [ 0, %19 ], [ %51, %35 ]
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %37
%40 = load i8, i8* %39
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %36
%42 = load i8, i8* %41
store i8 %42, i8* %39
store i8 %40, i8* %41
%43 = or i64 %37, 1
%44 = add i64 %36, -1
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %43
%46 = load i8, i8* %45
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %44
%48 = load i8, i8* %47
store i8 %48, i8* %45
store i8 %46, i8* %47
%49 = add nuw i64 %37, 2
%50 = add i64 %36, -2
%51 = add i64 %38, 2
%52 = icmp eq i64 %51, %20
br i1 %52, label %21, label %35
}