#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 */
typedef int int64_t;

/* Variables and functions */
int ipow(int, int);
bool is_bit_palindrome(int64_t i) {
  while (i > 10) {
    int64_t last_digit = i % 10;
    int64_t copy = i;
    int64_t counter = 0;
    int64_t first_digit;
    for (counter = 0; copy >= 10; counter++) {
      copy = copy / 10;
    }
    first_digit = copy;
    if (first_digit != last_digit) {
      return false;
    }
    i = i - (ipow(10, counter) * first_digit);
    i = i / 10;
  }
  return true;
}


x86 assembly (clang, -O0):
<is_bit_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jle    11bf <is_bit_palindrome+0xaf>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x10(%rbp)
jl     116d <is_bit_palindrome+0x5d>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <is_bit_palindrome+0x37>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     118b <is_bit_palindrome+0x7b>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <is_bit_palindrome+0xb6>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1030 <ipow@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    111b <is_bit_palindrome+0xb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_bit_palindrome>:
push   %rbp
push   %r14
push   %rbx
cmp    $0xb,%edi
jl     11a3 <is_bit_palindrome+0x93>
mov    %edi,%ebx
mov    $0xcccccccd,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ebp
sub    %eax,%ebp
xor    %eax,%eax
mov    %ebx,%ecx
mov    $0x0,%esi
cmp    $0xa,%ebx
jl     1174 <is_bit_palindrome+0x64>
xor    %esi,%esi
mov    %ebx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,%ecx
imul   %r14,%rcx
shr    $0x23,%rcx
add    $0x1,%esi
cmp    $0x63,%edx
mov    %ecx,%edx
ja     1160 <is_bit_palindrome+0x50>
cmp    %ebp,%ecx
jne    11a8 <is_bit_palindrome+0x98>
mov    $0xa,%edi
call   1030 <ipow@plt>
imul   %ebp,%eax
sub    %eax,%ebx
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
cmp    $0x6d,%eax
jg     1130 <is_bit_palindrome+0x20>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_bit_palindrome(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
br label %8
8: ; preds = %30, %1
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 10
br i1 %10, label %11, label %39
11: ; preds = %8
%12 = load i32, i32* %3
%13 = srem i32 %12, 10
store i32 %13, i32* %4
%14 = load i32, i32* %3
store i32 %14, i32* %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %15
15: ; preds = %21, %11
%16 = load i32, i32* %5
%17 = icmp sge i32 %16, 10
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %5
%20 = sdiv i32 %19, 10
store i32 %20, i32* %5
br label %21
21: ; preds = %18
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %15
24: ; preds = %15
%25 = load i32, i32* %5
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = load i32, i32* %4
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %2
br label %40
30: ; preds = %24
%31 = load i32, i32* %3
%32 = load i32, i32* %6
%33 = call i32 @ipow(i32 10, i32 %32)
%34 = load i32, i32* %7
%35 = mul nsw i32 %33, %34
%36 = sub nsw i32 %31, %35
store i32 %36, i32* %3
%37 = load i32, i32* %3
%38 = sdiv i32 %37, 10
store i32 %38, i32* %3
br label %8
39: ; preds = %8
store i32 1, i32* %2
br label %40
40: ; preds = %39, %29
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @is_bit_palindrome(i32 %0) {
%2 = icmp sgt i32 %0, 10
br i1 %2, label %3, label %23
3: ; preds = %1, %17
%4 = phi i32 [ %21, %17 ], [ %0, %1 ]
%5 = urem i32 %4, 10
%6 = icmp sgt i32 %4, 9
br i1 %6, label %7, label %13
7: ; preds = %3, %7
%8 = phi i32 [ %11, %7 ], [ 0, %3 ]
%9 = phi i32 [ %10, %7 ], [ %4, %3 ]
%10 = udiv i32 %9, 10
%11 = add nuw nsw i32 %8, 1
%12 = icmp ugt i32 %9, 99
br i1 %12, label %7, label %13
13: ; preds = %7, %3
%14 = phi i32 [ %4, %3 ], [ %10, %7 ]
%15 = phi i32 [ 0, %3 ], [ %11, %7 ]
%16 = icmp eq i32 %14, %5
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = tail call i32 @ipow(i32 10, i32 %15)
%19 = mul nsw i32 %18, %5
%20 = sub nsw i32 %4, %19
%21 = sdiv i32 %20, 10
%22 = icmp sgt i32 %20, 109
br i1 %22, label %3, label %23
23: ; preds = %17, %13, %1
%24 = phi i32 [ 1, %1 ], [ 0, %13 ], [ 1, %17 ]
ret i32 %24
}