#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__ EOF;
int /*<<< orphan*/ find_prime_ring(char *, int, int *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int num_cases, num;
  int result[32];
  char used_flag[32];
  num_cases = 0;
  while (scanf("%d\n", &num) != EOF) {
    num_cases++;
    memset(used_flag, 0x0, sizeof(char) * 32);
    if (num_cases > 1) {
      printf("\n");
    }
    printf("Case %d:\n", num_cases);
    result[0] = 1;
    used_flag[1] = 1;
    find_prime_ring(used_flag, num, result, 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%rax
je     11ec <main+0xac>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11ad <main+0x6d>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x90(%rbp)
movb   $0x1,-0xaf(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x90(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <find_prime_ring@plt>
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
lea    0xe98(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%rax
je     126d <main+0x11d>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
lea    0xe67(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x1,0x30(%rsp)
movb   $0x1,0x11(%rsp)
mov    0xc(%rsp),%esi
lea    0x30(%rsp),%rdx
mov    %rbx,%rdi
xor    %ecx,%ecx
call   1040 <find_prime_ring@plt>
lea    0xe30(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e07(%rip),%rcx
cmp    (%rcx),%rax
je     126d <main+0x11d>
mov    $0x2,%ebx
lea    0x10(%rsp),%r14
lea    0xe09(%rip),%r15
lea    0x30(%rsp),%r12
lea    0xdf9(%rip),%r13
lea    0xc(%rsp),%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0x1,0x30(%rsp)
movb   $0x1,0x11(%rsp)
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1040 <find_prime_ring@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <scanf@plt>
add    $0x1,%ebx
mov    0x2d80(%rip),%rcx
cmp    (%rcx),%rax
jne    1210 <main+0xc0>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [10 x i8] c"Case %d:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [32 x i32]
%5 = alloca [32 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %19, %0
%7 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i64, i64* @EOF
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
store i32 %12, i32* %2
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 32)
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %10
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
store i32 1, i32* %22
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 1
store i8 1, i8* %23
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%25 = load i32, i32* %3
%26 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
%27 = call i32 @find_prime_ring(i8* %24, i32 %25, i32* %26, i32 0)
br label %6
28: ; preds = %6
ret i32 0
}

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