#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 */
long long pow(int, long long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long long *);
int main() {
  long long int n, p, count = 0, q;
  unsigned long long int k;
  scanf("%lld", &n);
  p = n;
  while (p) {
    count++;
    p = p / 10;
  }
  q = pow(10, count);
  k = n * n;
  k = k % q;
  if (k == n)
    printf("Given number is automorphic.\n");
  else
    printf("Given number is not automorphic.\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xeb2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118d <main+0x5d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    115f <main+0x2f>
mov    -0x20(%rbp),%rsi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11db <main+0xab>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xb7>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%rcx
xor    %esi,%esi
test   %rcx,%rcx
je     1185 <main+0x55>
movabs $0x6666666666666667,%rdi
66 66 66
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rsi
mov    %rcx,%rax
imul   %rdi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    $0x9,%rcx
cmp    $0x12,%rcx
mov    %rdx,%rcx
ja     1160 <main+0x30>
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %rax,%rcx
mov    (%rsp),%rsi
mov    %rsi,%rax
imul   %rsi,%rax
mov    %rcx,%rdx
or     %rax,%rdx
shr    $0x20,%rdx
je     11b0 <main+0x80>
xor    %edx,%edx
div    %rcx
jmp    11b4 <main+0x84>
xor    %edx,%edx
div    %ecx
cmp    %rsi,%rdx
lea    0xe68(%rip),%rax
lea    0xe40(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [30 x i8] c"Given number is automorphic.\0A\00"
@.str.2 = [34 x i8] c"Given number is not automorphic.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%8 = load i64, i64* %2
store i64 %8, i64* %3
br label %9
9: ; preds = %12, %0
%10 = load i64, i64* %3
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i64, i64* %4
%14 = add nsw i64 %13, 1
store i64 %14, i64* %4
%15 = load i64, i64* %3
%16 = sdiv i64 %15, 10
store i64 %16, i64* %3
br label %9
17: ; preds = %9
%18 = load i64, i64* %4
%19 = call i64 @pow(i32 10, i64 %18)
store i64 %19, i64* %5
%20 = load i64, i64* %2
%21 = load i64, i64* %2
%22 = mul nsw i64 %20, %21
store i64 %22, i64* %6
%23 = load i64, i64* %6
%24 = load i64, i64* %5
%25 = urem i64 %23, %24
store i64 %25, i64* %6
%26 = load i64, i64* %6
%27 = load i64, i64* %2
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %31
29: ; preds = %17
%30 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %33
31: ; preds = %17
%32 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@str = [33 x i8] c"Given number is not automorphic.\00"
@str.3 = [29 x i8] c"Given number is automorphic.\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = load i64, i64* %1
%5 = icmp eq i64 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %10, %6 ], [ %4, %0 ]
%8 = phi i64 [ %9, %6 ], [ 0, %0 ]
%9 = add nuw nsw i64 %8, 1
%10 = sdiv i64 %7, 10
%11 = add i64 %7, 9
%12 = icmp ult i64 %11, 19
br i1 %12, label %13, label %6
13: ; preds = %6, %0
%14 = phi i64 [ 0, %0 ], [ %9, %6 ]
%15 = call i64 @pow(i32 10, i64 %14)
%16 = load i64, i64* %1
%17 = mul nsw i64 %16, %16
%18 = urem i64 %17, %15
%19 = icmp eq i64 %18, %16
%20 = select i1 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
ret i32 0
}