#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 palindromeCheck(char *, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char s[1000];
  printf("Enter a string(size<999): ");
  scanf("%s", s);
  int p, n, size;
  size = strlen(s);
  if (size % 2 != 0) {
    p = n = size / 2;
  } else {
    n = size / 2;
    p = n - 1;
  }
  printf("Palindrome : %d\n", palindromeCheck(s, p, n, size));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xead(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3fc(%rbp)
mov    -0x3fc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11bb <main+0x7b>
mov    -0x3fc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3f8(%rbp)
mov    %eax,-0x3f4(%rbp)
jmp    11de <main+0x9e>
mov    -0x3fc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    -0x3f4(%rbp),%esi
mov    -0x3f8(%rbp),%edx
mov    -0x3fc(%rbp),%ecx
call   1050 <palindromeCheck@plt>
mov    %eax,%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
and    $0x1,%ecx
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
lea    (%rcx,%rdx,1),%esi
add    $0xffffffff,%esi
mov    %rbx,%rdi
mov    %eax,%ecx
call   1050 <palindromeCheck@plt>
lea    0xe89(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter a string(size<999): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"Palindrome : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [1000 x i8], [1000 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 [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = srem i32 %11, 2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* %5
%16 = sdiv i32 %15, 2
store i32 %16, i32* %4
store i32 %16, i32* %3
br label %22
17: ; preds = %0
%18 = load i32, i32* %5
%19 = sdiv i32 %18, 2
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %17, %14
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @palindromeCheck(i8* %23, i32 %24, i32 %25, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter a string(size<999): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [17 x i8] c"Palindrome : %d\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 = and i32 %5, 1
%7 = sdiv i32 %5, 2
%8 = add nsw i32 %6, -1
%9 = add nsw i32 %7, %8
%10 = call i32 @palindromeCheck(i8* %2, i32 %9, i32 %7, i32 %5)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret i32 0
}