#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 strlen(char *);
int isPalindrome(int num) {
  int len = 0;
  int isPalindrome = 1;
  int i;
  char out[512];
  sprintf(out, "%d", num);
  len = strlen(out);
  for (i = 0; i < len; i++) {
    if (out[i] != out[len - (i + 1)]) {
      isPalindrome = 0;
      break;
    }
  }
  return isPalindrome;
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xeb3(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bd <isPalindrome+0x9d>
movslq -0x10(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%eax
ff
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
sub    %edx,%ecx
movslq %ecx,%rcx
movsbl -0x210(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
je     11aa <isPalindrome+0x8a>
movl   $0x0,-0xc(%rbp)
jmp    11bd <isPalindrome+0x9d>
jmp    11af <isPalindrome+0x8f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1168 <isPalindrome+0x48>
mov    -0xc(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPalindrome>:
push   %rbx
sub    $0x200,%rsp
mov    %edi,%edx
lea    0xecf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdx
xor    %eax,%eax
test   %edx,%edx
mov    $0x0,%ecx
cmovg  %edx,%ecx
neg    %rcx
lea    (%rdx,%rbx,1),%rsi
add    $0xffffffffffffffff,%rsi
xchg   %ax,%ax
cmp    %rax,%rcx
je     117c <isPalindrome+0x5c>
movzbl (%rbx),%edx
lea    -0x1(%rax),%rdi
add    $0x1,%rbx
cmp    (%rsi,%rax,1),%dl
mov    %rdi,%rax
je     1160 <isPalindrome+0x40>
xor    %eax,%eax
jmp    1181 <isPalindrome+0x61>
mov    $0x1,%eax
add    $0x200,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @isPalindrome(i32 %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 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 = sext i32 %5 to i64
%7 = call i32 @llvm.smax.i32(i32 %5, i32 0)
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %12, %1
%10 = phi i64 [ %15, %12 ], [ 0, %1 ]
%11 = icmp eq i64 %10, %8
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %10
%14 = load i8, i8* %13
%15 = add nuw nsw i64 %10, 1
%16 = sub nsw i64 %6, %15
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %14, %18
br i1 %19, label %9, label %20
20: ; preds = %12, %9
%21 = phi i32 [ 1, %9 ], [ 0, %12 ]
ret i32 %21
}