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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ printf(char *, int);
void main(void) {
  FILE *in_file;
  int a, b;
  int no_cases, start, end, sum = 0;
  in_file = fopen("input.txt", "r");
  if (in_file == NULL)
    exit(1);
  fscanf(in_file, "%d", &no_cases);
  for (a = 0; a < no_cases; a++) {
    fscanf(in_file, "%d %d", &start, &end);
    sum = 0;
    for (b = start; b <= end; b++) {
      sum += b;
    }
    printf("%d\n", sum);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x20(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117b <main+0x3b>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    120b <main+0xcb>
mov    -0x8(%rbp),%rdi
lea    0xe5d(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11ee <main+0xae>
mov    -0x10(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11cb <main+0x8b>
mov    -0x20(%rbp),%esi
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1198 <main+0x58>
add    $0x20,%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    0xeab(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1204 <main+0xc4>
mov    %rax,%rbx
lea    0xe9b(%rip),%rsi
xor    %r14d,%r14d
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11f5 <main+0xb5>
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe74(%rip),%r13
jmp    11b5 <main+0x75>
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
jge    11f5 <main+0xb5>
xor    %ebp,%ebp
mov    %rbx,%rdi
lea    0xe4b(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x14(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    %edx,%eax
sub    %ecx,%eax
jl     11a0 <main+0x60>
lea    0x1(%rcx),%ebp
imul   %eax,%ebp
mov    %ecx,%esi
not    %esi
add    %esi,%edx
imul   %rdx,%rax
shr    %rax
add    %ecx,%ebp
add    %eax,%ebp
jmp    11a0 <main+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %7
%8 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %1
%9 = load i32*, i32** %1
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = load i32*, i32** %1
%15 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
store i32 0, i32* %2
br label %16
16: ; preds = %38, %13
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load i32*, i32** %1
%22 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %5, i32* %6)
store i32 0, i32* %7
%23 = load i32, i32* %5
store i32 %23, i32* %3
br label %24
24: ; preds = %32, %20
%25 = load i32, i32* %3
%26 = load i32, i32* %6
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i32, i32* %3
%30 = load i32, i32* %7
%31 = add nsw i32 %30, %29
store i32 %31, i32* %7
br label %32
32: ; preds = %28
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %24
35: ; preds = %24
%36 = load i32, i32* %7
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %35
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %16
41: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define void @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 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %40
15: ; preds = %11, %34
%16 = phi i32 [ %37, %34 ], [ 0, %11 ]
%17 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3)
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, %18
br i1 %20, label %34, label %21
21: ; preds = %15
%22 = sub i32 %19, %18
%23 = add i32 %18, 1
%24 = mul i32 %22, %23
%25 = xor i32 %18, -1
%26 = add i32 %19, %25
%27 = zext i32 %26 to i33
%28 = zext i32 %22 to i33
%29 = mul i33 %27, %28
%30 = lshr i33 %29, 1
%31 = trunc i33 %30 to i32
%32 = add i32 %18, %24
%33 = add i32 %32, %31
br label %34
34: ; preds = %21, %15
%35 = phi i32 [ 0, %15 ], [ %33, %21 ]
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i32 %16, 1
%38 = load i32, i32* %1
%39 = icmp slt i32 %37, %38
br i1 %39, label %15, label %40
40: ; preds = %34, %11
ret void
}