int main() {
  int i, n, k, l, stat, count = 0;
  printf("\nEnter the value of 'n': ");
  scanf("%d", &n);
  i = sqrt(n);
  printf("%d\n", i);
  for (l = i; l > 0; l--) {
    for (k = i; k > 0; k--) {
      stat = l * l + k * k;
      double f = sqrt(stat);
      printf("%lf\n", f);
      printf("%f\n", fmod(f, 1));
      if (fmod(f, 1.0) == 0 && stat < n)
        count++;
    }
  }
  printf("\nCount= %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cvtsi2sdl -0xc(%rbp),%xmm0
call   1060 <sqrt@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    126d <main+0x12d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    125a <main+0x11a>
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xe06(%rip),%xmm1
call   1040 <fmod@plt>
lea    0xe24(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
call   1040 <fmod@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1247 <main+0x107>
jp     1247 <main+0x107>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1247 <main+0x107>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    124c <main+0x10c>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11ae <main+0x6e>
jmp    125f <main+0x11f>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x5e>
mov    -0x1c(%rbp),%esi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <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
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cvtsi2sdl 0x4(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1187 <main+0x47>
sqrtsd %xmm0,%xmm0
jmp    118c <main+0x4c>
call   1060 <sqrt@plt>
cvttsd2si %xmm0,%ebp
lea    0xe9f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,(%rsp)
test   %ebp,%ebp
jle    129a <main+0x15a>
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
lea    0xe6d(%rip),%r15
lea    0xe6b(%rip),%r13
mov    (%rsp),%eax
jmp    11e1 <main+0xa1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%rcx
lea    -0x1(%rcx),%eax
cmp    $0x1,%ecx
jle    129a <main+0x15a>
mov    %rax,0x10(%rsp)
mov    %eax,%ebp
imul   %eax,%ebp
mov    (%rsp),%eax
mov    %eax,%r14d
jmp    1275 <main+0x135>
cs nopw 0x0(%rax,%rax,1)
call   1060 <sqrt@plt>
mov    %r15,%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xddd(%rip),%xmm1
call   1040 <fmod@plt>
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xdc0(%rip),%xmm1
call   1040 <fmod@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setnp  %al
sete   %cl
and    %al,%cl
cmp    0x4(%rsp),%r12d
setl   %al
and    %cl,%al
movzbl %al,%eax
add    %eax,%ebx
lea    -0x1(%r14),%eax
cmp    $0x1,%r14d
mov    %eax,%r14d
jle    11d0 <main+0x90>
mov    %r14d,%r12d
imul   %r14d,%r12d
add    %ebp,%r12d
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
ucomisd %xmm1,%xmm0
jb     1200 <main+0xc0>
sqrtsd %xmm0,%xmm0
jmp    1205 <main+0xc5>
lea    0xd8d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"\0AEnter the value of 'n': \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"%lf\0A\00"
@.str.4 = [4 x i8] c"%f\0A\00"
@.str.5 = [12 x i8] c"\0ACount= %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 i32
%8 = alloca double
store i32 0, i32* %1
store i32 0, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = sitofp i32 %11 to double
%13 = call double @sqrt(double %12)
%14 = fptosi double %13 to i32
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
store i32 %17, i32* %5
br label %18
18: ; preds = %57, %0
%19 = load i32, i32* %5
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %60
21: ; preds = %18
%22 = load i32, i32* %2
store i32 %22, i32* %4
br label %23
23: ; preds = %53, %21
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %56
26: ; preds = %23
%27 = load i32, i32* %5
%28 = load i32, i32* %5
%29 = mul nsw i32 %27, %28
%30 = load i32, i32* %4
%31 = load i32, i32* %4
%32 = mul nsw i32 %30, %31
%33 = add nsw i32 %29, %32
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = sitofp i32 %34 to double
%36 = call double @sqrt(double %35)
store double %36, double* %8
%37 = load double, double* %8
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %37)
%39 = load double, double* %8
%40 = call double @fmod(double %39, double 1.000000e+00)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %40)
%42 = load double, double* %8
%43 = call double @fmod(double %42, double 1.000000e+00)
%44 = fcmp oeq double %43, 0.000000e+00
br i1 %44, label %45, label %52
45: ; preds = %26
%46 = load i32, i32* %6
%47 = load i32, i32* %3
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %52
52: ; preds = %49, %45, %26
br label %53
53: ; preds = %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, -1
store i32 %55, i32* %4
br label %23
56: ; preds = %23
br label %57
57: ; preds = %56
%58 = load i32, i32* %5
%59 = add nsw i32 %58, -1
store i32 %59, i32* %5
br label %18
60: ; preds = %18
%61 = load i32, i32* %7
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"\0AEnter the value of 'n': \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"%lf\0A\00"
@.str.4 = [4 x i8] c"%f\0A\00"
@.str.5 = [12 x i8] c"\0ACount= %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = sitofp i32 %5 to double
%7 = call double @sqrt(double %6)
%8 = fptosi double %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %37
11: ; preds = %0, %34
%12 = phi i32 [ %31, %34 ], [ 0, %0 ]
%13 = phi i32 [ %35, %34 ], [ %8, %0 ]
%14 = mul nsw i32 %13, %13
br label %15
15: ; preds = %11, %15
%16 = phi i32 [ %8, %11 ], [ %32, %15 ]
%17 = phi i32 [ %12, %11 ], [ %31, %15 ]
%18 = mul nsw i32 %16, %16
%19 = add nuw nsw i32 %18, %14
%20 = sitofp i32 %19 to double
%21 = call double @sqrt(double %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %21)
%23 = call double @fmod(double %21, double 1.000000e+00)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %23)
%25 = call double @fmod(double %21, double 1.000000e+00)
%26 = fcmp oeq double %25, 0.000000e+00
%27 = load i32, i32* %1
%28 = icmp slt i32 %19, %27
%29 = select i1 %26, i1 %28, i1 false
%30 = zext i1 %29 to i32
%31 = add nsw i32 %17, %30
%32 = add nsw i32 %16, -1
%33 = icmp sgt i32 %16, 1
br i1 %33, label %15, label %34
34: ; preds = %15
%35 = add nsw i32 %13, -1
%36 = icmp sgt i32 %13, 1
br i1 %36, label %11, label %37
37: ; preds = %34, %0
%38 = phi i32 [ 0, %0 ], [ %31, %34 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %38)
ret i32 0
}