#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*/ sprintf(char *, char *, int);
int is_palindrome(int value) {
  char *first, *last, string[7];
  sprintf(string, "%d", value);
  first = string;
  last = string;
  while (*last != '\0') {
    last++;
  }
  last--;
  while (last > first) {
    if (*first != *last)
      return 0;
    first++;
    last--;
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x1f(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xed7(%rip),%rsi
call   1030 <sprintf@plt>
lea    -0x1f(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1f(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     115f <is_palindrome+0x4f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113e <is_palindrome+0x2e>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    11b8 <is_palindrome+0xa8>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     119b <is_palindrome+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    11bf <is_palindrome+0xaf>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    116b <is_palindrome+0x5b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_palindrome>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%edx
lea    0xee2(%rip),%rsi
lea    0x9(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <sprintf@plt>
lea    0x7(%rsp),%rcx
cmpb   $0x0,0x2(%rcx)
lea    0x1(%rcx),%rcx
jne    1130 <is_palindrome+0x20>
mov    $0x1,%eax
cmp    %rbx,%rcx
jbe    116c <is_palindrome+0x5c>
lea    0xa(%rsp),%rdx
nopl   0x0(%rax)
movzbl -0x1(%rdx),%ebx
cmp    (%rcx),%bl
jne    116a <is_palindrome+0x5a>
add    $0xffffffffffffffff,%rcx
lea    0x1(%rdx),%rsi
cmp    %rdx,%rcx
mov    %rsi,%rdx
ja     1150 <is_palindrome+0x40>
jmp    116c <is_palindrome+0x5c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @is_palindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [7 x i8]
store i32 %0, i32* %3
%7 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
store i8* %10, i8** %4
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
store i8* %11, i8** %5
br label %12
12: ; preds = %17, %1
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
br label %12
20: ; preds = %12
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i32 -1
store i8* %22, i8** %5
br label %23
23: ; preds = %36, %20
%24 = load i8*, i8** %5
%25 = load i8*, i8** %4
%26 = icmp ugt i8* %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %5
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %30, %33
br i1 %34, label %35, label %36
35: ; preds = %27
store i32 0, i32* %2
br label %42
36: ; preds = %27
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 -1
store i8* %40, i8** %5
br label %23
41: ; preds = %23
store i32 1, i32* %2
br label %42
42: ; preds = %41, %35
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @is_palindrome(i32 %0) {
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %5
5: ; preds = %5, %1
%6 = phi i8* [ %3, %1 ], [ %9, %5 ]
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %8, label %10, label %5
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %6, i64 -1
%12 = icmp ugt i8* %11, %3
br i1 %12, label %16, label %23
13: ; preds = %16
%14 = getelementptr inbounds i8, i8* %17, i64 -1
%15 = icmp ugt i8* %14, %22
br i1 %15, label %16, label %23
16: ; preds = %10, %13
%17 = phi i8* [ %14, %13 ], [ %11, %10 ]
%18 = phi i8* [ %22, %13 ], [ %3, %10 ]
%19 = load i8, i8* %18
%20 = load i8, i8* %17
%21 = icmp eq i8 %19, %20
%22 = getelementptr inbounds i8, i8* %18, i64 1
br i1 %21, label %13, label %23
23: ; preds = %16, %13, %10
%24 = phi i32 [ 1, %10 ], [ 1, %13 ], [ 0, %16 ]
ret i32 %24
}