#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 s[32];
  int length;
  int c = 0;
  int i, j;
  printf("Enter a string: ");
  scanf("%s", s);
  length = strlen(s);
  for (i = 0; i < length / 2; i++) {
    if (s[i] != s[length - 1 - i]) {
      c = -1;
      break;
    }
  }
  if (c != -1) {
    printf("%s is a palindrome.\n", s);
  } else {
    printf("%s is not a palindrome.\n", s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    11d6 <main+0xa6>
movslq -0x3c(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11c3 <main+0x93>
movl   $0xffffffff,-0x38(%rbp)
jmp    11d6 <main+0xa6>
jmp    11c8 <main+0x98>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1177 <main+0x47>
cmpl   $0xffffffff,-0x38(%rbp)
je     11f7 <main+0xc7>
lea    -0x30(%rbp),%rsi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1209 <main+0xd9>
lea    -0x30(%rbp),%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xeb0(%rip),%rdi
cmp    $0x2,%eax
jl     119d <main+0x6d>
mov    %eax,%ecx
shr    %ecx
add    $0xffffffff,%eax
xor    %edx,%edx
lea    0xeb0(%rip),%r8
nopl   0x0(%rax)
movzbl (%rsp,%rdx,1),%ebx
movslq %eax,%rsi
cmp    (%rsp,%rsi,1),%bl
jne    119a <main+0x6a>
add    $0x1,%rdx
add    $0xffffffff,%eax
cmp    %rdx,%rcx
jne    1180 <main+0x50>
jmp    119d <main+0x6d>
mov    %r8,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

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