#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*/ getNumberOfPerfectSquareLeadingDigit(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char numStr[2000 + 1], sqrtStr[2000 + 1];
  while (1) {
    scanf("%s", numStr);
    if (numStr[0] == '0')
      break;
    getNumberOfPerfectSquareLeadingDigit(numStr, sqrtStr);
    printf("%s\n", sqrtStr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x7e0(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
movsbl -0x7e0(%rbp),%eax
cmp    $0x30,%eax
jne    116a <main+0x3a>
jmp    1195 <main+0x65>
lea    -0x7e0(%rbp),%rdi
lea    -0xfc0(%rbp),%rsi
call   1030 <getNumberOfPerfectSquareLeadingDigit@plt>
lea    -0xfc0(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfb8,%rsp
lea    0xebb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmpb   $0x30,(%rsp)
je     1197 <main+0x67>
mov    %rsp,%r14
lea    0x7e0(%rsp),%rbx
lea    0xe9e(%rip),%r15
lea    0xe94(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <getNumberOfPerfectSquareLeadingDigit@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
cmpb   $0x30,(%rsp)
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0xfb8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2001 x i8]
%3 = alloca [2001 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %0, %12
%5 = getelementptr inbounds [2001 x i8], [2001 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [2001 x i8], [2001 x i8]* %2, i64 0, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 48
br i1 %10, label %11, label %12
11: ; preds = %4
br label %18
12: ; preds = %4
%13 = getelementptr inbounds [2001 x i8], [2001 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [2001 x i8], [2001 x i8]* %3, i64 0, i64 0
%15 = call i32 @getNumberOfPerfectSquareLeadingDigit(i8* %13, i8* %14)
%16 = getelementptr inbounds [2001 x i8], [2001 x i8]* %3, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %16)
br label %4
18: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [2001 x i8]
%2 = alloca [2001 x i8]
%3 = getelementptr inbounds [2001 x i8], [2001 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [2001 x i8], [2001 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), i8* %3)
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 48
br i1 %7, label %14, label %8
8: ; preds = %0, %8
%9 = call i32 @getNumberOfPerfectSquareLeadingDigit(i8* %3, i8* %4)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%12 = load i8, i8* %3
%13 = icmp eq i8 %12, 48
br i1 %13, label %14, label %8
14: ; preds = %8, %0
ret i32 0
}