#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);
int rs(int m, int n) {
  int i;
  int total = 0;
  int temp = m;
  do {
    i = temp % 10;
    total += (int)(pow(i, n));
    temp = temp / 10;
  } while (temp);
  if (total == m) {
    printf("%d ", m);
  }
  return 0;
}


x86 assembly (clang, -O0):
<rs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <pow@plt>
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    113b <rs+0x1b>
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    118d <rs+0x6d>
mov    -0x4(%rbp),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rs>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r14d
xor    %r12d,%r12d
mov    %edi,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %ebp,%rbx
imul   $0x66666667,%rbx,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x22,%rbp
add    %eax,%ebp
lea    0x0(%rbp,%rbp,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%edi
sub    %eax,%edi
mov    %r15d,%esi
call   1040 <pow@plt>
add    %eax,%r12d
add    $0x9,%ebx
cmp    $0x12,%ebx
ja     1140 <rs+0x20>
cmp    %r14d,%r12d
jne    1189 <rs+0x69>
lea    0xe7f(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define i32 @rs(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %6
%8 = load i32, i32* %3
store i32 %8, i32* %7
br label %9
9: ; preds = %20, %2
%10 = load i32, i32* %7
%11 = srem i32 %10, 10
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = call i64 @pow(i32 %12, i32 %13)
%15 = trunc i64 %14 to i32
%16 = load i32, i32* %6
%17 = add nsw i32 %16, %15
store i32 %17, i32* %6
%18 = load i32, i32* %7
%19 = sdiv i32 %18, 10
store i32 %19, i32* %7
br label %20
20: ; preds = %9
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
br i1 %22, label %9, label %23
23: ; preds = %20
%24 = load i32, i32* %6
%25 = load i32, i32* %3
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* %3
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @rs(i32 %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %9, %3 ]
%5 = phi i32 [ %0, %2 ], [ %10, %3 ]
%6 = srem i32 %5, 10
%7 = tail call i64 @pow(i32 %6, i32 %1)
%8 = trunc i64 %7 to i32
%9 = add nsw i32 %4, %8
%10 = sdiv i32 %5, 10
%11 = add i32 %5, 9
%12 = icmp ult i32 %11, 19
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = icmp eq i32 %9, %0
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %17
17: ; preds = %15, %13
ret i32 0
}