#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 num_length(int /*<<< orphan*/);
int /*<<< orphan*/ pow(int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int a, n;
  int ndigits = 0;
  for (a = 1; a < 10; a++) {
    for (n = 1; n < 22; n++) {
      if (num_length(pow(a, n)) == n) {
        ndigits += 1;
      }
    }
  }
  printf("%d\n", ndigits);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11b9 <main+0x89>
movl   $0x1,-0x18(%rbp)
cmpl   $0x16,-0x18(%rbp)
jge    11a6 <main+0x76>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
cmp    -0x18(%rbp),%eax
jne    1193 <main+0x63>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1198 <main+0x68>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <main+0x35>
jmp    11ab <main+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
mov    -0x1c(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    $0x1,%ebp
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %esi,0x2c(%rsp)
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x30(%rsp)
mov    %ebp,%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x28(%rsp)
mov    %ebp,%edi
mov    $0x3,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x24(%rsp)
mov    %ebp,%edi
mov    $0x4,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x20(%rsp)
mov    %ebp,%edi
mov    $0x5,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x1c(%rsp)
mov    %ebp,%edi
mov    $0x6,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x18(%rsp)
mov    %ebp,%edi
mov    $0x7,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x14(%rsp)
mov    %ebp,%edi
mov    $0x8,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    $0x9,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0xc(%rsp)
mov    %ebp,%edi
mov    $0xa,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
mov    $0xb,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,%r12d
mov    %ebp,%edi
mov    $0xc,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,%r13d
mov    %ebp,%edi
mov    $0xd,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0xe,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,%r14d
mov    %ebp,%edi
mov    $0xf,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    %eax,%r15d
mov    %ebp,%edi
mov    $0x10,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
movd   %ebx,%xmm0
movd   %r14d,%xmm8
movd   %r15d,%xmm3
movd   %eax,%xmm9
movd   0xc(%rsp),%xmm1
movd   0x8(%rsp),%xmm10
movd   %r12d,%xmm6
movd   %r13d,%xmm11
movd   0x1c(%rsp),%xmm2
movd   0x18(%rsp),%xmm12
movd   0x14(%rsp),%xmm5
movd   0x10(%rsp),%xmm13
movd   0x30(%rsp),%xmm15
movd   0x28(%rsp),%xmm14
movd   0x24(%rsp),%xmm7
movd   0x20(%rsp),%xmm4
punpckldq %xmm8,%xmm0
punpckldq %xmm9,%xmm3
punpcklqdq %xmm3,%xmm0
punpckldq %xmm10,%xmm1
punpckldq %xmm11,%xmm6
punpcklqdq %xmm6,%xmm1
pcmpeqd 0xcf4(%rip),%xmm0
pcmpeqd 0xcdc(%rip),%xmm1
packssdw %xmm0,%xmm1
punpckldq %xmm12,%xmm2
punpckldq %xmm13,%xmm5
punpcklqdq %xmm5,%xmm2
punpckldq %xmm14,%xmm15
pcmpeqd 0xcad(%rip),%xmm2
punpckldq %xmm4,%xmm7
punpcklqdq %xmm7,%xmm15
pcmpeqd 0xc8b(%rip),%xmm15
packssdw %xmm2,%xmm15
packsswb %xmm1,%xmm15
movdqa %xmm15,0x30(%rsp)
mov    %ebp,%edi
mov    $0x11,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
xor    %r14d,%r14d
cmp    $0x11,%eax
sete   %r14b
mov    %ebp,%edi
mov    $0x12,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
xor    %r15d,%r15d
cmp    $0x12,%eax
sete   %r15b
mov    %ebp,%edi
mov    $0x13,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
xor    %r12d,%r12d
cmp    $0x13,%eax
sete   %r12b
mov    %ebp,%edi
mov    $0x14,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
xor    %ebx,%ebx
cmp    $0x14,%eax
sete   %bl
mov    %ebp,%edi
mov    $0x15,%esi
call   1050 <pow@plt>
mov    %eax,%edi
call   1040 <num_length@plt>
mov    0x2c(%rsp),%esi
xor    %ecx,%ecx
cmp    $0x15,%eax
sete   %cl
movdqa 0x30(%rsp),%xmm0
pmovmskb %xmm0,%eax
mov    %eax,%edx
shr    %edx
and    $0x5555,%edx
sub    %edx,%eax
mov    %eax,%edx
and    $0x3333,%edx
shr    $0x2,%eax
and    $0x3333,%eax
add    %edx,%eax
mov    %eax,%edx
shr    $0x4,%edx
add    %eax,%edx
and    $0xf0f,%edx
mov    %edx,%eax
shl    $0x8,%eax
add    %edx,%eax
movzbl %ah,%eax
add    %r14d,%eax
add    %r15d,%eax
add    %r12d,%eax
add    %ebx,%eax
add    %ecx,%eax
add    %eax,%esi
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    1150 <main+0x20>
lea    0xbc8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.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 i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 1, i32* %6
br label %9
9: ; preds = %31, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %34
12: ; preds = %9
store i32 1, i32* %7
br label %13
13: ; preds = %27, %12
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 22
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = call i32 @pow(i32 %17, i32 %18)
%20 = call i32 @num_length(i32 %19)
%21 = load i32, i32* %7
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %26
26: ; preds = %23, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %13
30: ; preds = %13
br label %31
31: ; preds = %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %9
34: ; preds = %9
%35 = load i32, i32* %8
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %83, %3 ]
%5 = phi i32 [ 1, %2 ], [ %84, %3 ]
%6 = tail call i32 @pow(i32 %5, i32 1)
%7 = tail call i32 @num_length(i32 %6)
%8 = tail call i32 @pow(i32 %5, i32 2)
%9 = tail call i32 @num_length(i32 %8)
%10 = tail call i32 @pow(i32 %5, i32 3)
%11 = tail call i32 @num_length(i32 %10)
%12 = tail call i32 @pow(i32 %5, i32 4)
%13 = tail call i32 @num_length(i32 %12)
%14 = tail call i32 @pow(i32 %5, i32 5)
%15 = tail call i32 @num_length(i32 %14)
%16 = tail call i32 @pow(i32 %5, i32 6)
%17 = tail call i32 @num_length(i32 %16)
%18 = tail call i32 @pow(i32 %5, i32 7)
%19 = tail call i32 @num_length(i32 %18)
%20 = tail call i32 @pow(i32 %5, i32 8)
%21 = tail call i32 @num_length(i32 %20)
%22 = tail call i32 @pow(i32 %5, i32 9)
%23 = tail call i32 @num_length(i32 %22)
%24 = tail call i32 @pow(i32 %5, i32 10)
%25 = tail call i32 @num_length(i32 %24)
%26 = tail call i32 @pow(i32 %5, i32 11)
%27 = tail call i32 @num_length(i32 %26)
%28 = tail call i32 @pow(i32 %5, i32 12)
%29 = tail call i32 @num_length(i32 %28)
%30 = tail call i32 @pow(i32 %5, i32 13)
%31 = tail call i32 @num_length(i32 %30)
%32 = tail call i32 @pow(i32 %5, i32 14)
%33 = tail call i32 @num_length(i32 %32)
%34 = tail call i32 @pow(i32 %5, i32 15)
%35 = tail call i32 @num_length(i32 %34)
%36 = tail call i32 @pow(i32 %5, i32 16)
%37 = tail call i32 @num_length(i32 %36)
%38 = insertelement <16 x i32> poison, i32 %7, i64 0
%39 = insertelement <16 x i32> %38, i32 %9, i64 1
%40 = insertelement <16 x i32> %39, i32 %11, i64 2
%41 = insertelement <16 x i32> %40, i32 %13, i64 3
%42 = insertelement <16 x i32> %41, i32 %15, i64 4
%43 = insertelement <16 x i32> %42, i32 %17, i64 5
%44 = insertelement <16 x i32> %43, i32 %19, i64 6
%45 = insertelement <16 x i32> %44, i32 %21, i64 7
%46 = insertelement <16 x i32> %45, i32 %23, i64 8
%47 = insertelement <16 x i32> %46, i32 %25, i64 9
%48 = insertelement <16 x i32> %47, i32 %27, i64 10
%49 = insertelement <16 x i32> %48, i32 %29, i64 11
%50 = insertelement <16 x i32> %49, i32 %31, i64 12
%51 = insertelement <16 x i32> %50, i32 %33, i64 13
%52 = insertelement <16 x i32> %51, i32 %35, i64 14
%53 = insertelement <16 x i32> %52, i32 %37, i64 15
%54 = icmp eq <16 x i32> %53, <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>
%55 = tail call i32 @pow(i32 %5, i32 17)
%56 = tail call i32 @num_length(i32 %55)
%57 = icmp eq i32 %56, 17
%58 = zext i1 %57 to i32
%59 = tail call i32 @pow(i32 %5, i32 18)
%60 = tail call i32 @num_length(i32 %59)
%61 = icmp eq i32 %60, 18
%62 = zext i1 %61 to i32
%63 = tail call i32 @pow(i32 %5, i32 19)
%64 = tail call i32 @num_length(i32 %63)
%65 = icmp eq i32 %64, 19
%66 = zext i1 %65 to i32
%67 = tail call i32 @pow(i32 %5, i32 20)
%68 = tail call i32 @num_length(i32 %67)
%69 = icmp eq i32 %68, 20
%70 = zext i1 %69 to i32
%71 = tail call i32 @pow(i32 %5, i32 21)
%72 = tail call i32 @num_length(i32 %71)
%73 = icmp eq i32 %72, 21
%74 = zext i1 %73 to i32
%75 = bitcast <16 x i1> %54 to i16
%76 = call i16 @llvm.ctpop.i16(i16 %75)
%77 = zext i16 %76 to i32
%78 = add nuw nsw i32 %77, %58
%79 = add nuw nsw i32 %78, %62
%80 = add nuw nsw i32 %79, %66
%81 = add nuw nsw i32 %80, %70
%82 = add nuw nsw i32 %81, %74
%83 = add nsw i32 %82, %4
%84 = add nuw nsw i32 %5, 1
%85 = icmp eq i32 %84, 10
br i1 %85, label %86, label %3
86: ; preds = %3
%87 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %83)
ret i32 0
}