#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, i, j = 0, temp;
  printf("Enter a Number : ");
  scanf("%d", &n);
  for (i = sizeof(int) * 8 - 1; !(n >> i & 1); i--)
    ;
  for (; j < i; i--, j++)
    if ((n >> i & 1) != (n >> j & 1))
      break;
  temp = i;
  for (i += j; i >= 0; printf("%d", n >> i & 1), i--)
    ;
  if (temp <= j)
    printf(" - Palindrome\n");
  else
    printf(" - Not Palindrome\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1f,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117b <main+0x5b>
jmp    118e <main+0x6e>
jmp    1180 <main+0x60>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
jmp    1193 <main+0x73>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e0 <main+0xc0>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0x1,%ecx
cmp    %ecx,%eax
je     11c4 <main+0xa4>
jmp    11e0 <main+0xc0>
jmp    11c9 <main+0xa9>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1193 <main+0x73>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1225 <main+0x105>
jmp    11fe <main+0xde>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11ef <main+0xcf>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1244 <main+0x124>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1252 <main+0x132>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0x20,%ebx
mov    0x4(%rsp),%esi
nop
add    $0xffffffff,%ebx
bt     %ebx,%esi
jae    1160 <main+0x30>
lea    0xeb8(%rip),%r14
xor    %r15d,%r15d
test   %ebx,%ebx
jle    11a6 <main+0x76>
lea    0xe98(%rip),%rax
nopl   (%rax)
mov    %esi,%edx
mov    %ebx,%ecx
shr    %cl,%edx
mov    %esi,%edi
mov    %r15d,%ecx
shr    %cl,%edi
xor    %edx,%edi
test   $0x1,%dil
jne    11a3 <main+0x73>
add    $0xffffffff,%ebx
add    $0x1,%r15d
cmp    %ebx,%r15d
jl     1180 <main+0x50>
jmp    11a6 <main+0x76>
mov    %rax,%r14
mov    %ebx,%ebp
add    %r15d,%ebp
js     11fe <main+0xce>
mov    %ebp,%ecx
shr    %cl,%esi
and    $0x1,%esi
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
je     11fe <main+0xce>
lea    (%rbx,%r15,1),%ebp
add    $0x1,%ebp
lea    0xe3e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x4(%rsp),%esi
lea    -0x2(%rbp),%ecx
shr    %cl,%esi
and    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     11e0 <main+0xb0>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter a Number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c" - Palindrome\0A\00"
@.str.3 = [19 x i8] c" - Not Palindrome\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 31, i32* %3
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = ashr i32 %9, %10
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %19
15: ; preds = %8
br label %16
16: ; preds = %15
%17 = load i32, i32* %3
%18 = add nsw i32 %17, -1
store i32 %18, i32* %3
br label %8
19: ; preds = %8
br label %20
20: ; preds = %36, %19
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %41
24: ; preds = %20
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = ashr i32 %25, %26
%28 = and i32 %27, 1
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = ashr i32 %29, %30
%32 = and i32 %31, 1
%33 = icmp ne i32 %28, %32
br i1 %33, label %34, label %35
34: ; preds = %24
br label %41
35: ; preds = %24
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, -1
store i32 %38, i32* %3
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %20
41: ; preds = %34, %20
%42 = load i32, i32* %3
store i32 %42, i32* %5
%43 = load i32, i32* %4
%44 = load i32, i32* %3
%45 = add nsw i32 %44, %43
store i32 %45, i32* %3
br label %46
46: ; preds = %50, %41
%47 = load i32, i32* %3
%48 = icmp sge i32 %47, 0
br i1 %48, label %49, label %58
49: ; preds = %46
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = ashr i32 %51, %52
%54 = and i32 %53, 1
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %3
%57 = add nsw i32 %56, -1
store i32 %57, i32* %3
br label %46
58: ; preds = %46
%59 = load i32, i32* %5
%60 = load i32, i32* %4
%61 = icmp sle i32 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %66
64: ; preds = %58
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64, %62
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a Number : \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [18 x i8] c" - Not Palindrome\00"
@str.4 = [14 x i8] c" - Palindrome\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ 31, %0 ], [ %11, %6 ]
%8 = shl nuw i32 1, %7
%9 = and i32 %5, %8
%10 = icmp eq i32 %9, 0
%11 = add nsw i32 %7, -1
br i1 %10, label %6, label %12
12: ; preds = %6
%13 = icmp sgt i32 %7, 0
br i1 %13, label %14, label %26
14: ; preds = %12, %22
%15 = phi i32 [ %23, %22 ], [ %7, %12 ]
%16 = phi i32 [ %24, %22 ], [ 0, %12 ]
%17 = lshr i32 %5, %15
%18 = lshr i32 %5, %16
%19 = xor i32 %17, %18
%20 = and i32 %19, 1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = add nsw i32 %15, -1
%24 = add nuw nsw i32 %16, 1
%25 = icmp slt i32 %24, %23
br i1 %25, label %14, label %26
26: ; preds = %22, %14, %12
%27 = phi i32 [ 0, %12 ], [ %24, %22 ], [ %16, %14 ]
%28 = phi i32 [ %7, %12 ], [ %23, %22 ], [ %15, %14 ]
%29 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0), %22 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0), %14 ]
%30 = add nsw i32 %28, %27
%31 = icmp sgt i32 %30, -1
br i1 %31, label %32, label %45
32: ; preds = %26
%33 = lshr i32 %5, %30
%34 = and i32 %33, 1
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = icmp eq i32 %30, 0
br i1 %36, label %45, label %37
37: ; preds = %32, %37
%38 = phi i32 [ %39, %37 ], [ %30, %32 ]
%39 = add nsw i32 %38, -1
%40 = load i32, i32* %1
%41 = lshr i32 %40, %39
%42 = and i32 %41, 1
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = icmp sgt i32 %38, 1
br i1 %44, label %37, label %45
45: ; preds = %37, %32, %26
%46 = call i32 @puts(i8* dereferenceable(1) %29)
ret i32 0
}