#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 *, unsigned int);
int strlen(char *);
int is_palindrome(unsigned int n) {
  char str[90];
  sprintf(str, "%u", n);
  int len = strlen(str);
  for (int i = 0; i < len / 2; i++) {
    if (str[i] != str[len - i - 1]) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xec4(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x74(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
jge    11b3 <is_palindrome+0x93>
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
mov    -0x74(%rbp),%ecx
sub    -0x78(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x70(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11a0 <is_palindrome+0x80>
movl   $0x0,-0x4(%rbp)
jmp    11ba <is_palindrome+0x9a>
jmp    11a5 <is_palindrome+0x85>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1154 <is_palindrome+0x34>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_palindrome>:
push   %rbx
sub    $0x60,%rsp
mov    %edi,%edx
lea    0xed2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    $0x1,%ecx
cmp    $0x2,%eax
jl     11a3 <is_palindrome+0x83>
mov    (%rsp),%dl
lea    -0x1(%rax),%ecx
movslq %ecx,%rsi
xor    %ecx,%ecx
cmp    (%rsp,%rsi,1),%dl
jne    11a3 <is_palindrome+0x83>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%r8
mov    %r8d,%ecx
add    $0xfffffffe,%eax
mov    $0x1,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rdi,%rsi
cmp    %rdi,%rcx
je     119b <is_palindrome+0x7b>
movzbl (%rsp,%rsi,1),%ebx
movslq %eax,%rdx
lea    0x1(%rsi),%rdi
lea    -0x1(%rdx),%eax
cmp    (%rsp,%rdx,1),%bl
je     1180 <is_palindrome+0x60>
xor    %ecx,%ecx
cmp    %r8,%rsi
setge  %cl
mov    %ecx,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
define i32 @is_palindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [90 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = getelementptr inbounds [90 x i8], [90 x i8]* %4, 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 [90 x i8], [90 x i8]* %4, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %5
store i32 0, i32* %6
br label %12
12: ; preds = %34, %1
%13 = load i32, i32* %6
%14 = load i32, i32* %5
%15 = sdiv i32 %14, 2
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %37
17: ; preds = %12
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = sub nsw i32 %23, %24
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [90 x i8], [90 x i8]* %4, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %22, %30
br i1 %31, label %32, label %33
32: ; preds = %17
store i32 0, i32* %2
br label %38
33: ; preds = %17
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %12
37: ; preds = %12
store i32 1, i32* %2
br label %38
38: ; preds = %37, %32
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
define i32 @is_palindrome(i32 %0) {
%2 = alloca [90 x i8]
%3 = getelementptr inbounds [90 x i8], [90 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)
%5 = call i32 @strlen(i8* %3)
%6 = sdiv i32 %5, 2
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %35
8: ; preds = %1
%9 = sext i32 %6 to i64
%10 = zext i32 %6 to i64
%11 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 0
%12 = load i8, i8* %11
%13 = add i32 %5, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %12, %16
br i1 %17, label %18, label %35
18: ; preds = %8, %21
%19 = phi i64 [ %31, %21 ], [ 1, %8 ]
%20 = icmp eq i64 %19, %10
br i1 %20, label %32, label %21
21: ; preds = %18
%22 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 %19
%23 = load i8, i8* %22
%24 = trunc i64 %19 to i32
%25 = xor i32 %24, -1
%26 = add i32 %5, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [90 x i8], [90 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %23, %29
%31 = add nuw nsw i64 %19, 1
br i1 %30, label %18, label %32
32: ; preds = %18, %21
%33 = icmp sge i64 %19, %9
%34 = zext i1 %33 to i32
br label %35
35: ; preds = %32, %8, %1
%36 = phi i32 [ 1, %1 ], [ 0, %8 ], [ %34, %32 ]
ret i32 %36
}