#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *mpz_get_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_ui_pow_ui(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
int main(int argc, char **argv) {
  char *s;
  mpz_t x;
  int a, b, f, m;
  m = 0;
  f = 1;
  b = 1;
  mpz_init(x);
  while (f > 0) {
    a = f;
    f = -1;
    while (1) {
      mpz_ui_pow_ui(x, a, b);
      s = mpz_get_str(NULL, 10, x);
      if (strlen(s) > b)
        break;
      if (strlen(s) == b) {
        if (f < 0)
          f = a;
        m++;
      }
      free(s);
      a++;
    }
    b++;
  }
  printf("%d\n", m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <mpz_init@plt>
cmpl   $0x0,-0x28(%rbp)
jle    1234 <main+0xd4>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0xffffffff,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <mpz_ui_pow_ui@plt>
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1070 <mpz_get_str@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x24(%rbp),%eax
jle    11e4 <main+0x84>
jmp    1226 <main+0xc6>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x24(%rbp),%eax
jne    120f <main+0xaf>
cmpl   $0x0,-0x28(%rbp)
jge    1206 <main+0xa6>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11aa <main+0x4a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1193 <main+0x33>
mov    -0x2c(%rbp),%esi
lea    0xdc2(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1060 <mpz_init@plt>
mov    $0x1,%r12d
xor    %r15d,%r15d
mov    $0x1,%r14d
nop
mov    %r12d,%esi
mov    %r14d,%edx
call   1080 <mpz_ui_pow_ui@plt>
xor    %edi,%edi
mov    $0xa,%esi
call   1070 <mpz_get_str@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cmp    %r14d,%eax
jg     1212 <main+0xb2>
mov    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    %ebp,%r13d
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %ebp,%ebp
cmovs  %r12d,%ebp
xor    %ecx,%ecx
cmp    %r14d,%eax
sete   %cl
cmovne %r13d,%ebp
add    %ecx,%r15d
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x1,%r12d
mov    %r12d,%esi
mov    %r14d,%edx
call   1080 <mpz_ui_pow_ui@plt>
xor    %edi,%edi
mov    $0xa,%esi
call   1070 <mpz_get_str@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cmp    %r14d,%eax
jle    11b0 <main+0x50>
add    $0x1,%r14d
mov    %ebp,%r12d
test   %ebp,%ebp
jg     1180 <main+0x20>
lea    0xde7(%rip),%rdi
mov    %r15d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%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 i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
store i32 1, i32* %10
store i32 1, i32* %9
%12 = load i32, i32* %7
%13 = call i32 @mpz_init(i32 %12)
br label %14
14: ; preds = %49, %2
%15 = load i32, i32* %10
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %52
17: ; preds = %14
%18 = load i32, i32* %10
store i32 %18, i32* %8
store i32 -1, i32* %10
br label %19
19: ; preds = %17, %44
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = call i32 @mpz_ui_pow_ui(i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %7
%25 = call i8* @mpz_get_str(i32* null, i32 10, i32 %24)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 @strlen(i8* %26)
%28 = load i32, i32* %9
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %19
br label %49
31: ; preds = %19
%32 = load i8*, i8** %6
%33 = call i32 @strlen(i8* %32)
%34 = load i32, i32* %9
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = load i32, i32* %10
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = load i32, i32* %8
store i32 %40, i32* %10
br label %41
41: ; preds = %39, %36
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %44
44: ; preds = %41, %31
%45 = load i8*, i8** %6
%46 = call i32 @free(i8* %45)
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %19
49: ; preds = %30
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %14
52: ; preds = %14
%53 = load i32, i32* %11
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mpz_init(i32 undef)
br label %4
4: ; preds = %2, %30
%5 = phi i32 [ 0, %2 ], [ %23, %30 ]
%6 = phi i32 [ 1, %2 ], [ %21, %30 ]
%7 = phi i32 [ 1, %2 ], [ %31, %30 ]
%8 = tail call i32 @mpz_ui_pow_ui(i32 undef, i32 %6, i32 %7)
%9 = tail call i8* @mpz_get_str(i32* null, i32 10, i32 undef)
%10 = tail call i32 @strlen(i8* %9)
%11 = icmp sgt i32 %10, %7
br i1 %11, label %33, label %12
12: ; preds = %4, %12
%13 = phi i8* [ %27, %12 ], [ %9, %4 ]
%14 = phi i32 [ %23, %12 ], [ %5, %4 ]
%15 = phi i32 [ %21, %12 ], [ -1, %4 ]
%16 = phi i32 [ %25, %12 ], [ %6, %4 ]
%17 = tail call i32 @strlen(i8* %13)
%18 = icmp eq i32 %17, %7
%19 = icmp slt i32 %15, 0
%20 = select i1 %18, i1 %19, i1 false
%21 = select i1 %20, i32 %16, i32 %15
%22 = zext i1 %18 to i32
%23 = add nsw i32 %14, %22
%24 = tail call i32 @free(i8* %13)
%25 = add nsw i32 %16, 1
%26 = tail call i32 @mpz_ui_pow_ui(i32 undef, i32 %25, i32 %7)
%27 = tail call i8* @mpz_get_str(i32* null, i32 10, i32 undef)
%28 = tail call i32 @strlen(i8* %27)
%29 = icmp sgt i32 %28, %7
br i1 %29, label %30, label %12
30: ; preds = %12
%31 = add nuw nsw i32 %7, 1
%32 = icmp sgt i32 %21, 0
br i1 %32, label %4, label %33
33: ; preds = %4, %30
%34 = phi i32 [ %23, %30 ], [ %5, %4 ]
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}