#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);
int main(int argc, const char *argv[]) {
  int fac[10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
  int i;
  int sum = 0;
  ;
  int tempi;
  int tempsum;
  for (i = 10; i < 9999999; i++) {
    tempsum = 0;
    tempi = i;
    while (tempi > 0) {
      tempsum += fac[tempi % 10];
      tempi /= 10;
    }
    if (tempsum == i) {
      sum += i;
    }
  }
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x48(%rbp)
movl   $0xa,-0x44(%rbp)
cmpl   $0x98967f,-0x44(%rbp)
jge    11d0 <main+0xb0>
movl   $0x0,-0x50(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jle    11a8 <main+0x88>
mov    -0x4c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x40(%rbp,%rax,4),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
jmp    1173 <main+0x53>
mov    -0x50(%rbp),%eax
cmp    -0x44(%rbp),%eax
jne    11bd <main+0x9d>
mov    -0x44(%rbp),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1159 <main+0x39>
mov    -0x48(%rbp),%esi
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%r8d
xor    %esi,%esi
mov    $0xcccccccd,%r9d
lea    0xeda(%rip),%r10
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r8d,%eax
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ecx
imul   %r9,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%r11d
mov    %eax,%edx
sub    %r11d,%edx
add    (%r10,%rdx,4),%edi
cmp    $0x9,%eax
mov    %ecx,%eax
ja     1140 <main+0x30>
cmp    %r8d,%edi
mov    $0x0,%eax
cmove  %r8d,%eax
add    %eax,%esi
add    $0x1,%r8d
cmp    $0x98967f,%r8d
jne    1130 <main+0x20>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.fac = [10 x i32] [i32 1, i32 1, i32 2, i32 6, i32 24, i32 120, i32 720, i32 5040, i32 40320, i32 362880]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [10 x i32]* %6 to i8*
store i32 0, i32* %8
store i32 10, i32* %7
br label %12
12: ; preds = %39, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 9999999
br i1 %14, label %15, label %42
15: ; preds = %12
store i32 0, i32* %10
%16 = load i32, i32* %7
store i32 %16, i32* %9
br label %17
17: ; preds = %20, %15
%18 = load i32, i32* %9
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i32, i32* %9
%22 = srem i32 %21, 10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %10
%27 = add nsw i32 %26, %25
store i32 %27, i32* %10
%28 = load i32, i32* %9
%29 = sdiv i32 %28, 10
store i32 %29, i32* %9
br label %17
30: ; preds = %17
%31 = load i32, i32* %10
%32 = load i32, i32* %7
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = add nsw i32 %36, %35
store i32 %37, i32* %8
br label %38
38: ; preds = %34, %30
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %12
42: ; preds = %12
%43 = load i32, i32* %8
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
ret i32 0
}

LLVM IR (-O2):
@__const.main.fac = [10 x i32] [i32 1, i32 1, i32 2, i32 6, i32 24, i32 120, i32 720, i32 5040, i32 40320, i32 362880]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %16
%4 = phi i32 [ 0, %2 ], [ %19, %16 ]
%5 = phi i32 [ 10, %2 ], [ %20, %16 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %13, %6 ]
%8 = phi i32 [ %5, %3 ], [ %14, %6 ]
%9 = urem i32 %8, 10
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds [10 x i32], [10 x i32]* @__const.main.fac, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = add nsw i32 %12, %7
%14 = udiv i32 %8, 10
%15 = icmp ult i32 %8, 10
br i1 %15, label %16, label %6
16: ; preds = %6
%17 = icmp eq i32 %13, %5
%18 = select i1 %17, i32 %5, i32 0
%19 = add nuw nsw i32 %18, %4
%20 = add nuw nsw i32 %5, 1
%21 = icmp eq i32 %20, 9999999
br i1 %21, label %22, label %3
22: ; preds = %16
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}