#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 number, sum = 0, temp, remainder;
  printf("Enter an integer\n");
  scanf("%d", &number);
  temp = number;
  while (temp != 0) {
    remainder = temp % 10;
    sum = sum + remainder * remainder * remainder;
    temp = temp / 10;
  }
  if (number == sum)
    printf("Entered number is an armstrong number.\n");
  else
    printf("Entered number is not an armstrong number.\n");
  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
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1196 <main+0x76>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x14(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    1158 <main+0x38>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11b3 <main+0x93>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    11bf <main+0x9f>
lea    0xe83(%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
test   %r8d,%r8d
je     119a <main+0x7a>
xor    %ecx,%ecx
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>
cmp    %ecx,%r8d
lea    0xeb2(%rip),%rax
lea    0xe80(%rip),%rdi
cmove  %rax,%rdi
jmp    11a1 <main+0x81>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter an integer\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [40 x i8] c"Entered number is an armstrong number.\0A\00"
@.str.3 = [44 x i8] c"Entered number is not an 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* %3
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 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* %4
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %9
%13 = load i32, i32* %4
%14 = srem i32 %13, 10
store i32 %14, i32* %5
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = load i32, i32* %5
%18 = mul nsw i32 %16, %17
%19 = load i32, i32* %5
%20 = mul nsw i32 %18, %19
%21 = add nsw i32 %15, %20
store i32 %21, i32* %3
%22 = load i32, i32* %4
%23 = sdiv i32 %22, 10
store i32 %23, i32* %4
br label %9
24: ; preds = %9
%25 = load i32, i32* %2
%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 ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 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 = [17 x i8] c"Enter an integer\00"
@str.4 = [43 x i8] c"Entered number is not an armstrong number.\00"
@str.5 = [39 x i8] c"Entered number is an 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 ([17 x i8], [17 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 %20, 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
%18 = icmp eq i32 %5, %13
%19 = select i1 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @str.4, i64 0, i64 0)
br label %20
20: ; preds = %17, %0
%21 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0), %0 ], [ %19, %17 ]
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}