#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 input, temp, sum = 0, remainder;
  printf("Enter a number to test amrstrong-ility: ");
  scanf("%d", &input);
  temp = input;
  while (temp != 0) {
    remainder = temp % 10;
    sum += remainder * remainder * remainder;
    temp = temp / 10;
  }
  int isArmStrong = sum == input;
  if (isArmStrong) {
    printf("%d is armstrong number\n", input);
  } else {
    printf("%d is not armstrong number\n", input);
  }
  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
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1196 <main+0x76>
mov    -0xc(%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    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    115a <main+0x3a>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11c7 <main+0xa7>
mov    -0x8(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <main+0xb8>
mov    -0x8(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1193 <main+0x73>
xor    %ebx,%ebx
mov    %esi,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
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,%edi
sub    %edx,%edi
mov    %edi,%edx
imul   %edi,%edx
imul   %edi,%edx
add    %edx,%ebx
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1160 <main+0x40>
cmp    %esi,%ebx
lea    0xe90(%rip),%rax
lea    0xea1(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter a number to test amrstrong-ility: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"%d is armstrong number\0A\00"
@.str.3 = [28 x i8] c"%d is not armstrong number\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* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
store i32 %9, i32* %3
br label %10
10: ; preds = %13, %0
%11 = load i32, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i32, i32* %3
%15 = srem i32 %14, 10
store i32 %15, i32* %5
%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 = load i32, i32* %4
%22 = add nsw i32 %21, %20
store i32 %22, i32* %4
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 10
store i32 %24, i32* %3
br label %10
25: ; preds = %10
%26 = load i32, i32* %4
%27 = load i32, i32* %2
%28 = icmp eq i32 %26, %27
%29 = zext i1 %28 to i32
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %38
35: ; preds = %25
%36 = load i32, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35, %32
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter a number to test amrstrong-ility: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"%d is armstrong number\0A\00"
@.str.3 = [28 x i8] c"%d is not armstrong number\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 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 %17, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %14, %7 ], [ %5, %0 ]
%9 = phi i32 [ %13, %7 ], [ 0, %0 ]
%10 = srem i32 %8, 10
%11 = mul nsw i32 %10, %10
%12 = mul nsw i32 %11, %10
%13 = add nsw i32 %12, %9
%14 = sdiv i32 %8, 10
%15 = add i32 %8, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %17, label %7
17: ; preds = %7, %0
%18 = phi i32 [ 0, %0 ], [ %13, %7 ]
%19 = icmp eq i32 %18, %5
%20 = select i1 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %20, i32 %5)
ret i32 0
}