#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 *, long long *);
int main() {
  long long a[9], i, num;
  long long final_val = 1;
  scanf("%lld", &num);
  if (num == 0) {
    printf("10");
    return 0;
  }
  for (i = 0; i < 10; i++)
    a[i] = 0;
  while (num != 1) {
    for (i = 9; i > 1; i--) {
      if ((num % i) == 0) {
        a[i]++;
        num = num / i;
        break;
      }
    }
    if (i == 1) {
      printf("-1");
      return 0;
    }
  }
  i = 2;
  while (i != 10) {
    if (a[i] > 0) {
      if (final_val == 1)
        final_val = i;
      else
        final_val = final_val * 10 + i;
      a[i]--;
    } else
      i++;
  }
  printf("%lld\n", final_val);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x68(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x60(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x60(%rbp)
jne    116c <main+0x4c>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c2 <main+0x1a2>
movq   $0x0,-0x58(%rbp)
cmpq   $0xa,-0x58(%rbp)
jge    119d <main+0x7d>
mov    -0x58(%rbp),%rax
movq   $0x0,-0x50(%rbp,%rax,8)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1174 <main+0x54>
jmp    11a2 <main+0x82>
cmpq   $0x1,-0x60(%rbp)
je     1239 <main+0x119>
movq   $0x9,-0x58(%rbp)
cmpq   $0x1,-0x58(%rbp)
jle    120f <main+0xef>
mov    -0x60(%rbp),%rax
cqto
idivq  -0x58(%rbp)
cmp    $0x0,%rdx
jne    11f9 <main+0xd9>
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
add    $0x1,%rcx
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x60(%rbp),%rax
cqto
idivq  -0x58(%rbp)
mov    %rax,-0x60(%rbp)
jmp    120f <main+0xef>
jmp    11fe <main+0xde>
mov    -0x58(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x58(%rbp)
jmp    11b5 <main+0x95>
cmpq   $0x1,-0x58(%rbp)
jne    1234 <main+0x114>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c2 <main+0x1a2>
jmp    11a2 <main+0x82>
movq   $0x2,-0x58(%rbp)
cmpq   $0xa,-0x58(%rbp)
je     12a9 <main+0x189>
mov    -0x58(%rbp),%rax
cmpq   $0x0,-0x50(%rbp,%rax,8)
jle    1298 <main+0x178>
cmpq   $0x1,-0x68(%rbp)
jne    1274 <main+0x154>
mov    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    1281 <main+0x161>
imul   $0xa,-0x68(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x50(%rbp,%rax,8)
jmp    12a4 <main+0x184>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1241 <main+0x121>
mov    -0x68(%rbp),%rsi
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xecb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
test   %rax,%rax
je     11c6 <main+0xa6>
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
cmp    $0x1,%rax
jne    11e5 <main+0xc5>
mov    $0x2,%eax
mov    $0x1,%esi
xor    %ecx,%ecx
jmp    118a <main+0x6a>
nopl   0x0(%rax)
add    $0x1,%rax
cmp    $0xa,%rax
je     11b6 <main+0x96>
mov    0x10(%rsp,%rax,8),%rdx
test   %rdx,%rdx
jle    1180 <main+0x60>
lea    (%rsi,%rsi,1),%rdi
cmp    $0x1,%rsi
lea    (%rdi,%rdi,4),%rsi
cmove  %rcx,%rsi
add    %rax,%rsi
add    $0xffffffffffffffff,%rdx
mov    %rdx,0x10(%rsp,%rax,8)
cmp    $0xa,%rax
jne    118a <main+0x6a>
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x8e38e38e38e38e39,%rcx
e3 38 8e
movabs $0xe38e38e38e38e38,%rsi
e3 38 0e
movabs $0x1c71c71c71c71c71,%rdi
movabs $0x6db6db6db6db6db7,%r8
db b6 6d
movabs $0x1249249249249249,%r9
24 49 12
movabs $0x2492492492492493,%r10
49 92 24
movabs $0xaaaaaaaaaaaaaaab,%r11
aa aa aa
movabs $0x2aaaaaaaaaaaaaaa,%r14
aa aa 2a
movabs $0x2aaaaaaaaaaaaaab,%rbx
aa aa 2a
movabs $0xcccccccccccccccd,%r15
cc cc cc
movabs $0x1999999999999999,%r12
99 99 19
movabs $0x3333333333333333,%r13
33 33 33
jmp    1274 <main+0x154>
nop
cqto
idiv   %rbp
mov    %rax,0x8(%rsp)
cmp    $0x1,%rax
je     116b <main+0x4b>
mov    %rax,%rdx
imul   %rcx,%rdx
add    %rsi,%rdx
cmp    %rdi,%rdx
jb     12e0 <main+0x1c0>
test   $0x7,%al
je     12f0 <main+0x1d0>
mov    %rax,%rdx
imul   %r8,%rdx
add    %r9,%rdx
cmp    %r10,%rdx
jb     12f7 <main+0x1d7>
mov    %rax,%rdx
imul   %r11,%rdx
add    %r14,%rdx
mov    %rdx,%rbp
ror    %rbp
cmp    %rbx,%rbp
jb     12fe <main+0x1de>
mov    %rax,%rbp
imul   %r15,%rbp
add    %r12,%rbp
cmp    %r13,%rbp
jb     1305 <main+0x1e5>
test   $0x3,%al
je     130c <main+0x1ec>
movabs $0x5555555555555555,%rbp
55 55 55
cmp    %rbp,%rdx
jb     1313 <main+0x1f3>
mov    $0x2,%ebp
test   $0x1,%al
je     1320 <main+0x200>
jmp    133c <main+0x21c>
nopl   0x0(%rax,%rax,1)
mov    $0x9,%ebp
jmp    1320 <main+0x200>
nopw   0x0(%rax,%rax,1)
mov    $0x8,%ebp
jmp    1320 <main+0x200>
mov    $0x7,%ebp
jmp    1320 <main+0x200>
mov    $0x6,%ebp
jmp    1320 <main+0x200>
mov    $0x5,%ebp
jmp    1320 <main+0x200>
mov    $0x4,%ebp
jmp    1320 <main+0x200>
mov    $0x3,%ebp
nopl   0x0(%rax,%rax,1)
addq   $0x1,0x10(%rsp,%rbp,8)
mov    %rax,%rdx
shr    $0x20,%rdx
jne    1260 <main+0x140>
xor    %edx,%edx
div    %ebp
jmp    1265 <main+0x145>
lea    0xcc5(%rip),%rdi
jmp    11cd <main+0xad>

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [3 x i8] c"10\00"
@.str.2 = [3 x i8] c"-1\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i64]
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %4)
%7 = load i64, i64* %4
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %83
11: ; preds = %0
store i64 0, i64* %3
br label %12
12: ; preds = %18, %11
%13 = load i64, i64* %3
%14 = icmp slt i64 %13, 10
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i64, i64* %3
%17 = getelementptr inbounds [9 x i64], [9 x i64]* %2, i64 0, i64 %16
store i64 0, i64* %17
br label %18
18: ; preds = %15
%19 = load i64, i64* %3
%20 = add nsw i64 %19, 1
store i64 %20, i64* %3
br label %12
21: ; preds = %12
br label %22
22: ; preds = %51, %21
%23 = load i64, i64* %4
%24 = icmp ne i64 %23, 1
br i1 %24, label %25, label %52
25: ; preds = %22
store i64 9, i64* %3
br label %26
26: ; preds = %43, %25
%27 = load i64, i64* %3
%28 = icmp sgt i64 %27, 1
br i1 %28, label %29, label %46
29: ; preds = %26
%30 = load i64, i64* %4
%31 = load i64, i64* %3
%32 = srem i64 %30, %31
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %29
%35 = load i64, i64* %3
%36 = getelementptr inbounds [9 x i64], [9 x i64]* %2, i64 0, i64 %35
%37 = load i64, i64* %36
%38 = add nsw i64 %37, 1
store i64 %38, i64* %36
%39 = load i64, i64* %4
%40 = load i64, i64* %3
%41 = sdiv i64 %39, %40
store i64 %41, i64* %4
br label %46
42: ; preds = %29
br label %43
43: ; preds = %42
%44 = load i64, i64* %3
%45 = add nsw i64 %44, -1
store i64 %45, i64* %3
br label %26
46: ; preds = %34, %26
%47 = load i64, i64* %3
%48 = icmp eq i64 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %83
51: ; preds = %46
br label %22
52: ; preds = %22
store i64 2, i64* %3
br label %53
53: ; preds = %79, %52
%54 = load i64, i64* %3
%55 = icmp ne i64 %54, 10
br i1 %55, label %56, label %80
56: ; preds = %53
%57 = load i64, i64* %3
%58 = getelementptr inbounds [9 x i64], [9 x i64]* %2, i64 0, i64 %57
%59 = load i64, i64* %58
%60 = icmp sgt i64 %59, 0
br i1 %60, label %61, label %76
61: ; preds = %56
%62 = load i64, i64* %5
%63 = icmp eq i64 %62, 1
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = load i64, i64* %3
store i64 %65, i64* %5
br label %71
66: ; preds = %61
%67 = load i64, i64* %5
%68 = mul nsw i64 %67, 10
%69 = load i64, i64* %3
%70 = add nsw i64 %68, %69
store i64 %70, i64* %5
br label %71
71: ; preds = %66, %64
%72 = load i64, i64* %3
%73 = getelementptr inbounds [9 x i64], [9 x i64]* %2, i64 0, i64 %72
%74 = load i64, i64* %73
%75 = add nsw i64 %74, -1
store i64 %75, i64* %73
br label %79
76: ; preds = %56
%77 = load i64, i64* %3
%78 = add nsw i64 %77, 1
store i64 %78, i64* %3
br label %79
79: ; preds = %76, %71
br label %53
80: ; preds = %53
%81 = load i64, i64* %5
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %81)
store i32 0, i32* %1
br label %83
83: ; preds = %80, %49, %9
%84 = load i32, i32* %1
ret i32 %84
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [3 x i8] c"10\00"
@.str.2 = [3 x i8] c"-1\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca [9 x i64]
%2 = bitcast [9 x i64]* %1 to i8*
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%6 = load i64, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = icmp eq i64 %6, 1
br i1 %9, label %10, label %13
10: ; preds = %38, %8
br label %47
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %67
13: ; preds = %8, %38
%14 = phi i64 [ %43, %38 ], [ %6, %8 ]
%15 = srem i64 %14, 9
%16 = icmp eq i64 %15, 0
br i1 %16, label %38, label %17
17: ; preds = %13
%18 = and i64 %14, 7
%19 = icmp eq i64 %18, 0
br i1 %19, label %38, label %20
20: ; preds = %17
%21 = srem i64 %14, 7
%22 = icmp eq i64 %21, 0
br i1 %22, label %38, label %23
23: ; preds = %20
%24 = srem i64 %14, 6
%25 = icmp eq i64 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %23
%27 = srem i64 %14, 5
%28 = icmp eq i64 %27, 0
br i1 %28, label %38, label %29
29: ; preds = %26
%30 = and i64 %14, 3
%31 = icmp eq i64 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %29
%33 = srem i64 %14, 3
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = and i64 %14, 1
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %13, %17, %20, %23, %26, %29, %32, %35
%39 = phi i64 [ 9, %13 ], [ 8, %17 ], [ 7, %20 ], [ 6, %23 ], [ 5, %26 ], [ 4, %29 ], [ 3, %32 ], [ 2, %35 ]
%40 = getelementptr inbounds [9 x i64], [9 x i64]* %1, i64 0, i64 %39
%41 = load i64, i64* %40
%42 = add nsw i64 %41, 1
store i64 %42, i64* %40
%43 = sdiv i64 %14, %39
store i64 %43, i64* %3
%44 = icmp eq i64 %43, 1
br i1 %44, label %10, label %13
45: ; preds = %35
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %67
47: ; preds = %10, %61
%48 = phi i64 [ %63, %61 ], [ 1, %10 ]
%49 = phi i64 [ %62, %61 ], [ 2, %10 ]
%50 = getelementptr inbounds [9 x i64], [9 x i64]* %1, i64 0, i64 %49
%51 = load i64, i64* %50
%52 = icmp sgt i64 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %47
%54 = icmp eq i64 %48, 1
%55 = mul nsw i64 %48, 10
%56 = select i1 %54, i64 0, i64 %55
%57 = add nsw i64 %56, %49
%58 = add nsw i64 %51, -1
store i64 %58, i64* %50
br label %61
59: ; preds = %47
%60 = add nsw i64 %49, 1
br label %61
61: ; preds = %59, %53
%62 = phi i64 [ %49, %53 ], [ %60, %59 ]
%63 = phi i64 [ %57, %53 ], [ %48, %59 ]
%64 = icmp eq i64 %62, 10
br i1 %64, label %65, label %47
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %63)
br label %67
67: ; preds = %65, %45, %11
ret i32 0
}