#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 iNum, iRev = 0, iTemp, iRem;
  printf("\n*******************************************************************"
         "*******");
  printf(
      "\n*\tPROGRAM TO CHECK WHETHER AN INTEGER IS A PALINDROME OR NOT\t *\n");
  printf("*********************************************************************"
         "*****");
  printf("\nEnter a number\n");
  scanf("%d", &iNum);
  iTemp = iNum;
  while (iNum != 0) {
    iRem = iNum % 10;
    iRev = iRev * 10 + iRem;
    iNum = iNum / 10;
  }
  printf("\nReverse is %d", iRev);
  if (iRev == iTemp)
    printf("\nNumber %d is a palindrome\n", iTemp);
  else
    printf("\nNumber %d is not a palindrome\n", iTemp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf36(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b9 <main+0x99>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
imul   $0xa,-0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x64>
mov    -0xc(%rbp),%esi
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11ec <main+0xcc>
mov    -0x10(%rbp),%esi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
mov    -0x10(%rbp),%esi
lea    0xed4(%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   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf74(%rip),%rdi
call   1030 <puts@plt>
lea    0xee8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
je     11c3 <main+0x93>
xor    %ebx,%ebx
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
lea    (%rbx,%rbx,4),%ecx
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rax
mov    %rax,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rax
add    %esi,%eax
lea    (%rax,%rax,1),%esi
lea    (%rsi,%rsi,4),%esi
mov    %edx,%edi
sub    %esi,%edi
lea    (%rdi,%rcx,2),%ebx
add    $0x9,%edx
cmp    $0x12,%edx
ja     1190 <main+0x60>
mov    %eax,0x4(%rsp)
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebp,%ebx
lea    0xe7f(%rip),%rax
lea    0xe94(%rip),%rdi
cmove  %rax,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [76 x i8] c"\0A**************************************************************************\00"
@.str.1 = [66 x i8] c"\0A*\09PROGRAM TO CHECK WHETHER AN INTEGER IS A PALINDROME OR NOT\09 *\0A\00"
@.str.2 = [75 x i8] c"**************************************************************************\00"
@.str.3 = [17 x i8] c"\0AEnter a number\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [15 x i8] c"\0AReverse is %d\00"
@.str.6 = [28 x i8] c"\0ANumber %d is a palindrome\0A\00"
@.str.7 = [32 x i8] c"\0ANumber %d is not a 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* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
store i32 %11, i32* %4
br label %12
12: ; preds = %15, %0
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %2
%17 = srem i32 %16, 10
store i32 %17, i32* %5
%18 = load i32, i32* %3
%19 = mul nsw i32 %18, 10
%20 = load i32, i32* %5
%21 = add nsw i32 %19, %20
store i32 %21, i32* %3
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 10
store i32 %23, i32* %2
br label %12
24: ; preds = %12
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %31)
br label %36
33: ; preds = %24
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [76 x i8] c"\0A**************************************************************************\00"
@.str.2 = [75 x i8] c"**************************************************************************\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [15 x i8] c"\0AReverse is %d\00"
@.str.6 = [28 x i8] c"\0ANumber %d is a palindrome\0A\00"
@.str.7 = [32 x i8] c"\0ANumber %d is not a palindrome\0A\00"
@str = [65 x i8] c"\0A*\09PROGRAM TO CHECK WHETHER AN INTEGER IS A PALINDROME OR NOT\09 *\00"
@str.8 = [16 x i8] c"\0AEnter a 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 ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %15, %10 ], [ 0, %0 ]
%12 = phi i32 [ %16, %10 ], [ %8, %0 ]
%13 = srem i32 %12, 10
%14 = mul nsw i32 %11, 10
%15 = add nsw i32 %14, %13
%16 = sdiv i32 %12, 10
%17 = add i32 %12, 9
%18 = icmp ult i32 %17, 19
br i1 %18, label %19, label %10
19: ; preds = %10
store i32 %16, i32* %1
br label %20
20: ; preds = %19, %0
%21 = phi i32 [ %15, %19 ], [ 0, %0 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = icmp eq i32 %21, %8
%24 = select i1 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, i32 %8)
ret i32 0
}