#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*/ assert(int);
int fmod(int, int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
bool isPalindrome(int x) {
  printf("x: %d\n", x);
  if (x == 0) {
    return true;
  }
  if (x < 0) {
    if (x == -2147483648) {
      return false;
    }
    x = -1 * x;
    return false;
  }
  assert(x >= 0);
  int length = 1;
  int quotient;
  for (length = 1; length <= 11; length++) {
    quotient = x / pow(10, length);
    if (quotient == 0) {
      break;
    }
  }
  printf("length is  %d, odd. \n", length);
  int tmp = length - 1;
  while (x > 0) {
    int a = x / pow(10, tmp);
    int b = fmod(x, 10);
    printf("%d, %d, %d\n", a, b, x);
    if (a != b) {
      return false;
    }
    x -= b * pow(10, tmp);
    tmp = tmp - 2;
    x = x / 10;
  }
  return true;
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1172 <isPalindrome+0x32>
movl   $0x1,-0x4(%rbp)
jmp    12dc <isPalindrome+0x19c>
cmpl   $0x0,-0x8(%rbp)
jge    11ae <isPalindrome+0x6e>
movslq -0x8(%rbp),%rax
cmp    $0xffffffff80000000,%rax
jne    1198 <isPalindrome+0x58>
movl   $0x0,-0x4(%rbp)
jmp    12dc <isPalindrome+0x19c>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    12dc <isPalindrome+0x19c>
cmpl   $0x0,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0xb,-0xc(%rbp)
jg     1217 <isPalindrome+0xd7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1204 <isPalindrome+0xc4>
jmp    1217 <isPalindrome+0xd7>
jmp    1209 <isPalindrome+0xc9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <isPalindrome+0x8d>
mov    -0xc(%rbp),%esi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    12d5 <isPalindrome+0x195>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    $0xa,%esi
call   1040 <fmod@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1298 <isPalindrome+0x158>
movl   $0x0,-0x4(%rbp)
jmp    12dc <isPalindrome+0x19c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    -0x28(%rbp),%ecx
imul   %eax,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1231 <isPalindrome+0xf1>
movl   $0x1,-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
mov    %edi,%r13d
lea    0xeab(%rip),%rdi
xor    %r14d,%r14d
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r13d,%r13d
je     139f <isPalindrome+0x25f>
js     13a5 <isPalindrome+0x265>
mov    $0x1,%r12d
mov    $0x1,%edi
call   1050 <assert@plt>
mov    $0xa,%edi
mov    $0x1,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x2,%r12d
mov    $0xa,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x3,%r12d
mov    $0xa,%edi
mov    $0x3,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x4,%r12d
mov    $0xa,%edi
mov    $0x4,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x5,%r12d
mov    $0xa,%edi
mov    $0x5,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x6,%r12d
mov    $0xa,%edi
mov    $0x6,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x7,%r12d
mov    $0xa,%edi
mov    $0x7,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x8,%r12d
mov    $0xa,%edi
mov    $0x8,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0x9,%r12d
mov    $0xa,%edi
mov    $0x9,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0xa,%edi
mov    $0xa,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
mov    $0xa,%r12d
test   %eax,%eax
je     1305 <isPalindrome+0x1c5>
mov    $0xa,%edi
mov    $0xb,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
cmp    $0x1,%eax
mov    $0xc,%r12d
sbb    $0x0,%r12d
lea    0xcfb(%rip),%rdi
xor    %r14d,%r14d
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xffffffff,%r12d
lea    0xcf9(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
mov    %r12d,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
mov    %eax,%ebp
mov    %r13d,%edi
mov    $0xa,%esi
call   1040 <fmod@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebx,%ebp
jne    13a5 <isPalindrome+0x265>
mov    $0xa,%edi
mov    %r12d,%esi
call   1060 <pow@plt>
imul   %ebp,%eax
sub    %eax,%r13d
add    $0xfffffffe,%r12d
movslq %r13d,%rax
imul   $0x66666667,%rax,%r13
mov    %r13,%rcx
shr    $0x3f,%rcx
sar    $0x22,%r13
add    %ecx,%r13d
cmp    $0x9,%eax
jg     1330 <isPalindrome+0x1f0>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"x: %d\0A\00"
@.str.1 = [22 x i8] c"length is %d, odd. \0A\00"
@.str.2 = [12 x i8] c"%d, %d, %d\0A\00"
define i32 @isPalindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
%9 = load i32, i32* %3
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 1, i32* %2
br label %80
14: ; preds = %1
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = icmp eq i64 %19, -2147483648
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %2
br label %80
22: ; preds = %17
%23 = load i32, i32* %3
%24 = mul nsw i32 -1, %23
store i32 %24, i32* %3
store i32 0, i32* %2
br label %80
25: ; preds = %14
%26 = load i32, i32* %3
%27 = icmp sge i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
store i32 1, i32* %4
store i32 1, i32* %4
br label %30
30: ; preds = %42, %25
%31 = load i32, i32* %4
%32 = icmp sle i32 %31, 11
br i1 %32, label %33, label %45
33: ; preds = %30
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = call i32 @pow(i32 10, i32 %35)
%37 = sdiv i32 %34, %36
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %33
br label %45
41: ; preds = %33
br label %42
42: ; preds = %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %30
45: ; preds = %40, %30
%46 = load i32, i32* %4
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %4
%49 = sub nsw i32 %48, 1
store i32 %49, i32* %6
br label %50
50: ; preds = %68, %45
%51 = load i32, i32* %3
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %79
53: ; preds = %50
%54 = load i32, i32* %3
%55 = load i32, i32* %6
%56 = call i32 @pow(i32 10, i32 %55)
%57 = sdiv i32 %54, %56
store i32 %57, i32* %7
%58 = load i32, i32* %3
%59 = call i32 @fmod(i32 %58, i32 10)
store i32 %59, i32* %8
%60 = load i32, i32* %7
%61 = load i32, i32* %8
%62 = load i32, i32* %3
%63 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 %61, i32 %62)
%64 = load i32, i32* %7
%65 = load i32, i32* %8
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %68
67: ; preds = %53
store i32 0, i32* %2
br label %80
68: ; preds = %53
%69 = load i32, i32* %8
%70 = load i32, i32* %6
%71 = call i32 @pow(i32 10, i32 %70)
%72 = mul nsw i32 %69, %71
%73 = load i32, i32* %3
%74 = sub nsw i32 %73, %72
store i32 %74, i32* %3
%75 = load i32, i32* %6
%76 = sub nsw i32 %75, 2
store i32 %76, i32* %6
%77 = load i32, i32* %3
%78 = sdiv i32 %77, 10
store i32 %78, i32* %3
br label %50
79: ; preds = %50
store i32 1, i32* %2
br label %80
80: ; preds = %79, %67, %22, %21, %13
%81 = load i32, i32* %2
ret i32 %81
}

LLVM IR (-O2):
@.str = [7 x i8] c"x: %d\0A\00"
@.str.1 = [22 x i8] c"length is %d, odd. \0A\00"
@.str.2 = [12 x i8] c"%d, %d, %d\0A\00"
define i32 @isPalindrome(i32 %0) {
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = icmp eq i32 %0, 0
br i1 %3, label %71, label %4
4: ; preds = %1
%5 = icmp slt i32 %0, 0
br i1 %5, label %71, label %6
6: ; preds = %4
%7 = tail call i32 @assert(i32 1)
%8 = tail call i32 @pow(i32 10, i32 1)
%9 = sdiv i32 %0, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %52, label %11
11: ; preds = %6
%12 = tail call i32 @pow(i32 10, i32 2)
%13 = sdiv i32 %0, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %52, label %15
15: ; preds = %11
%16 = tail call i32 @pow(i32 10, i32 3)
%17 = sdiv i32 %0, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %52, label %19
19: ; preds = %15
%20 = tail call i32 @pow(i32 10, i32 4)
%21 = sdiv i32 %0, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %52, label %23
23: ; preds = %19
%24 = tail call i32 @pow(i32 10, i32 5)
%25 = sdiv i32 %0, %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %52, label %27
27: ; preds = %23
%28 = tail call i32 @pow(i32 10, i32 6)
%29 = sdiv i32 %0, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %52, label %31
31: ; preds = %27
%32 = tail call i32 @pow(i32 10, i32 7)
%33 = sdiv i32 %0, %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %52, label %35
35: ; preds = %31
%36 = tail call i32 @pow(i32 10, i32 8)
%37 = sdiv i32 %0, %36
%38 = icmp eq i32 %37, 0
br i1 %38, label %52, label %39
39: ; preds = %35
%40 = tail call i32 @pow(i32 10, i32 9)
%41 = sdiv i32 %0, %40
%42 = icmp eq i32 %41, 0
br i1 %42, label %52, label %43
43: ; preds = %39
%44 = tail call i32 @pow(i32 10, i32 10)
%45 = sdiv i32 %0, %44
%46 = icmp eq i32 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %43
%48 = tail call i32 @pow(i32 10, i32 11)
%49 = sdiv i32 %0, %48
%50 = icmp eq i32 %49, 0
%51 = select i1 %50, i32 11, i32 12
br label %52
52: ; preds = %47, %6, %11, %15, %19, %23, %27, %31, %35, %39, %43
%53 = phi i32 [ 1, %6 ], [ 2, %11 ], [ 3, %15 ], [ 4, %19 ], [ 5, %23 ], [ 6, %27 ], [ 7, %31 ], [ 8, %35 ], [ 9, %39 ], [ 10, %43 ], [ %51, %47 ]
%54 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%55 = add nsw i32 %53, -1
br label %56
56: ; preds = %52, %64
%57 = phi i32 [ %69, %64 ], [ %0, %52 ]
%58 = phi i32 [ %68, %64 ], [ %55, %52 ]
%59 = tail call i32 @pow(i32 10, i32 %58)
%60 = sdiv i32 %57, %59
%61 = tail call i32 @fmod(i32 %57, i32 10)
%62 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 %61, i32 %57)
%63 = icmp eq i32 %60, %61
br i1 %63, label %64, label %71
64: ; preds = %56
%65 = tail call i32 @pow(i32 10, i32 %58)
%66 = mul nsw i32 %65, %60
%67 = sub nsw i32 %57, %66
%68 = add nsw i32 %58, -2
%69 = sdiv i32 %67, 10
%70 = icmp sgt i32 %67, 9
br i1 %70, label %56, label %71
71: ; preds = %64, %56, %4, %1
%72 = phi i32 [ 1, %1 ], [ 0, %4 ], [ 1, %64 ], [ 0, %56 ]
ret i32 %72
}