#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, iDig, iSum = 0;
  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) {
    iDig = iNum % 10;
    iSum += iDig;
    iRev = iRev * 10 + iDig;
    iNum = iNum / 10;
  }
  printf("\nReversed number is %d", iRev);
  if (iRev == iTemp)
    printf("\nNumber %d is a palindrome\n", iTemp);
  else
    printf("\nNumber %d is not a palindrome\n", iTemp);
  printf("\nSum of digits of the given number is %d\n", iSum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11c9 <main+0xa9>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%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    118b <main+0x6b>
mov    -0xc(%rbp),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11fc <main+0xdc>
mov    -0x10(%rbp),%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <main+0xed>
mov    -0x10(%rbp),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xedb(%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   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf7a(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfa1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeeb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%r14d
mov    $0x0,%ebp
test   %r14d,%r14d
je     11d5 <main+0xa5>
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    %r14d,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %esi,%ebp
lea    (%rbx,%rbx,4),%edx
lea    (%rsi,%rdx,2),%ebx
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     11a0 <main+0x70>
mov    %eax,0xc(%rsp)
lea    0xe70(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r14d,%ebx
lea    0xe74(%rip),%rax
lea    0xe89(%rip),%rdi
cmove  %rax,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
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 = [23 x i8] c"\0AReversed number 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.8 = [42 x i8] c"\0ASum of digits of the given number is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
store i32 %12, i32* %4
br label %13
13: ; preds = %16, %0
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i32, i32* %2
%18 = srem i32 %17, 10
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %20, %19
store i32 %21, i32* %6
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, 10
%24 = load i32, i32* %5
%25 = add nsw i32 %23, %24
store i32 %25, i32* %3
%26 = load i32, i32* %2
%27 = sdiv i32 %26, 10
store i32 %27, i32* %2
br label %13
28: ; preds = %13
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %35)
br label %40
37: ; preds = %28
%38 = load i32, i32* %4
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %41)
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 = [23 x i8] c"\0AReversed number 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.8 = [42 x i8] c"\0ASum of digits of the given number is %d\0A\00"
@str = [65 x i8] c"\0A*\09PROGRAM TO CHECK WHETHER AN INTEGER IS A PALINDROME OR NOT\09 *\00"
@str.9 = [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.9, 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 %22, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %15, %10 ], [ 0, %0 ]
%12 = phi i32 [ %17, %10 ], [ 0, %0 ]
%13 = phi i32 [ %18, %10 ], [ %8, %0 ]
%14 = srem i32 %13, 10
%15 = add nsw i32 %11, %14
%16 = mul nsw i32 %12, 10
%17 = add nsw i32 %16, %14
%18 = sdiv i32 %13, 10
%19 = add i32 %13, 9
%20 = icmp ult i32 %19, 19
br i1 %20, label %21, label %10
21: ; preds = %10
store i32 %18, i32* %1
br label %22
22: ; preds = %21, %0
%23 = phi i32 [ %17, %21 ], [ 0, %0 ]
%24 = phi i32 [ %15, %21 ], [ 0, %0 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%26 = icmp eq i32 %23, %8
%27 = select i1 %26, 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)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %27, i32 %8)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %24)
ret i32 0
}