#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 getNumDivisor(int, int *, int);
int getPrime(int *, int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int primeSieve[32000], numPrime, T, L, U, resultNum, maxNumDivisor, n,
      numDivisor;
  numPrime = getPrime(primeSieve, 32000);
  scanf("%d", &T);
  while (T) {
    scanf("%d %d", &L, &U);
    resultNum = 1;
    maxNumDivisor = 1;
    for (n = L; n <= U; n++) {
      numDivisor = getNumDivisor(n, primeSieve, numPrime);
      if (numDivisor > maxNumDivisor) {
        resultNum = n;
        maxNumDivisor = numDivisor;
      }
    }
    printf("Between %d and %d, %d has a maximum of %d divisors.\n", L, U,
           resultNum, maxNumDivisor);
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f430,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1f410(%rbp),%rdi
mov    $0x7d00,%esi
call   1030 <getPrime@plt>
mov    %eax,-0x1f414(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x1f418(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x0,-0x1f418(%rbp)
je     1273 <main+0x133>
lea    0xe6e(%rip),%rdi
lea    -0x1f41c(%rbp),%rsi
lea    -0x1f420(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x1,-0x1f424(%rbp)
movl   $0x1,-0x1f428(%rbp)
mov    -0x1f41c(%rbp),%eax
mov    %eax,-0x1f42c(%rbp)
mov    -0x1f42c(%rbp),%eax
cmp    -0x1f420(%rbp),%eax
jg     123a <main+0xfa>
mov    -0x1f42c(%rbp),%edi
lea    -0x1f410(%rbp),%rsi
mov    -0x1f414(%rbp),%edx
call   1040 <getNumDivisor@plt>
mov    %eax,-0x1f430(%rbp)
mov    -0x1f430(%rbp),%eax
cmp    -0x1f428(%rbp),%eax
jle    1221 <main+0xe1>
mov    -0x1f42c(%rbp),%eax
mov    %eax,-0x1f424(%rbp)
mov    -0x1f430(%rbp),%eax
mov    %eax,-0x1f428(%rbp)
jmp    1226 <main+0xe6>
mov    -0x1f42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1f42c(%rbp)
jmp    11c7 <main+0x87>
mov    -0x1f41c(%rbp),%esi
mov    -0x1f420(%rbp),%edx
mov    -0x1f424(%rbp),%ecx
mov    -0x1f428(%rbp),%r8d
lea    0xdac(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1f418(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1f418(%rbp)
jmp    117e <main+0x3e>
xor    %eax,%eax
add    $0x1f430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f418,%rsp
lea    0x10(%rsp),%rdi
mov    $0x7d00,%esi
call   1030 <getPrime@plt>
mov    %eax,%ebx
lea    0xe9a(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     120f <main+0xcf>
lea    0xe7f(%rip),%r13
lea    0x10(%rsp),%rbp
jmp    11a8 <main+0x68>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r12d,%ecx
mov    %r14d,%r8d
call   1050 <printf@plt>
addl   $0xffffffff,0xc(%rsp)
je     120f <main+0xcf>
lea    0xe51(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%r15d
mov    0x4(%rsp),%edx
mov    $0x1,%r14d
mov    $0x1,%r12d
cmp    %edx,%r15d
jg     1190 <main+0x50>
mov    $0x1,%r14d
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1040 <getNumDivisor@plt>
cmp    %r14d,%eax
cmovg  %eax,%r14d
cmovg  %r15d,%r12d
lea    0x1(%r15),%eax
mov    0x4(%rsp),%edx
cmp    %edx,%r15d
mov    %eax,%r15d
jl     11e0 <main+0xa0>
mov    0x8(%rsp),%r15d
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0x1f418,%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 = [6 x i8] c"%d %d\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 [32000 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
store i32 0, i32* %1
%11 = getelementptr inbounds [32000 x i32], [32000 x i32]* %2, i64 0, i64 0
%12 = call i32 @getPrime(i32* %11, i32 32000)
store i32 %12, i32* %3
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %14
14: ; preds = %39, %0
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %47
17: ; preds = %14
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
store i32 1, i32* %7
store i32 1, i32* %8
%19 = load i32, i32* %5
store i32 %19, i32* %9
br label %20
20: ; preds = %36, %17
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %39
24: ; preds = %20
%25 = load i32, i32* %9
%26 = getelementptr inbounds [32000 x i32], [32000 x i32]* %2, i64 0, i64 0
%27 = load i32, i32* %3
%28 = call i32 @getNumDivisor(i32 %25, i32* %26, i32 %27)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = load i32, i32* %8
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = load i32, i32* %9
store i32 %33, i32* %7
%34 = load i32, i32* %10
store i32 %34, i32* %8
br label %35
35: ; preds = %32, %24
br label %36
36: ; preds = %35
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %20
39: ; preds = %20
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43)
%45 = load i32, i32* %4
%46 = add nsw i32 %45, -1
store i32 %46, i32* %4
br label %14
47: ; preds = %14
ret i32 0
}

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