#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__ check_prime(int);
int get_num_divisors(int, int *, int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int sqrt(int);
int main() {
  int prime_num[4096], num_primes;
  int num_cases, high, low;
  int div, max_div, max_num;
  int i, temp;
  temp = sqrt(1000000000);
  for (num_primes = 0, i = 2; i <= temp; i++) {
    if (check_prime(i)) {
      prime_num[num_primes++] = i;
    }
  }
  scanf("%d\n", &num_cases);
  while (num_cases-- > 0) {
    scanf("%d %d\n", &low, &high);
    max_div = 0, max_num = 0;
    for (i = low; i <= high; i++) {
      div = get_num_divisors(i, prime_num, num_primes);
      if (div > max_div) {
        max_div = div;
        max_num = i;
      }
    }
    printf("Between %d and %d, %d has a maximum of %d divisors.\n", low, high,
           max_num, max_div);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4040,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3b9aca00,%edi
call   1070 <sqrt@plt>
mov    %eax,-0x4034(%rbp)
movl   $0x0,-0x4014(%rbp)
movl   $0x2,-0x4030(%rbp)
mov    -0x4030(%rbp),%eax
cmp    -0x4034(%rbp),%eax
jg     11e6 <main+0x96>
mov    -0x4030(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x0,%rax
je     11cd <main+0x7d>
mov    -0x4030(%rbp),%ecx
mov    -0x4014(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x4014(%rbp)
cltq
mov    %ecx,-0x4010(%rbp,%rax,4)
jmp    11d2 <main+0x82>
mov    -0x4030(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4030(%rbp)
jmp    1186 <main+0x36>
lea    0xe16(%rip),%rdi
lea    -0x4018(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x4018(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4018(%rbp)
cmp    $0x0,%eax
jle    12ee <main+0x19e>
lea    0xde4(%rip),%rdi
lea    -0x4020(%rbp),%rsi
lea    -0x401c(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x4028(%rbp)
movl   $0x0,-0x402c(%rbp)
mov    -0x4020(%rbp),%eax
mov    %eax,-0x4030(%rbp)
mov    -0x4030(%rbp),%eax
cmp    -0x401c(%rbp),%eax
jg     12c4 <main+0x174>
mov    -0x4030(%rbp),%edi
lea    -0x4010(%rbp),%rsi
mov    -0x4014(%rbp),%edx
call   1060 <get_num_divisors@plt>
mov    %eax,-0x4024(%rbp)
mov    -0x4024(%rbp),%eax
cmp    -0x4028(%rbp),%eax
jle    12ab <main+0x15b>
mov    -0x4024(%rbp),%eax
mov    %eax,-0x4028(%rbp)
mov    -0x4030(%rbp),%eax
mov    %eax,-0x402c(%rbp)
jmp    12b0 <main+0x160>
mov    -0x4030(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4030(%rbp)
jmp    1251 <main+0x101>
mov    -0x4020(%rbp),%esi
mov    -0x401c(%rbp),%edx
mov    -0x402c(%rbp),%ecx
mov    -0x4028(%rbp),%r8d
lea    0xd23(%rip),%rdi
call   1040 <printf@plt>
jmp    11fb <main+0xab>
xor    %eax,%eax
add    $0x4040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4018,%rsp
mov    $0x3b9aca00,%edi
call   1070 <sqrt@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
jge    1243 <main+0xf3>
lea    0xe86(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    122f <main+0xdf>
lea    0xe64(%rip),%r13
lea    0x10(%rsp),%rbp
jmp    11d0 <main+0x80>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12d,%ecx
mov    %r14d,%r8d
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    122f <main+0xdf>
xor    %r14d,%r14d
lea    0xe26(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%r15d
mov    0xc(%rsp),%edx
xor    %r12d,%r12d
cmp    %edx,%r15d
jg     11b0 <main+0x60>
xor    %r14d,%r14d
nop
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1060 <get_num_divisors@plt>
cmp    %r14d,%eax
cmovg  %eax,%r14d
cmovg  %r15d,%r12d
lea    0x1(%r15),%eax
mov    0xc(%rsp),%edx
cmp    %edx,%r15d
mov    %eax,%r15d
jl     1200 <main+0xb0>
mov    0x8(%rsp),%r15d
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x4018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r14d
neg    %r14d
mov    $0x2,%ebp
xor    %ebx,%ebx
jmp    1277 <main+0x127>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r14,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     1176 <main+0x26>
mov    %ebp,%edi
call   1030 <check_prime@plt>
test   %rax,%rax
je     1260 <main+0x110>
movslq %ebx,%rax
add    $0x1,%ebx
mov    %ebp,0x10(%rsp,%rax,4)
jmp    1260 <main+0x110>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [53 x i8] c"Between %d and %d, %d has a maximum of %d divisors.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 @sqrt(i32 1000000000)
store i32 %12, i32* %11
store i32 0, i32* %3
store i32 2, i32* %10
br label %13
13: ; preds = %28, %0
%14 = load i32, i32* %10
%15 = load i32, i32* %11
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %31
17: ; preds = %13
%18 = load i32, i32* %10
%19 = call i64 @check_prime(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* %10
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [4096 x i32], [4096 x i32]* %2, i64 0, i64 %25
store i32 %22, i32* %26
br label %27
27: ; preds = %21, %17
br label %28
28: ; preds = %27
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
br label %13
31: ; preds = %13
%32 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %33
33: ; preds = %59, %31
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
%36 = icmp sgt i32 %34, 0
br i1 %36, label %37, label %65
37: ; preds = %33
%38 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %5)
store i32 0, i32* %8
store i32 0, i32* %9
%39 = load i32, i32* %6
store i32 %39, i32* %10
br label %40
40: ; preds = %56, %37
%41 = load i32, i32* %10
%42 = load i32, i32* %5
%43 = icmp sle i32 %41, %42
br i1 %43, label %44, label %59
44: ; preds = %40
%45 = load i32, i32* %10
%46 = getelementptr inbounds [4096 x i32], [4096 x i32]* %2, i64 0, i64 0
%47 = load i32, i32* %3
%48 = call i32 @get_num_divisors(i32 %45, i32* %46, i32 %47)
store i32 %48, i32* %7
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = icmp sgt i32 %49, %50
br i1 %51, label %52, label %55
52: ; preds = %44
%53 = load i32, i32* %7
store i32 %53, i32* %8
%54 = load i32, i32* %10
store i32 %54, i32* %9
br label %55
55: ; preds = %52, %44
br label %56
56: ; preds = %55
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %40
59: ; preds = %40
%60 = load i32, i32* %6
%61 = load i32, i32* %5
%62 = load i32, i32* %9
%63 = load i32, i32* %8
%64 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 %61, i32 %62, i32 %63)
br label %33
65: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@.str.2 = [53 x i8] c"Between %d and %d, %d has a maximum of %d divisors.\0A\00"
define i32 @main() {
%1 = alloca [4096 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [4096 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 @sqrt(i32 1000000000)
%10 = icmp slt i32 %9, 2
br i1 %10, label %24, label %11
11: ; preds = %0, %20
%12 = phi i32 [ %21, %20 ], [ 0, %0 ]
%13 = phi i32 [ %22, %20 ], [ 2, %0 ]
%14 = tail call i64 @check_prime(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %11
%17 = add nsw i32 %12, 1
%18 = sext i32 %12 to i64
%19 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 %18
store i32 %13, i32* %19
br label %20
20: ; preds = %11, %16
%21 = phi i32 [ %17, %16 ], [ %12, %11 ]
%22 = add nuw i32 %13, 1
%23 = icmp eq i32 %13, %9
br i1 %23, label %24, label %11
24: ; preds = %20, %0
%25 = phi i32 [ 0, %0 ], [ %21, %20 ]
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%27 = load i32, i32* %2
%28 = add nsw i32 %27, -1
store i32 %28, i32* %2
%29 = icmp sgt i32 %27, 0
br i1 %29, label %30, label %59
30: ; preds = %24
%31 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 0
br label %32
32: ; preds = %30, %50
%33 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %3)
%34 = load i32, i32* %4
%35 = load i32, i32* %3
%36 = icmp sgt i32 %34, %35
br i1 %36, label %50, label %37
37: ; preds = %32, %37
%38 = phi i32 [ %45, %37 ], [ %34, %32 ]
%39 = phi i32 [ %44, %37 ], [ 0, %32 ]
%40 = phi i32 [ %43, %37 ], [ 0, %32 ]
%41 = call i32 @get_num_divisors(i32 %38, i32* %31, i32 %25)
%42 = icmp sgt i32 %41, %40
%43 = select i1 %42, i32 %41, i32 %40
%44 = select i1 %42, i32 %38, i32 %39
%45 = add nsw i32 %38, 1
%46 = load i32, i32* %3
%47 = icmp slt i32 %38, %46
br i1 %47, label %37, label %48
48: ; preds = %37
%49 = load i32, i32* %4
br label %50
50: ; preds = %48, %32
%51 = phi i32 [ %34, %32 ], [ %49, %48 ]
%52 = phi i32 [ 0, %32 ], [ %43, %48 ]
%53 = phi i32 [ 0, %32 ], [ %44, %48 ]
%54 = phi i32 [ %35, %32 ], [ %46, %48 ]
%55 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %51, i32 %54, i32 %53, i32 %52)
%56 = load i32, i32* %2
%57 = add nsw i32 %56, -1
store i32 %57, i32* %2
%58 = icmp sgt i32 %56, 0
br i1 %58, label %32, label %59
59: ; preds = %50, %24
ret i32 0
}