#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__ pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int lower, upper, i, temp1, temp2, rem, num = 0;
  float sum_pow = 0.0;
  printf("Enter lower range: ");
  scanf("%d", &lower);
  printf("Enter upper range: ");
  scanf("%d", &upper);
  printf("Armstrong numbers between %d and %d are: ", lower, upper);
  for (i = lower; i <= upper; ++i) {
    temp1 = i;
    temp2 = i;
    while (temp1 != 0) {
      temp1 /= 10;
      ++num;
    }
    while (temp2 != 0) {
      rem = temp2 % 10;
      sum_pow += pow(rem, num);
      temp2 /= 10;
    }
    if ((int)sum_pow == i) {
      printf("%d ", i);
    }
    num = 0;
    sum_pow = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1268 <main+0x138>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11e2 <main+0xb2>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11bc <main+0x8c>
jmp    11e7 <main+0xb7>
cmpl   $0x0,-0x18(%rbp)
je     122c <main+0xfc>
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <pow@plt>
cvtsi2ss %rax,%xmm0
addss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    11e7 <main+0xb7>
cvttss2si -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    124b <main+0x11b>
mov    -0x10(%rbp),%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a4 <main+0x74>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec3(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%r15d
cmp    0x8(%rsp),%r15d
jle    11aa <main+0x7a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea4(%rip),%r14
jmp    11ce <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x1(%r15),%eax
cmp    0x8(%rsp),%r15d
mov    %eax,%r15d
jge    119b <main+0x6b>
xorps  %xmm0,%xmm0
test   %r15d,%r15d
je     1265 <main+0x135>
xor    %r12d,%r12d
mov    %r15d,%eax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    $0x1,%r12d
add    $0x9,%ecx
cmp    $0x13,%ecx
jae    11e0 <main+0xb0>
test   %r15d,%r15d
je     1265 <main+0x135>
xorps  %xmm0,%xmm0
mov    %r15d,%ebx
xchg   %ax,%ax
movss  %xmm0,0x4(%rsp)
movslq %ebx,%rbp
imul   $0x66666667,%rbp,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%edi
sub    %eax,%edi
mov    %r12d,%esi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
add    $0x9,%ebp
cmp    $0x12,%ebp
ja     1210 <main+0xe0>
cvttss2si %xmm0,%eax
cmp    %eax,%r15d
jne    11c0 <main+0x90>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c0 <main+0x90>

LLVM IR (-O0):
@.str = [20 x i8] c"Enter lower range: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter upper range: \00"
@.str.3 = [42 x i8] c"Armstrong numbers between %d and %d are: \00"
@.str.4 = [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
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i32 0, i32* %1
store i32 0, i32* %8
store float 0.000000e+00, float* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %15)
%17 = load i32, i32* %2
store i32 %17, i32* %4
br label %18
18: ; preds = %57, %0
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %60
22: ; preds = %18
%23 = load i32, i32* %4
store i32 %23, i32* %5
%24 = load i32, i32* %4
store i32 %24, i32* %6
br label %25
25: ; preds = %28, %22
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %5
%30 = sdiv i32 %29, 10
store i32 %30, i32* %5
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %25
33: ; preds = %25
br label %34
34: ; preds = %37, %33
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = load i32, i32* %6
%39 = srem i32 %38, 10
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = load i32, i32* %8
%42 = call i64 @pow(i32 %40, i32 %41)
%43 = sitofp i64 %42 to float
%44 = load float, float* %9
%45 = fadd float %44, %43
store float %45, float* %9
%46 = load i32, i32* %6
%47 = sdiv i32 %46, 10
store i32 %47, i32* %6
br label %34
48: ; preds = %34
%49 = load float, float* %9
%50 = fptosi float %49 to i32
%51 = load i32, i32* %4
%52 = icmp eq i32 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i32, i32* %4
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %48
store i32 0, i32* %8
store float 0.000000e+00, float* %9
br label %57
57: ; preds = %56
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %18
60: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter lower range: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Enter upper range: \00"
@.str.3 = [42 x i8] c"Armstrong numbers between %d and %d are: \00"
@.str.4 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, 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* %1
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = icmp sgt i32 %12, %13
br i1 %14, label %46, label %15
15: ; preds = %0, %42
%16 = phi i32 [ %43, %42 ], [ %12, %0 ]
%17 = icmp eq i32 %16, 0
br i1 %17, label %36, label %19
18: ; preds = %19
br i1 %17, label %36, label %26
19: ; preds = %15, %19
%20 = phi i32 [ %23, %19 ], [ 0, %15 ]
%21 = phi i32 [ %22, %19 ], [ %16, %15 ]
%22 = sdiv i32 %21, 10
%23 = add nuw nsw i32 %20, 1
%24 = add i32 %21, 9
%25 = icmp ult i32 %24, 19
br i1 %25, label %18, label %19
26: ; preds = %18, %26
%27 = phi float [ %32, %26 ], [ 0.000000e+00, %18 ]
%28 = phi i32 [ %33, %26 ], [ %16, %18 ]
%29 = srem i32 %28, 10
%30 = call i64 @pow(i32 %29, i32 %23)
%31 = sitofp i64 %30 to float
%32 = fadd float %27, %31
%33 = sdiv i32 %28, 10
%34 = add i32 %28, 9
%35 = icmp ult i32 %34, 19
br i1 %35, label %36, label %26
36: ; preds = %26, %15, %18
%37 = phi float [ 0.000000e+00, %18 ], [ 0.000000e+00, %15 ], [ %32, %26 ]
%38 = fptosi float %37 to i32
%39 = icmp eq i32 %16, %38
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %16)
br label %42
42: ; preds = %40, %36
%43 = add nsw i32 %16, 1
%44 = load i32, i32* %2
%45 = icmp slt i32 %16, %44
br i1 %45, label %15, label %46
46: ; preds = %42, %0
ret i32 0
}