#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
char *str_reverse(char *);
char *palindrome(char *str) {
  char *rev;
  int i;
  bool result = true;
  char *answer;
  rev = str_reverse(str);
  i = 0;
  while (result && str[i]) {
    if (str[i] != rev[i]) {
      result = false;
    }
    ++i;
  }
  free(rev);
  if (result) {
    answer = (char *)calloc(4, sizeof(char));
    answer[0] = 'Y';
    answer[1] = 'e';
    answer[2] = 's';
    answer[3] = '\0';
  } else {
    answer = (char *)calloc(3, sizeof(char));
    answer[0] = 'N';
    answer[1] = 'o';
    answer[2] = '\0';
  }
  return answer;
}


x86 assembly (clang, -O0):
<palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <str_reverse@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     117b <palindrome+0x4b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    118b <palindrome+0x5b>
jmp    11c0 <palindrome+0x90>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11b2 <palindrome+0x82>
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <palindrome+0x27>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
je     120a <palindrome+0xda>
mov    $0x4,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x59,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x65,0x1(%rax)
mov    -0x20(%rbp),%rax
movb   $0x73,0x2(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x3(%rax)
jmp    1234 <palindrome+0x104>
mov    $0x3,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x4e,(%rax)
mov    -0x20(%rbp),%rax
movb   $0x6f,0x1(%rax)
mov    -0x20(%rbp),%rax
movb   $0x0,0x2(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindrome>:
push   %rbx
mov    %rdi,%rbx
call   1040 <str_reverse@plt>
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%rcx,1),%edx
test   %dl,%dl
je     1179 <palindrome+0x49>
lea    0x1(%rcx),%rsi
cmp    (%rax,%rcx,1),%dl
mov    %rsi,%rcx
je     1140 <palindrome+0x10>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x3,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
movw   $0x6f4e,(%rax)
mov    %rax,%rcx
add    $0x2,%rcx
jmp    11a0 <palindrome+0x70>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x4,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
movw   $0x6559,(%rax)
movb   $0x73,0x2(%rax)
mov    %rax,%rcx
add    $0x3,%rcx
movb   $0x0,(%rcx)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @palindrome(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %2
store i32 1, i32* %5
%7 = load i8*, i8** %2
%8 = call i8* @str_reverse(i8* %7)
store i8* %8, i8** %3
store i32 0, i32* %4
br label %9
9: ; preds = %37, %1
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %12, %9
%21 = phi i1 [ false, %9 ], [ %19, %12 ]
br i1 %21, label %22, label %40
22: ; preds = %20
%23 = load i8*, i8** %2
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %3
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %28, %34
br i1 %35, label %36, label %37
36: ; preds = %22
store i32 0, i32* %5
br label %37
37: ; preds = %36, %22
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %9
40: ; preds = %20
%41 = load i8*, i8** %3
%42 = call i32 @free(i8* %41)
%43 = load i32, i32* %5
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %56
45: ; preds = %40
%46 = call i64 @calloc(i32 4, i32 1)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %6
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i64 0
store i8 89, i8* %49
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i64 1
store i8 101, i8* %51
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i64 2
store i8 115, i8* %53
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i64 3
store i8 0, i8* %55
br label %65
56: ; preds = %40
%57 = call i64 @calloc(i32 3, i32 1)
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %6
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i64 0
store i8 78, i8* %60
%61 = load i8*, i8** %6
%62 = getelementptr inbounds i8, i8* %61, i64 1
store i8 111, i8* %62
%63 = load i8*, i8** %6
%64 = getelementptr inbounds i8, i8* %63, i64 2
store i8 0, i8* %64
br label %65
65: ; preds = %56, %45
%66 = load i8*, i8** %6
ret i8* %66
}

LLVM IR (-O2):
define i8* @palindrome(i8* %0) {
%2 = tail call i8* @str_reverse(i8* %0)
br label %3
3: ; preds = %1, %8
%4 = phi i64 [ 0, %1 ], [ %12, %8 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %2, i64 %4
%10 = load i8, i8* %9
%11 = icmp eq i8 %6, %10
%12 = add nuw i64 %4, 1
br i1 %11, label %3, label %20
13: ; preds = %3
%14 = tail call i32 @free(i8* %2)
%15 = tail call i64 @calloc(i32 4, i32 1)
%16 = inttoptr i64 %15 to i8*
store i8 89, i8* %16
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8 101, i8* %17
%18 = getelementptr inbounds i8, i8* %16, i64 2
store i8 115, i8* %18
%19 = getelementptr inbounds i8, i8* %16, i64 3
br label %26
20: ; preds = %8
%21 = tail call i32 @free(i8* %2)
%22 = tail call i64 @calloc(i32 3, i32 1)
%23 = inttoptr i64 %22 to i8*
store i8 78, i8* %23
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 111, i8* %24
%25 = getelementptr inbounds i8, i8* %23, i64 2
br label %26
26: ; preds = %20, %13
%27 = phi i8* [ %25, %20 ], [ %19, %13 ]
%28 = phi i8* [ %23, %20 ], [ %16, %13 ]
store i8 0, i8* %27
ret i8* %28
}