int main() {
  int tc, a, b, p, prime_cnt = 0;
  int *primes = primes_less_than_500(&prime_cnt);
  scanf("%d", &tc);
  for (int i = 1; i <= tc; i++) {
    int arr[1001] = {[0 ... 1000] = -1};
    scanf("%d %d %d", &a, &b, &p);
    printf("Case #%d: %d\n", i, sets(a, b, p, arr, primes, prime_cnt));
  }
  free(primes);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1070 <primes_less_than_500@plt>
cltq
mov    %rax,-0x20(%rbp)
lea    0xe75(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     122b <main+0xcb>
lea    -0xfd0(%rbp),%rdi
mov    $0xff,%esi
mov    $0xfa4,%edx
call   1060 <memset@plt>
lea    0xe34(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0xfd4(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0xfd0(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9d
mov    $0x0,%al
call   1040 <sets@plt>
mov    -0xfd4(%rbp),%esi
mov    %eax,%edx
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a3 <main+0x43>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xfe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfc8,%rsp
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rdi
xor    %eax,%eax
call   1070 <primes_less_than_500@plt>
movslq %eax,%r14
lea    0xe77(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1223 <main+0xc3>
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%r13
lea    0x14(%rsp),%rbp
lea    0xe4d(%rip),%r15
xor    %r12d,%r12d
nop
add    $0x1,%r12d
mov    $0xfa4,%edx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1060 <memset@plt>
lea    0xe23(%rip),%rdi
lea    0x1c(%rsp),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x1c(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0xc(%rsp),%r9d
mov    %rbx,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1040 <sets@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    0x10(%rsp),%r12d
jl     11c0 <main+0x60>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xfc8,%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 = [9 x i8] c"%d %d %d\00"
@.str.2 = [14 x i8] c"Case #%d: %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
%9 = alloca [1001 x i32]
store i32 0, i32* %1
store i32 0, i32* %6
%10 = call i32 (i32*, ...) bitcast (i32 (...)* @primes_less_than_500 to i32 (i32*, ...)*)(i32* %6)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
store i32* %12, i32** %7
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %8
br label %14
14: ; preds = %30, %0
%15 = load i32, i32* %8
%16 = load i32, i32* %2
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = bitcast [1001 x i32]* %9 to i8*
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%21 = load i32, i32* %8
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = getelementptr inbounds [1001 x i32], [1001 x i32]* %9, i64 0, i64 0
%26 = load i32*, i32** %7
%27 = load i32, i32* %6
%28 = call i32 (i32, i32, i32, i32*, i32*, i32, ...) bitcast (i32 (...)* @sets to i32 (i32, i32, i32, i32*, i32*, i32, ...)*)(i32 %22, i32 %23, i32 %24, i32* %25, i32* %26, i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %28)
br label %30
30: ; preds = %18
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %14
33: ; preds = %14
%34 = load i32*, i32** %7
%35 = bitcast i32* %34 to i8*
ret i32 0
}

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