#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_primes(int, int *, int *);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, int *);
int main() {
  int primes[81920];
  int num_primes;
  int num, count;
  int i;
  find_primes(1000000, primes, &num_primes);
  while (scanf("%d\n", &num) != EOF && num != 0) {
    count = 0;
    for (i = 0; primes[i] <= num && i < num_primes; i++) {
      if (num % primes[i] == 0) {
        count++;
      }
    }
    printf("%d : %d\n", num, count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50030,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50010(%rbp),%rsi
mov    $0xf4240,%edi
lea    -0x50014(%rbp),%rdx
call   1030 <find_primes@plt>
lea    0xea4(%rip),%rdi
lea    -0x50018(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e6f(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x50021(%rbp)
je     1198 <main+0x68>
cmpl   $0x0,-0x50018(%rbp)
setne  %al
mov    %al,-0x50021(%rbp)
mov    -0x50021(%rbp),%al
test   $0x1,%al
jne    11ab <main+0x7b>
jmp    126c <main+0x13c>
movl   $0x0,-0x5001c(%rbp)
movl   $0x0,-0x50020(%rbp)
movslq -0x50020(%rbp),%rax
mov    -0x50010(%rbp,%rax,4),%ecx
xor    %eax,%eax
cmp    -0x50018(%rbp),%ecx
mov    %al,-0x50022(%rbp)
jg     11f6 <main+0xc6>
mov    -0x50020(%rbp),%eax
cmp    -0x50014(%rbp),%eax
setl   %al
mov    %al,-0x50022(%rbp)
mov    -0x50022(%rbp),%al
test   $0x1,%al
jne    1209 <main+0xd9>
jmp    124f <main+0x11f>
mov    -0x50018(%rbp),%eax
movslq -0x50020(%rbp),%rcx
cltd
idivl  -0x50010(%rbp,%rcx,4)
cmp    $0x0,%edx
jne    1236 <main+0x106>
mov    -0x5001c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5001c(%rbp)
jmp    123b <main+0x10b>
mov    -0x50020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50020(%rbp)
jmp    11bf <main+0x8f>
mov    -0x50018(%rbp),%esi
mov    -0x5001c(%rbp),%edx
lea    0xd9e(%rip),%rdi
call   1040 <printf@plt>
jmp    115a <main+0x2a>
xor    %eax,%eax
add    $0x50030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50010,%rsp
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    $0xf4240,%edi
call   1030 <find_primes@plt>
lea    0xeaa(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e7c(%rip),%r12
cmp    (%r12),%rax
je     1202 <main+0xd2>
mov    0x8(%rsp),%esi
test   %esi,%esi
je     1202 <main+0xd2>
lea    0xe77(%rip),%r14
lea    0xe75(%rip),%r15
lea    0x8(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%ebx
xor    %ecx,%ecx
cmp    %esi,%ebx
jg     11df <main+0xaf>
mov    0xc(%rsp),%r8d
test   %r8d,%r8d
jle    11df <main+0xaf>
xor    %ecx,%ecx
mov    $0x1,%edi
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %ebx
cmp    $0x1,%edx
adc    $0x0,%ecx
mov    0x10(%rsp,%rdi,4),%ebx
cmp    %esi,%ebx
jg     11df <main+0xaf>
lea    0x1(%rdi),%rax
cmp    %r8,%rdi
mov    %rax,%rdi
jb     11c0 <main+0x90>
mov    %r14,%rdi
mov    %ecx,%edx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmp    (%r12),%rax
je     1202 <main+0xd2>
mov    0x8(%rsp),%esi
test   %esi,%esi
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x50010,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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