#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*/ mpf_t;

/* Variables and functions */
scalar_t__ is_perfect_sq(int);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
long mpf_get_ui(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_mul_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_set_default_prec(int);
int /*<<< orphan*/ mpf_sqrt_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpf_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, long);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  mpf_set_default_prec(512);
  mpf_t a;
  mpf_init(a);
  int total_sum = 0;
  for (int i = 2; i <= 100; ++i) {
    if (is_perfect_sq(i)) {
      continue;
    }
    mpf_sqrt_ui(a, i);
    int digital_sum = 0;
    for (int i = 0; i < 100; ++i) {
      long ip = mpf_get_ui(a);
      digital_sum += ip % 10;
      mpf_sub_ui(a, a, ip);
      mpf_mul_ui(a, a, 10);
    }
    total_sum += digital_sum;
  }
  printf("%d\n", total_sum);
  mpf_clear(a);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x200,%edi
call   10a0 <mpf_set_default_prec@plt>
mov    -0x8(%rbp),%edi
call   1060 <mpf_init@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
cmpl   $0x64,-0x10(%rbp)
jg     126b <main+0xdb>
mov    -0x10(%rbp),%edi
call   1090 <is_perfect_sq@plt>
cmp    $0x0,%rax
je     11e0 <main+0x50>
jmp    125d <main+0xcd>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   10b0 <mpf_sqrt_ui@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    1254 <main+0xc4>
mov    -0x8(%rbp),%edi
call   1030 <mpf_get_ui@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
movslq -0x14(%rbp),%rax
add    %rdx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <mpf_sub_ui@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0xa,%edx
call   1080 <mpf_mul_ui@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f9 <main+0x69>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bf <main+0x2f>
mov    -0xc(%rbp),%esi
lea    0xd8b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <mpf_clear@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x200,%edi
call   10a0 <mpf_set_default_prec@plt>
call   1060 <mpf_init@plt>
xor    %r14d,%r14d
mov    $0x2,%r12d
movabs $0x6666666666666667,%r15
66 66 66
jmp    11ca <main+0x3a>
nopl   0x0(%rax)
add    $0x1,%r12d
cmp    $0x65,%r12d
je     122f <main+0x9f>
mov    %r12d,%edi
call   1090 <is_perfect_sq@plt>
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %r12d,%esi
call   10b0 <mpf_sqrt_ui@plt>
xor    %ebx,%ebx
mov    $0x64,%ebp
cs nopw 0x0(%rax,%rax,1)
call   1030 <mpf_get_ui@plt>
mov    %rax,%rcx
imul   %r15
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x2,%rdx
add    %eax,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%eax
mov    %ecx,%edx
sub    %eax,%edx
add    %edx,%ebx
mov    %rcx,%rdx
call   1040 <mpf_sub_ui@plt>
mov    $0xa,%edx
call   1080 <mpf_mul_ui@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0x60>
add    %ebx,%r14d
jmp    11c0 <main+0x30>
lea    0xdca(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
call   1070 <mpf_clear@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 @mpf_set_default_prec(i32 512)
%2 = tail call i32 @mpf_init(i32 undef)
br label %6
3: ; preds = %26
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%5 = tail call i32 @mpf_clear(i32 undef)
ret i32 0
6: ; preds = %0, %26
%7 = phi i32 [ 2, %0 ], [ %28, %26 ]
%8 = phi i32 [ 0, %0 ], [ %27, %26 ]
%9 = tail call i64 @is_perfect_sq(i32 %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %6
%12 = tail call i32 @mpf_sqrt_ui(i32 undef, i32 %7)
br label %15
13: ; preds = %15
%14 = add nsw i32 %21, %8
br label %26
15: ; preds = %11, %15
%16 = phi i32 [ 0, %11 ], [ %24, %15 ]
%17 = phi i32 [ 0, %11 ], [ %21, %15 ]
%18 = tail call i64 @mpf_get_ui(i32 undef)
%19 = srem i64 %18, 10
%20 = trunc i64 %19 to i32
%21 = add i32 %17, %20
%22 = tail call i32 @mpf_sub_ui(i32 undef, i32 undef, i64 %18)
%23 = tail call i32 @mpf_mul_ui(i32 undef, i32 undef, i32 10)
%24 = add nuw nsw i32 %16, 1
%25 = icmp eq i32 %24, 100
br i1 %25, label %13, label %15
26: ; preds = %6, %13
%27 = phi i32 [ %8, %6 ], [ %14, %13 ]
%28 = add nuw nsw i32 %7, 1
%29 = icmp eq i32 %28, 101
br i1 %29, label %3, label %6
}