#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 log10(int);
int pow(int, int);
int isPalindrome(int n) {
  int result = 0;
  if (n < 0) {
    return 0;
  }
  int digit = log10(n), i = 0, high = pow(10.0, digit);
  ++digit;
  for (i = 0; i < digit / 2; ++i) {
    if ((int)(n / high) % 10 == (int)(n / pow(10, i)) % 10) {
      high /= 10;
      continue;
    } else
      return result;
  }
  result = 1;
  return result;
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1148 <isPalindrome+0x28>
movl   $0x0,-0x4(%rbp)
jmp    1213 <isPalindrome+0xf3>
mov    -0x8(%rbp),%edi
call   1040 <log10@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%esi
mov    $0xa,%edi
call   1030 <pow@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1206 <isPalindrome+0xe6>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x20(%rbp),%edx
cmp    %eax,%edx
jne    11ed <isPalindrome+0xcd>
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    11f8 <isPalindrome+0xd8>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1213 <isPalindrome+0xf3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117a <isPalindrome+0x5a>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPalindrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
js     11ec <isPalindrome+0xcc>
mov    %edi,%r12d
call   1040 <log10@plt>
mov    %eax,%r15d
mov    $0xa,%edi
mov    %eax,%esi
call   1030 <pow@plt>
mov    $0x1,%r14d
test   %r15d,%r15d
jle    11ef <isPalindrome+0xcf>
mov    %eax,%ebp
add    $0x1,%r15d
shr    %r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%eax
cltd
idiv   %ebp
movslq %eax,%r13
imul   $0x66666667,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r13d
mov    $0xa,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cmp    %eax,%r13d
jne    11ec <isPalindrome+0xcc>
movslq %ebp,%rax
imul   $0x66666667,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x22,%rbp
add    %eax,%ebp
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1170 <isPalindrome+0x50>
jmp    11ef <isPalindrome+0xcf>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isPalindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %44
11: ; preds = %1
%12 = load i32, i32* %3
%13 = call i32 @log10(i32 %12)
store i32 %13, i32* %5
store i32 0, i32* %6
%14 = load i32, i32* %5
%15 = call i32 @pow(i32 10, i32 %14)
store i32 %15, i32* %7
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
store i32 0, i32* %6
br label %18
18: ; preds = %39, %11
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sdiv i32 %20, 2
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %42
23: ; preds = %18
%24 = load i32, i32* %3
%25 = load i32, i32* %7
%26 = sdiv i32 %24, %25
%27 = srem i32 %26, 10
%28 = load i32, i32* %3
%29 = load i32, i32* %6
%30 = call i32 @pow(i32 10, i32 %29)
%31 = sdiv i32 %28, %30
%32 = srem i32 %31, 10
%33 = icmp eq i32 %27, %32
br i1 %33, label %34, label %37
34: ; preds = %23
%35 = load i32, i32* %7
%36 = sdiv i32 %35, 10
store i32 %36, i32* %7
br label %39
37: ; preds = %23
%38 = load i32, i32* %4
store i32 %38, i32* %2
br label %44
39: ; preds = %34
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %18
42: ; preds = %18
store i32 1, i32* %4
%43 = load i32, i32* %4
store i32 %43, i32* %2
br label %44
44: ; preds = %42, %37, %10
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
define i32 @isPalindrome(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %23, label %3
3: ; preds = %1
%4 = tail call i32 @log10(i32 %0)
%5 = tail call i32 @pow(i32 10, i32 %4)
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %23
7: ; preds = %3
%8 = add nuw nsw i32 %4, 1
%9 = lshr i32 %8, 1
br label %10
10: ; preds = %7, %19
%11 = phi i32 [ %20, %19 ], [ %5, %7 ]
%12 = phi i32 [ %21, %19 ], [ 0, %7 ]
%13 = sdiv i32 %0, %11
%14 = srem i32 %13, 10
%15 = tail call i32 @pow(i32 10, i32 %12)
%16 = sdiv i32 %0, %15
%17 = srem i32 %16, 10
%18 = icmp eq i32 %14, %17
br i1 %18, label %19, label %23
19: ; preds = %10
%20 = sdiv i32 %11, 10
%21 = add nuw nsw i32 %12, 1
%22 = icmp eq i32 %21, %9
br i1 %22, label %23, label %10
23: ; preds = %19, %10, %3, %1
%24 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 1, %19 ], [ 0, %10 ]
ret i32 %24
}