#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 ceil(int /*<<< orphan*/);
int /*<<< orphan*/ pow(int, int);
int /*<<< orphan*/ printf(char *, long);
int scanf(char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main() {
  int digits, n, p;
  long s, d;
  char fs[20];
  while (scanf("%d", &digits) != -1) {
    p = ceil(pow(10, digits / 2));
    for (n = 0; n < p; n++) {
      s = n * n;
      d = (int)(s / p) + (s % p);
      if (d == n) {
        sprintf(fs, "%%0%dd\n", digits);
        printf(fs, s);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0xffffffff,%eax
je     122d <main+0xdd>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1228 <main+0xd8>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
cqto
idiv   %rcx
cltq
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
cqto
idiv   %rcx
mov    -0x48(%rbp),%rax
add    %rdx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jne    1215 <main+0xc5>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe00(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <printf@plt>
jmp    121a <main+0xca>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a0 <main+0x50>
jmp    115f <main+0xf>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe9b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0xffffffff,%eax
je     120e <main+0xbe>
lea    0xe84(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%r12
jmp    11a4 <main+0x54>
nopl   0x0(%rax,%rax,1)
lea    0xe69(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    $0xffffffff,%eax
je     120e <main+0xbe>
mov    0xc(%rsp),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%edi
call   1030 <ceil@plt>
test   %eax,%eax
jle    1190 <main+0x40>
mov    %eax,%ebp
xor    %r15d,%r15d
jmp    11d9 <main+0x89>
nopl   (%rax)
add    $0x1,%r15
cmp    %r15,%rbp
je     1190 <main+0x40>
mov    %r15,%rcx
imul   %r15,%rcx
mov    %ecx,%eax
xor    %edx,%edx
div    %ebp
cltq
add    %rdx,%rax
cmp    %rax,%r15
jne    11d0 <main+0x80>
mov    %ecx,%ebx
mov    0xc(%rsp),%edx
mov    %r13,%rdi
mov    %r14,%rsi
call   1070 <sprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    11d0 <main+0x80>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"%%0%dd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca [20 x i8]
store i32 0, i32* %1
br label %8
8: ; preds = %51, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = icmp ne i32 %9, -1
br i1 %10, label %11, label %52
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 2
%14 = call i32 @pow(i32 10, i32 %13)
%15 = call i32 @ceil(i32 %14)
store i32 %15, i32* %4
store i32 0, i32* %3
br label %16
16: ; preds = %48, %11
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %51
20: ; preds = %16
%21 = load i32, i32* %3
%22 = load i32, i32* %3
%23 = mul nsw i32 %21, %22
%24 = sext i32 %23 to i64
store i64 %24, i64* %5
%25 = load i64, i64* %5
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = sdiv i64 %25, %27
%29 = trunc i64 %28 to i32
%30 = sext i32 %29 to i64
%31 = load i64, i64* %5
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = srem i64 %31, %33
%35 = add nsw i64 %30, %34
store i64 %35, i64* %6
%36 = load i64, i64* %6
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = icmp eq i64 %36, %38
br i1 %39, label %40, label %47
40: ; preds = %20
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%42 = load i32, i32* %2
%43 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%45 = load i64, i64* %5
%46 = call i32 @printf(i8* %44, i64 %45)
br label %47
47: ; preds = %40, %20
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %16
51: ; preds = %16
br label %8
52: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [8 x i8] c"%%0%dd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %36, label %10
7: ; preds = %33, %10
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, -1
br i1 %9, label %36, label %10
10: ; preds = %0, %7
%11 = load i32, i32* %1
%12 = sdiv i32 %11, 2
%13 = call i32 @pow(i32 10, i32 %12)
%14 = call i32 @ceil(i32 %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %10
%17 = zext i32 %14 to i64
%18 = zext i32 %14 to i64
br label %19
19: ; preds = %16, %33
%20 = phi i64 [ 0, %16 ], [ %34, %33 ]
%21 = mul i64 %20, %20
%22 = and i64 %21, 4294967295
%23 = udiv i64 %22, %17
%24 = shl nuw i64 %23, 32
%25 = ashr exact i64 %24, 32
%26 = urem i64 %22, %17
%27 = add nsw i64 %25, %26
%28 = icmp eq i64 %27, %20
br i1 %28, label %29, label %33
29: ; preds = %19
%30 = load i32, i32* %1
%31 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = call i32 @printf(i8* %4, i64 %22)
br label %33
33: ; preds = %19, %29
%34 = add nuw nsw i64 %20, 1
%35 = icmp eq i64 %34, %18
br i1 %35, label %7, label %19
36: ; preds = %7, %0
ret i32 0
}