#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*/ printf(char *, int);
int isPalindrome(int x) {
  int highBit = 1 << 31;
  int lowBit = 1;
  int inputIsPalindrome = 1;
  int leftMost = 0;
  int rightMost = 0;
  int i;
  leftMost = x & highBit;
  rightMost = x & lowBit;
  for (i = 1; i < 16; i++) {
    leftMost = x & highBit;
    rightMost = x & lowBit;
    if ((leftMost > 0 && rightMost > 0) || (leftMost == 0 && rightMost == 0) ||
        (leftMost < 0 && rightMost > 0)) {
      highBit = highBit >> 1;
      lowBit = lowBit << 1;
    } else {
      printf("pair %i didn't match :/\n", i);
      inputIsPalindrome = 0;
      break;
    }
  }
  return inputIsPalindrome;
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x80000000,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    11f4 <isPalindrome+0xe4>
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1187 <isPalindrome+0x77>
cmpl   $0x0,-0x18(%rbp)
jg     11af <isPalindrome+0x9f>
cmpl   $0x0,-0x14(%rbp)
jne    119b <isPalindrome+0x8b>
cmpl   $0x0,-0x18(%rbp)
je     11af <isPalindrome+0x9f>
cmpl   $0x0,-0x14(%rbp)
jge    11c6 <isPalindrome+0xb6>
cmpl   $0x0,-0x18(%rbp)
jle    11c6 <isPalindrome+0xb6>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e1 <isPalindrome+0xd1>
mov    -0x1c(%rbp),%esi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    11f4 <isPalindrome+0xe4>
jmp    11e6 <isPalindrome+0xd6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <isPalindrome+0x47>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPalindrome>:
mov    $0x80000000,%edx
mov    $0x1,%esi
mov    $0x1,%ecx
jmp    113c <isPalindrome+0x2c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
sar    %edx
add    %ecx,%ecx
add    $0x1,%esi
cmp    $0x10,%esi
je     1170 <isPalindrome+0x60>
mov    %ecx,%r8d
and    %edi,%r8d
test   %edi,%edx
jle    114b <isPalindrome+0x3b>
test   %r8d,%r8d
jg     1130 <isPalindrome+0x20>
mov    %edx,%eax
or     %ecx,%eax
test   %edi,%eax
je     1130 <isPalindrome+0x20>
test   %edi,%edx
jns    115c <isPalindrome+0x4c>
test   %r8d,%r8d
jg     1130 <isPalindrome+0x20>
push   %rax
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
@.str = [25 x i8] c"pair %i didn't match :/\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* %2
store i32 -2147483648, i32* %3
store i32 1, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = and i32 %9, %10
store i32 %11, i32* %6
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = and i32 %12, %13
store i32 %14, i32* %7
store i32 1, i32* %8
br label %15
15: ; preds = %51, %1
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 16
br i1 %17, label %18, label %54
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = and i32 %19, %20
store i32 %21, i32* %6
%22 = load i32, i32* %2
%23 = load i32, i32* %4
%24 = and i32 %22, %23
store i32 %24, i32* %7
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load i32, i32* %7
%29 = icmp sgt i32 %28, 0
br i1 %29, label %42, label %30
30: ; preds = %27, %18
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %33, %30
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load i32, i32* %7
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %39, %33, %27
%43 = load i32, i32* %3
%44 = ashr i32 %43, 1
store i32 %44, i32* %3
%45 = load i32, i32* %4
%46 = shl i32 %45, 1
store i32 %46, i32* %4
br label %50
47: ; preds = %39, %36
%48 = load i32, i32* %8
%49 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %48)
store i32 0, i32* %5
br label %54
50: ; preds = %42
br label %51
51: ; preds = %50
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %15
54: ; preds = %47, %15
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
@.str = [25 x i8] c"pair %i didn't match :/\0A\00"
define i32 @isPalindrome(i32 %0) {
br label %2
2: ; preds = %1, %18
%3 = phi i32 [ 1, %1 ], [ %21, %18 ]
%4 = phi i32 [ 1, %1 ], [ %20, %18 ]
%5 = phi i32 [ -2147483648, %1 ], [ %19, %18 ]
%6 = and i32 %5, %0
%7 = and i32 %4, %0
%8 = icmp sgt i32 %6, 0
%9 = icmp sgt i32 %7, 0
%10 = select i1 %8, i1 %9, i1 false
br i1 %10, label %18, label %11
11: ; preds = %2
%12 = icmp eq i32 %6, 0
%13 = icmp eq i32 %7, 0
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = icmp slt i32 %6, 0
%17 = select i1 %16, i1 %9, i1 false
br i1 %17, label %18, label %23
18: ; preds = %15, %11, %2
%19 = ashr i32 %5, 1
%20 = shl i32 %4, 1
%21 = add nuw nsw i32 %3, 1
%22 = icmp eq i32 %21, 16
br i1 %22, label %25, label %2
23: ; preds = %15
%24 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %25
25: ; preds = %18, %23
%26 = phi i32 [ 0, %23 ], [ 1, %18 ]
ret i32 %26
}