#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, rev = 0, rem, a;
  printf("Enter a number : ");
  scanf("%d", &n);
  a = n;
  if (n <= 999 || n > 9999) {
    printf(" Not a 4 digit number\n");
    exit(0);
  }
  while (n != 0) {
    rem = n % 10;
    rev = rev * 10 + rem;
    n = n / 10;
  }
  if (a == rev)
    printf("\n The given Number %d is Palindrome", a);
  else
    printf("\n The given Number %d is not Palindrome", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3e7,-0x8(%rbp)
jle    1184 <main+0x54>
cmpl   $0x270f,-0x8(%rbp)
jle    1199 <main+0x69>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    119e <main+0x6e>
cmpl   $0x0,-0x8(%rbp)
je     11d3 <main+0xa3>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
imul   $0xa,-0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    119e <main+0x6e>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11f5 <main+0xc5>
mov    -0x14(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1206 <main+0xd6>
mov    -0x14(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    -0x2710(%rsi),%eax
cmp    $0xffffdcd8,%eax
jb     11d6 <main+0x96>
mov    %esi,%eax
nopl   0x0(%rax)
lea    (%rbx,%rbx,4),%ebx
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rax
add    %edi,%eax
lea    (%rax,%rax,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %ecx,%edx
sub    %edi,%edx
lea    (%rdx,%rbx,2),%ebx
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1180 <main+0x40>
mov    %eax,0xc(%rsp)
cmp    %ebx,%esi
lea    0xe59(%rip),%rax
lea    0xe76(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Enter a number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c" Not a 4 digit number\0A\00"
@.str.3 = [36 x i8] c"\0A The given Number %d is Palindrome\00"
@.str.4 = [40 x i8] c"\0A The given Number %d is not Palindrome\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* %3
%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)
%8 = load i32, i32* %2
store i32 %8, i32* %5
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 999
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp sgt i32 %12, 9999
br i1 %13, label %14, label %17
14: ; preds = %11, %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %11
br label %18
18: ; preds = %21, %17
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %2
%23 = srem i32 %22, 10
store i32 %23, i32* %4
%24 = load i32, i32* %3
%25 = mul nsw i32 %24, 10
%26 = load i32, i32* %4
%27 = add nsw i32 %25, %26
store i32 %27, i32* %3
%28 = load i32, i32* %2
%29 = sdiv i32 %28, 10
store i32 %29, i32* %2
br label %18
30: ; preds = %18
%31 = load i32, i32* %5
%32 = load i32, i32* %3
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %40
37: ; preds = %30
%38 = load i32, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %34
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [36 x i8] c"\0A The given Number %d is Palindrome\00"
@.str.4 = [40 x i8] c"\0A The given Number %d is not Palindrome\00"
@str = [22 x i8] c" Not a 4 digit number\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
%6 = add i32 %5, -10000
%7 = icmp ult i32 %6, -9000
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %0, %11
%12 = phi i32 [ %16, %11 ], [ 0, %0 ]
%13 = phi i32 [ %17, %11 ], [ %5, %0 ]
%14 = srem i32 %13, 10
%15 = mul nsw i32 %12, 10
%16 = add nsw i32 %15, %14
%17 = sdiv i32 %13, 10
%18 = add nsw i32 %13, 9
%19 = icmp ult i32 %18, 19
br i1 %19, label %20, label %11
20: ; preds = %11
store i32 %17, i32* %1
%21 = icmp eq i32 %5, %16
%22 = select i1 %21, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22, i32 %5)
ret i32 0
}