#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;
scalar_t__ check_prime(int);
int /*<<< orphan*/ print_prime_cut(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *, int *);
int main() {
  int primes[1024], total_primes;
  int N, C;
  int i, count, num_primes;
  total_primes = 0;
  for (i = 1; i < 1000; i++) {
    if (check_prime(i)) {
      primes[total_primes++] = i;
    }
  }
  while (scanf("%d %d\n", &N, &C) != EOF) {
    num_primes = 0;
    for (i = 0; i < total_primes && primes[i] <= N; i++) {
      num_primes++;
    }
    printf("%d %d:", N, C);
    print_prime_cut(&primes[0], num_primes, C);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1014(%rbp)
movl   $0x1,-0x1020(%rbp)
cmpl   $0x3e8,-0x1020(%rbp)
jge    11c4 <main+0x84>
mov    -0x1020(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x0,%rax
je     11ab <main+0x6b>
mov    -0x1020(%rbp),%ecx
mov    -0x1014(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1014(%rbp)
cltq
mov    %ecx,-0x1010(%rbp,%rax,4)
jmp    11b0 <main+0x70>
mov    -0x1020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1020(%rbp)
jmp    1166 <main+0x26>
jmp    11c9 <main+0x89>
lea    0xe30(%rip),%rdi
lea    -0x1018(%rbp),%rsi
lea    -0x101c(%rbp),%rdx
call   1050 <scanf@plt>
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%rax
je     12b9 <main+0x179>
movl   $0x0,-0x1028(%rbp)
movl   $0x0,-0x1020(%rbp)
mov    -0x1020(%rbp),%ecx
xor    %eax,%eax
cmp    -0x1014(%rbp),%ecx
mov    %al,-0x1029(%rbp)
jge    123e <main+0xfe>
movslq -0x1020(%rbp),%rax
mov    -0x1010(%rbp,%rax,4),%eax
cmp    -0x1018(%rbp),%eax
setle  %al
mov    %al,-0x1029(%rbp)
mov    -0x1029(%rbp),%al
test   $0x1,%al
jne    1251 <main+0x111>
jmp    1274 <main+0x134>
mov    -0x1028(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1028(%rbp)
mov    -0x1020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1020(%rbp)
jmp    1207 <main+0xc7>
mov    -0x1018(%rbp),%esi
mov    -0x101c(%rbp),%edx
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x1028(%rbp),%esi
mov    -0x101c(%rbp),%edx
call   1060 <print_prime_cut@plt>
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c9 <main+0x89>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    $0x1,%ebx
xor    %r14d,%r14d
jmp    117b <main+0x2b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x3e8,%ebx
je     1194 <main+0x44>
mov    %ebx,%edi
call   1040 <check_prime@plt>
test   %rax,%rax
je     1170 <main+0x20>
movslq %r14d,%rax
add    $0x1,%r14d
mov    %ebx,0x10(%rsp,%rax,4)
jmp    1170 <main+0x20>
lea    0xe65(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%rax
jne    11ca <main+0x7a>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,%r15d
lea    0xe2c(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbx
jmp    1226 <main+0xd6>
mov    0x8(%rsp),%edx
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%edx
lea    0x10(%rsp),%rdi
mov    %ebp,%esi
call   1070 <print_prime_cut@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
mov    0x2dc7(%rip),%rcx
cmp    (%rcx),%rax
je     11b6 <main+0x66>
mov    0xc(%rsp),%esi
mov    $0x0,%ebp
test   %r14d,%r14d
jle    11e0 <main+0x90>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
cmp    %esi,0x10(%rsp,%rbp,4)
jg     11e0 <main+0x90>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1240 <main+0xf0>
mov    %r15d,%ebp
jmp    11e0 <main+0x90>

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
@EOF = global i64 0
@.str.1 = [7 x i8] c"%d %d:\00"
define i32 @main() {
%1 = alloca [1024 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [1024 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %15
7: ; preds = %24
%8 = call i64 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %50, label %11
11: ; preds = %7
%12 = icmp sgt i32 %25, 0
%13 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 0
%14 = zext i32 %25 to i64
br label %28
15: ; preds = %0, %24
%16 = phi i32 [ 0, %0 ], [ %25, %24 ]
%17 = phi i32 [ 1, %0 ], [ %26, %24 ]
%18 = tail call i64 @check_prime(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = add nsw i32 %16, 1
%22 = sext i32 %16 to i64
%23 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 %22
store i32 %17, i32* %23
br label %24
24: ; preds = %15, %20
%25 = phi i32 [ %21, %20 ], [ %16, %15 ]
%26 = add nuw nsw i32 %17, 1
%27 = icmp eq i32 %26, 1000
br i1 %27, label %7, label %15
28: ; preds = %11, %40
%29 = load i32, i32* %2
br i1 %12, label %30, label %40
30: ; preds = %28, %35
%31 = phi i64 [ %36, %35 ], [ 0, %28 ]
%32 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp sgt i32 %33, %29
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = add nuw nsw i64 %31, 1
%37 = icmp eq i64 %36, %14
br i1 %37, label %40, label %30
38: ; preds = %30
%39 = trunc i64 %31 to i32
br label %40
40: ; preds = %35, %38, %28
%41 = phi i32 [ 0, %28 ], [ %39, %38 ], [ %25, %35 ]
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %42)
%44 = load i32, i32* %3
%45 = call i32 @print_prime_cut(i32* %13, i32 %41, i32 %44)
%46 = call i32 @putchar(i32 10)
%47 = call i64 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%48 = load i64, i64* @EOF
%49 = icmp eq i64 %47, %48
br i1 %49, label %50, label %28
50: ; preds = %40, %7
ret i32 0
}