#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 BUFSIZ;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
size_t snprintf(char *, int, char *, size_t);
int /*<<< orphan*/ stderr;
int strlen(char *);
bool ispalindrome(size_t number) {
  char s[BUFSIZ];
  size_t bytes = snprintf(s, BUFSIZ, "%zu", number);
  if (bytes <= 0 || bytes >= BUFSIZ) {
    fprintf(stderr, "Failed to check %zu exceeds length of string\n", number);
    return false;
  }
  char *start = s;
  char *end = s + strlen(s) - 1;
  while (start < end) {
    if (*start++ != *end--)
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<ispalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
lea    0xe84(%rip),%rdx
call   1040 <snprintf@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jbe    11a7 <ispalindrome+0x77>
mov    -0x28(%rbp),%rax
mov    0x2e3d(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jb     11d3 <ispalindrome+0xa3>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1254 <ispalindrome+0x124>
mov    -0x48(%rbp),%rdi
mov    %rdi,-0x38(%rbp)
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    1246 <ispalindrome+0x116>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movsbl (%rax),%eax
mov    -0x40(%rbp),%rcx
mov    %rcx,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x40(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1241 <ispalindrome+0x111>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
jmp    1254 <ispalindrome+0x124>
jmp    11f4 <ispalindrome+0xc4>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ispalindrome>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e94(%rip),%r15
mov    (%r15),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9e(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1040 <snprintf@plt>
test   %rax,%rax
je     11a9 <ispalindrome+0x79>
movslq (%r15),%rcx
cmp    %rcx,%rax
jae    11a9 <ispalindrome+0x79>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax,%rax,1)
cmp    %rax,%rbx
jae    11c5 <ispalindrome+0x95>
movzbl (%rbx),%ecx
add    $0x1,%rbx
lea    -0x1(%rax),%rdx
cmp    (%rax),%cl
mov    %rdx,%rax
je     1190 <ispalindrome+0x60>
jmp    11c1 <ispalindrome+0x91>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
xor    %eax,%eax
jmp    11ca <ispalindrome+0x9a>
mov    $0x1,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [4 x i8] c"%zu\00"
@stderr = global i32 0
@.str.1 = [46 x i8] c"Failed to check %zu exceeds length of string\0A\00"
define i32 @ispalindrome(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i64 %0, i64* %3
%10 = load i32, i32* @BUFSIZ
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %4
%13 = alloca i8, i64 %11
store i64 %11, i64* %5
%14 = load i32, i32* @BUFSIZ
%15 = load i64, i64* %3
%16 = call i64 @snprintf(i8* %13, i32 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %15)
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = icmp ule i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %1
%20 = load i64, i64* %6
%21 = load i32, i32* @BUFSIZ
%22 = sext i32 %21 to i64
%23 = icmp uge i64 %20, %22
br i1 %23, label %24, label %28
24: ; preds = %19, %1
%25 = load i32, i32* @stderr
%26 = load i64, i64* %3
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i64 %26)
store i32 0, i32* %2
store i32 1, i32* %7
br label %50
28: ; preds = %19
store i8* %13, i8** %8
%29 = call i32 @strlen(i8* %13)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %13, i64 %30
%32 = getelementptr inbounds i8, i8* %31, i64 -1
store i8* %32, i8** %9
br label %33
33: ; preds = %48, %28
%34 = load i8*, i8** %8
%35 = load i8*, i8** %9
%36 = icmp ult i8* %34, %35
br i1 %36, label %37, label %49
37: ; preds = %33
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %8
%40 = load i8, i8* %38
%41 = sext i8 %40 to i32
%42 = load i8*, i8** %9
%43 = getelementptr inbounds i8, i8* %42, i32 -1
store i8* %43, i8** %9
%44 = load i8, i8* %42
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %41, %45
br i1 %46, label %47, label %48
47: ; preds = %37
store i32 0, i32* %2
store i32 1, i32* %7
br label %50
48: ; preds = %37
br label %33
49: ; preds = %33
store i32 1, i32* %2
store i32 1, i32* %7
br label %50
50: ; preds = %49, %47, %24
%51 = load i8*, i8** %4
%52 = load i32, i32* %2
ret i32 %52
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [4 x i8] c"%zu\00"
@stderr = global i32 0
@.str.1 = [46 x i8] c"Failed to check %zu exceeds length of string\0A\00"
define i32 @ispalindrome(i64 %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i64 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %0)
%6 = icmp ne i64 %5, 0
%7 = load i32, i32* @BUFSIZ
%8 = sext i32 %7 to i64
%9 = icmp ult i64 %5, %8
%10 = select i1 %6, i1 %9, i1 false
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i64 %0)
br label %28
14: ; preds = %1
%15 = call i32 @strlen(i8* %4)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %4, i64 %16
br label %18
18: ; preds = %23, %14
%19 = phi i8* [ %4, %14 ], [ %24, %23 ]
%20 = phi i8* [ %17, %14 ], [ %21, %23 ]
%21 = getelementptr inbounds i8, i8* %20, i64 -1
%22 = icmp ult i8* %19, %21
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = getelementptr inbounds i8, i8* %19, i64 1
%25 = load i8, i8* %19
%26 = load i8, i8* %21
%27 = icmp eq i8 %25, %26
br i1 %27, label %18, label %28
28: ; preds = %23, %18, %11
%29 = phi i32 [ 0, %11 ], [ 1, %18 ], [ 0, %23 ]
ret i32 %29
}