#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 /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void palindromicString() {
  printf("--------------------------------\n");
  printf("PALINDROME WITH STRING\n");
  char string[100], original[100], temp;
  int begin, end;
  printf("Enter the string to check: ");
  scanf("%s", string);
  printf("You entered: %s\n", string);
  strcpy(original, string);
  begin = 0;
  end = strlen(string) - 1;
  while (begin < end) {
    temp = string[begin];
    string[begin] = string[end];
    string[end] = temp;
    begin++;
    end--;
  }
  printf("The reversed string is %s\n", string);
  printf("Since the original is %s", original);
  if (!strcmp(string, original)) {
    printf(" it is a palindrome.\n");
  } else {
    printf(" it is NOT a palindrome.\n");
  }
}


x86 assembly (clang, -O0):
<palindromicString>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xf08(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xec(%rbp)
mov    -0xe8(%rbp),%eax
cmp    -0xec(%rbp),%eax
jge    1240 <palindromicString+0xf0>
movslq -0xe8(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0xe1(%rbp)
movslq -0xec(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0xe8(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0xe1(%rbp),%cl
movslq -0xec(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xec(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xec(%rbp)
jmp    11d3 <palindromicString+0x83>
lea    -0x70(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1293 <palindromicString+0x143>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12a1 <palindromicString+0x151>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindromicString>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xef0(%rip),%rdi
call   1040 <puts@plt>
lea    0xf05(%rip),%rdi
call   1040 <puts@plt>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jl     1200 <palindromicString+0xa0>
mov    %eax,%eax
add    $0xfffffffffffffffe,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
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     11e0 <palindromicString+0x80>
lea    0xe26(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe2d(%rip),%rdi
lea    0x70(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
lea    0xe5b(%rip),%rax
lea    0xe69(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"--------------------------------\0A\00"
@.str.1 = [24 x i8] c"PALINDROME WITH STRING\0A\00"
@.str.2 = [28 x i8] c"Enter the string to check: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [17 x i8] c"You entered: %s\0A\00"
@.str.5 = [27 x i8] c"The reversed string is %s\0A\00"
@.str.6 = [25 x i8] c"Since the original is %s\00"
@.str.7 = [22 x i8] c" it is a palindrome.\0A\00"
@.str.8 = [26 x i8] c" it is NOT a palindrome.\0A\00"
define void @palindromicString() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%15 = call i32 @strcpy(i8* %13, i8* %14)
store i32 0, i32* %4
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %5
br label %19
19: ; preds = %23, %0
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %43
23: ; preds = %19
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
store i8 %27, i8* %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %33
store i8 %31, i8* %34
%35 = load i8, i8* %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %37
store i8 %35, i8* %38
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
%41 = load i32, i32* %5
%42 = add nsw i32 %41, -1
store i32 %42, i32* %5
br label %19
43: ; preds = %19
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %46)
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%50 = call i32 @strcmp(i8* %48, i8* %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %43
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %56
54: ; preds = %43
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %56
56: ; preds = %54, %52
ret void
}

LLVM IR (-O2):
@.str.2 = [28 x i8] c"Enter the string to check: \00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [17 x i8] c"You entered: %s\0A\00"
@.str.5 = [27 x i8] c"The reversed string is %s\0A\00"
@.str.6 = [25 x i8] c"Since the original is %s\00"
@str = [33 x i8] c"--------------------------------\00"
@str.9 = [23 x i8] c"PALINDROME WITH STRING\00"
@str.10 = [21 x i8] c" it is a palindrome.\00"
@str.11 = [25 x i8] c" it is NOT a palindrome.\00"
define void @palindromicString() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%10 = call i32 @strcpy(i8* %6, i8* %5)
%11 = call i32 @strlen(i8* %5)
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %26
13: ; preds = %0
%14 = zext i32 %11 to i64
%15 = add nsw i64 %14, -1
br label %16
16: ; preds = %13, %16
%17 = phi i64 [ 0, %13 ], [ %23, %16 ]
%18 = phi i64 [ %15, %13 ], [ %24, %16 ]
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %17
%20 = load i8, i8* %19
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
%22 = load i8, i8* %21
store i8 %22, i8* %19
store i8 %20, i8* %21
%23 = add nuw nsw i64 %17, 1
%24 = add nsw i64 %18, -1
%25 = icmp slt i64 %23, %24
br i1 %25, label %16, label %26
26: ; preds = %16, %0
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%29 = call i32 @strcmp(i8* %5, i8* %6)
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0)
%32 = call i32 @puts(i8* dereferenceable(1) %31)
ret void
}