#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 num, r, sum, temp;
  int ent;
  printf("introduzca un numero entero positivo: ");
  scanf("%d", &ent);
  if (ent >= 0)
    printf("los numeros Armstrong hasta ese numero son : ");
  for (num = 1; num <= ent; num++) {
    temp = num;
    sum = 0;
    while (temp != 0) {
      r = temp % 10;
      temp = temp / 10;
      sum = sum + (r * r * r);
    }
    if (sum == num)
      printf("%d ", num);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x18(%rbp)
jl     1165 <main+0x45>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11f3 <main+0xd3>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11c3 <main+0xa3>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    1185 <main+0x65>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11e0 <main+0xc0>
mov    -0x8(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <main+0xc5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
js     11da <main+0xba>
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%r8d
test   %r8d,%r8d
jle    11da <main+0xba>
mov    $0x1,%ebx
lea    0xee6(%rip),%r14
jmp    118a <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rbx),%eax
cmp    %r8d,%ebx
mov    %eax,%ebx
jge    11da <main+0xba>
mov    %ebx,%edx
xor    %ecx,%ecx
xchg   %ax,%ax
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     1190 <main+0x70>
cmp    %ebx,%ecx
jne    1180 <main+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%r8d
jmp    1180 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [39 x i8] c"introduzca un numero entero positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [46 x i8] c"los numeros Armstrong hasta ese numero son : \00"
@.str.3 = [4 x i8] c"%d \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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 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* %6)
%9 = load i32, i32* %6
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
store i32 1, i32* %2
br label %14
14: ; preds = %43, %13
%15 = load i32, i32* %2
%16 = load i32, i32* %6
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %46
18: ; preds = %14
%19 = load i32, i32* %2
store i32 %19, i32* %5
store i32 0, i32* %4
br label %20
20: ; preds = %23, %18
%21 = load i32, i32* %5
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %5
%25 = srem i32 %24, 10
store i32 %25, i32* %3
%26 = load i32, i32* %5
%27 = sdiv i32 %26, 10
store i32 %27, i32* %5
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = load i32, i32* %3
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %3
%33 = mul nsw i32 %31, %32
%34 = add nsw i32 %28, %33
store i32 %34, i32* %4
br label %20
35: ; preds = %20
%36 = load i32, i32* %4
%37 = load i32, i32* %2
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %39, %35
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %14
46: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"introduzca un numero entero positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [46 x i8] c"los numeros Armstrong hasta ese numero son : \00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 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 sgt i32 %5, -1
br i1 %6, label %7, label %33
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 1
br i1 %10, label %33, label %11
11: ; preds = %7, %29
%12 = phi i32 [ %30, %29 ], [ %9, %7 ]
%13 = phi i32 [ %31, %29 ], [ 1, %7 ]
br label %14
14: ; preds = %11, %14
%15 = phi i32 [ %13, %11 ], [ %18, %14 ]
%16 = phi i32 [ 0, %11 ], [ %21, %14 ]
%17 = srem i32 %15, 10
%18 = sdiv i32 %15, 10
%19 = mul nsw i32 %17, %17
%20 = mul nsw i32 %19, %17
%21 = add nsw i32 %20, %16
%22 = add i32 %15, 9
%23 = icmp ult i32 %22, 19
br i1 %23, label %24, label %14
24: ; preds = %14
%25 = icmp eq i32 %21, %13
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%28 = load i32, i32* %1
br label %29
29: ; preds = %24, %26
%30 = phi i32 [ %12, %24 ], [ %28, %26 ]
%31 = add nuw nsw i32 %13, 1
%32 = icmp slt i32 %13, %30
br i1 %32, label %11, label %33
33: ; preds = %29, %0, %7
ret i32 0
}