#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 countUnique(char *);
int /*<<< orphan*/ printf(char *, int, char *, char *);
int strlen(char *);
int /*<<< orphan*/ toBaseN(char *, long long, int);
void find(int base) {
  char nBuf[32];
  char sqBuf[32];
  long long n, s;
  for (n = 2;; n++) {
    s = n * n;
    toBaseN(sqBuf, s, base);
    if (strlen(sqBuf) >= base && countUnique(sqBuf) == base) {
      toBaseN(nBuf, n, base);
      toBaseN(sqBuf, s, base);
      printf("Base %d : Num %8s Square %16s\n", base, nBuf, sqBuf);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x2,-0x58(%rbp)
mov    -0x58(%rbp),%rax
imul   -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1050 <toBaseN@plt>
lea    -0x50(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x4(%rbp),%eax
jl     11d0 <find+0x90>
lea    -0x50(%rbp),%rdi
call   1060 <countUnique@plt>
cmp    -0x4(%rbp),%eax
jne    11d0 <find+0x90>
lea    -0x30(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1050 <toBaseN@plt>
lea    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1050 <toBaseN@plt>
mov    -0x4(%rbp),%esi
lea    -0x30(%rbp),%rdx
lea    -0x50(%rbp),%rcx
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
jmp    11e6 <find+0xa6>
jmp    11d5 <find+0x95>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    1153 <find+0x13>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %edi,%r14d
mov    $0x2,%ebp
mov    %rsp,%r15
jmp    1164 <find+0x24>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    %rbp,%rbx
imul   %rbp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <toBaseN@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %r14d,%eax
jl     1160 <find+0x20>
mov    %r15,%rdi
call   1060 <countUnique@plt>
cmp    %r14d,%eax
jne    1160 <find+0x20>
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1050 <toBaseN@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <toBaseN@plt>
lea    0xe42(%rip),%rdi
mov    %r14d,%esi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1040 <printf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Base %d : Num %8s Square %16s\0A\00"
define void @find(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca i64
%6 = alloca i64
store i32 %0, i32* %2
store i64 2, i64* %5
br label %7
7: ; preds = %38, %1
%8 = load i64, i64* %5
%9 = load i64, i64* %5
%10 = mul nsw i64 %8, %9
store i64 %10, i64* %6
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%12 = load i64, i64* %6
%13 = load i32, i32* %2
%14 = call i32 @toBaseN(i8* %11, i64 %12, i32 %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = load i32, i32* %2
%18 = icmp sge i32 %16, %17
br i1 %18, label %19, label %37
19: ; preds = %7
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%21 = call i32 @countUnique(i8* %20)
%22 = load i32, i32* %2
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %19
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%26 = load i64, i64* %5
%27 = load i32, i32* %2
%28 = call i32 @toBaseN(i8* %25, i64 %26, i32 %27)
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%30 = load i64, i64* %6
%31 = load i32, i32* %2
%32 = call i32 @toBaseN(i8* %29, i64 %30, i32 %31)
%33 = load i32, i32* %2
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %33, i8* %34, i8* %35)
br label %41
37: ; preds = %19, %7
br label %38
38: ; preds = %37
%39 = load i64, i64* %5
%40 = add nsw i64 %39, 1
store i64 %40, i64* %5
br label %7
41: ; preds = %24
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"Base %d : Num %8s Square %16s\0A\00"
define void @find(i32 %0) {
%2 = alloca [32 x i8]
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %6
6: ; preds = %19, %1
%7 = phi i64 [ 2, %1 ], [ %20, %19 ]
%8 = mul nsw i64 %7, %7
%9 = call i32 @toBaseN(i8* %5, i64 %8, i32 %0)
%10 = call i32 @strlen(i8* %5)
%11 = icmp slt i32 %10, %0
br i1 %11, label %19, label %12
12: ; preds = %6
%13 = call i32 @countUnique(i8* %5)
%14 = icmp eq i32 %13, %0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @toBaseN(i8* %4, i64 %7, i32 %0)
%17 = call i32 @toBaseN(i8* %5, i64 %8, i32 %0)
%18 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0, i8* %4, i8* %5)
ret void
19: ; preds = %6, %12
%20 = add nuw nsw i64 %7, 1
br label %6
}