#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 *);
void palindromicNumber() {
  printf("--------------------------------\n");
  printf("PALINDROME OF A NUMBER\n");
  int number, reverse = 0, temp;
  printf("Enter the number to check: ");
  scanf("%d", &number);
  printf("You entered: %d\n", number);
  temp = number;
  while (temp != 0) {
    reverse = reverse * 10;
    reverse = reverse + temp % 10;
    temp = temp / 10;
  }
  printf("The reverse of %d is %d", number, reverse);
  if (number == reverse) {
    printf(" and it is a palindrome.\n");
  } else {
    printf(" and it is NOT a palindrome.\n");
  }
}


x86 assembly (clang, -O0):
<palindromicNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11bd <palindromicNumber+0x9d>
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1180 <palindromicNumber+0x60>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11f0 <palindromicNumber+0xd0>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fe <palindromicNumber+0xde>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindromicNumber>:
push   %rbx
sub    $0x10,%rsp
lea    0xf09(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11bf <palindromicNumber+0x8f>
xor    %ebx,%ebx
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     1190 <palindromicNumber+0x60>
lea    0xe67(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,0xc(%rsp)
lea    0xec0(%rip),%rax
lea    0xe9c(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"--------------------------------\0A\00"
@.str.1 = [24 x i8] c"PALINDROME OF A NUMBER\0A\00"
@.str.2 = [28 x i8] c"Enter the number to check: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [17 x i8] c"You entered: %d\0A\00"
@.str.5 = [24 x i8] c"The reverse of %d is %d\00"
@.str.6 = [26 x i8] c" and it is a palindrome.\0A\00"
@.str.7 = [30 x i8] c" and it is NOT a palindrome.\0A\00"
define void @palindromicNumber() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
store i32 %10, i32* %3
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %2
%16 = mul nsw i32 %15, 10
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = srem i32 %18, 10
%20 = add nsw i32 %17, %19
store i32 %20, i32* %2
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 10
store i32 %22, i32* %3
br label %11
23: ; preds = %11
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %34
32: ; preds = %23
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
ret void
}

LLVM IR (-O2):
@.str.2 = [28 x i8] c"Enter the number to check: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [17 x i8] c"You entered: %d\0A\00"
@.str.5 = [24 x i8] c"The reverse of %d is %d\00"
@str = [33 x i8] c"--------------------------------\00"
@str.8 = [23 x i8] c"PALINDROME OF A NUMBER\00"
@str.9 = [29 x i8] c" and it is NOT a palindrome.\00"
@str.10 = [25 x i8] c" and it is a palindrome.\00"
define void @palindromicNumber() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %0, %11
%12 = phi i32 [ %17, %11 ], [ %9, %0 ]
%13 = phi i32 [ %16, %11 ], [ 0, %0 ]
%14 = mul nsw i32 %13, 10
%15 = srem i32 %12, 10
%16 = add nsw i32 %15, %14
%17 = sdiv i32 %12, 10
%18 = add i32 %12, 9
%19 = icmp ult i32 %18, 19
br i1 %19, label %20, label %11
20: ; preds = %11, %0
%21 = phi i32 [ 0, %0 ], [ %16, %11 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %9, i32 %21)
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, %21
%25 = select i1 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0)
%26 = call i32 @puts(i8* dereferenceable(1) %25)
ret void
}