#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 */
scalar_t__ fibo(long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int cases, i;
  scanf("%d", &cases);
  for (i = 0; i < cases; ++i) {
    long long a, b;
    scanf("%llu %llu", &a, &b);
    long long s = 0;
    while (a <= b) {
      s += fibo(a);
      a = a + 1;
    }
    printf("%llu\n", s % 1000000007);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dd <main+0xad>
lea    0xe98(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jg     11b2 <main+0x82>
mov    -0x18(%rbp),%rdi
call   1050 <fibo@plt>
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1182 <main+0x52>
mov    -0x28(%rbp),%rax
mov    $0x3b9aca07,%ecx
cqto
idiv   %rcx
mov    %rdx,%rsi
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <main+0x28>
mov    -0x4(%rbp),%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    0xebb(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11ff <main+0xcf>
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
movabs $0x89705f3112a28fe5,%rbp
5f 70 89
lea    0xe96(%rip),%r13
xor    %r14d,%r14d
jmp    11b9 <main+0x89>
nopl   0x0(%rax)
xor    %ebx,%ebx
mov    %rbx,%rax
imul   %rbp
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1d,%rdx
add    %rax,%rdx
imul   $0x3b9aca07,%rdx,%rax
sub    %rax,%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jge    11ff <main+0xcf>
lea    0xe43(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%rdi
cmp    0x10(%rsp),%rdi
jg     1180 <main+0x50>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
call   1050 <fibo@plt>
add    %rax,%rbx
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rdi
mov    %rdi,0x8(%rsp)
cmp    0x10(%rsp),%rax
jl     11e0 <main+0xb0>
jmp    1182 <main+0x52>
xor    %eax,%eax
add    $0x18,%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 = [10 x i8] c"%llu %llu\00"
@.str.2 = [6 x i8] c"%llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %29, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %4, i64* %5)
store i64 0, i64* %6
br label %14
14: ; preds = %18, %12
%15 = load i64, i64* %4
%16 = load i64, i64* %5
%17 = icmp sle i64 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14
%19 = load i64, i64* %4
%20 = call i64 @fibo(i64 %19)
%21 = load i64, i64* %6
%22 = add nsw i64 %21, %20
store i64 %22, i64* %6
%23 = load i64, i64* %4
%24 = add nsw i64 %23, 1
store i64 %24, i64* %4
br label %14
25: ; preds = %14
%26 = load i64, i64* %6
%27 = srem i64 %26, 1000000007
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %27)
br label %29
29: ; preds = %25
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %8
32: ; preds = %8
%33 = load i32, i32* %1
ret i32 %33
}

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