#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int sqrt(int);
int main() {
  int t, a, b, i, j, k, count = 0;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%d %d", &a, &b);
    k = sqrt(a);
    if (k * k == a)
      count++;
    for (; k * k <= b; k++) {
      count++;
    }
    printf("%d\n", count - 1);
    count = 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f8 <main+0xc8>
lea    0xe8e(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11a5 <main+0x75>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11aa <main+0x7a>
mov    -0x1c(%rbp),%eax
imul   -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11d1 <main+0xa1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <main+0x7a>
mov    -0x20(%rbp),%esi
sub    $0x1,%esi
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <main+0x2f>
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
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11e1 <main+0xb1>
lea    0xe9f(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe94(%rip),%rbx
xor    %ebp,%ebp
jmp    1194 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    11e1 <main+0xb1>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
call   1050 <sqrt@plt>
mov    %eax,%edx
imul   %eax,%edx
xor    %esi,%esi
cmp    0x4(%rsp),%edx
sete   %sil
mov    0xc(%rsp),%ecx
cmp    %ecx,%edx
jg     1180 <main+0x50>
add    $0x1,%eax
nopw   0x0(%rax,%rax,1)
add    $0x1,%esi
mov    %eax,%edx
imul   %eax,%edx
add    $0x1,%eax
cmp    %ecx,%edx
jle    11d0 <main+0xa0>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [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 i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %5
br label %10
10: ; preds = %43, %0
%11 = load i32, i32* %5
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %46
14: ; preds = %10
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%16 = load i32, i32* %3
%17 = call i32 @sqrt(i32 %16)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = load i32, i32* %7
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %3
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %14
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %26
26: ; preds = %23, %14
br label %27
27: ; preds = %36, %26
%28 = load i32, i32* %7
%29 = load i32, i32* %7
%30 = mul nsw i32 %28, %29
%31 = load i32, i32* %4
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %39
33: ; preds = %27
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %36
36: ; preds = %33
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %27
39: ; preds = %27
%40 = load i32, i32* %8
%41 = sub nsw i32 %40, 1
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
store i32 0, i32* %8
br label %43
43: ; preds = %39
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %10
46: ; preds = %10
%47 = load i32, i32* %1
ret i32 %47
}

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