#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() {
  int iNum, iNum2, iSum = 0, iDig;
  printf("\nEnter a number\n");
  scanf("%d", &iNum);
  iNum2 = iNum;
  while (iNum) {
    iDig = iNum % 10;
    iSum += iDig * iDig * iDig;
    iNum = iNum / 10;
  }
  if (iSum == iNum2)
    printf("\nGiven number is a Armstrong Number\n");
  else
    printf("\nGiven number is not a Armstrong Number\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1194 <main+0x74>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1158 <main+0x38>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11b1 <main+0x91>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    11bd <main+0x9d>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r8d
xor    %ecx,%ecx
test   %r8d,%r8d
je     1187 <main+0x67>
mov    %r8d,%edx
nopl   (%rax)
movslq %edx,%rsi
imul   $0x66666667,%rsi,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x22,%rdx
add    %edi,%edx
lea    (%rdx,%rdx,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %esi,%eax
sub    %edi,%eax
mov    %eax,%edi
imul   %eax,%edi
imul   %eax,%edi
add    %edi,%ecx
add    $0x9,%esi
cmp    $0x12,%esi
ja     1150 <main+0x30>
mov    %edx,0x4(%rsp)
cmp    %r8d,%ecx
lea    0xeaa(%rip),%rax
lea    0xe7b(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0AEnter a number\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"\0AGiven number is a Armstrong Number\0A\00"
@.str.3 = [41 x i8] c"\0AGiven number is not a Armstrong Number\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* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 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* %3
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %2
%14 = srem i32 %13, 10
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = load i32, i32* %5
%17 = mul nsw i32 %15, %16
%18 = load i32, i32* %5
%19 = mul nsw i32 %17, %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 10
store i32 %23, i32* %2
br label %9
24: ; preds = %9
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [16 x i8] c"\0AEnter a number\00"
@str.4 = [40 x i8] c"\0AGiven number is not a Armstrong Number\00"
@str.5 = [36 x i8] c"\0AGiven number is a Armstrong Number\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 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 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %13, %7 ], [ 0, %0 ]
%9 = phi i32 [ %14, %7 ], [ %5, %0 ]
%10 = srem i32 %9, 10
%11 = mul nsw i32 %10, %10
%12 = mul nsw i32 %11, %10
%13 = add nsw i32 %12, %8
%14 = sdiv i32 %9, 10
%15 = add i32 %9, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %17, label %7
17: ; preds = %7
store i32 %14, i32* %1
br label %18
18: ; preds = %17, %0
%19 = phi i32 [ %13, %17 ], [ 0, %0 ]
%20 = icmp eq i32 %19, %5
%21 = select i1 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @str.4, i64 0, i64 0)
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}