#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 */
scalar_t__ isarmstrong(long);
int printf(char *, ...);
int scanf(char *, long *);
int main(void) {
  long int num, i;
  int j;
  j = printf("Enter the number : ");
  j = scanf("%ld", &num);
  j = printf("The armstrong number upto %d are\n", num);
  for (i = 1; i <= num; ++i)
    if (isarmstrong(i))
      j = printf("%ld\n", i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0x1c(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0x1c(%rbp)
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11cc <main+0x9c>
mov    -0x18(%rbp),%rdi
call   1030 <isarmstrong@plt>
cmp    $0x0,%rax
je     11b6 <main+0x86>
mov    -0x18(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %eax,-0x1c(%rbp)
jmp    11bb <main+0x8b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%rsi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpq   $0x0,(%rsp)
jle    11a6 <main+0x76>
lea    0xec9(%rip),%r14
xor    %ebx,%ebx
jmp    1186 <main+0x56>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    (%rsp),%rbx
jge    11a6 <main+0x76>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <isarmstrong@plt>
test   %rax,%rax
je     1180 <main+0x50>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter the number : \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [34 x i8] c"The armstrong number upto %d are\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
store i32 %6, i32* %4
%7 = load i64, i64* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 %7)
store i32 %8, i32* %4
store i64 1, i64* %3
br label %9
9: ; preds = %21, %0
%10 = load i64, i64* %3
%11 = load i64, i64* %2
%12 = icmp sle i64 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i64, i64* %3
%15 = call i64 @isarmstrong(i64 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i64, i64* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %18)
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %13
br label %21
21: ; preds = %20
%22 = load i64, i64* %3
%23 = add nsw i64 %22, 1
store i64 %23, i64* %3
br label %9
24: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter the number : \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [34 x i8] c"The armstrong number upto %d are\0A\00"
@.str.3 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 %5)
%7 = load i64, i64* %1
%8 = icmp slt i64 %7, 1
br i1 %8, label %19, label %9
9: ; preds = %0, %15
%10 = phi i64 [ %16, %15 ], [ 1, %0 ]
%11 = call i64 @isarmstrong(i64 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %10)
br label %15
15: ; preds = %9, %13
%16 = add nuw nsw i64 %10, 1
%17 = load i64, i64* %1
%18 = icmp slt i64 %10, %17
br i1 %18, label %9, label %19
19: ; preds = %15, %0
ret i32 0
}