#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 /*<<< orphan*/ printf(char *, ...);
void _primes(size_t num, unsigned int prime_nums[], bool verbose) {
  unsigned int n = 2;
  size_t k = 0;
  size_t i = 0;
  if (verbose) {
    printf("+----------+--------------+\n");
    printf("| #        | Prime        |\n");
    printf("+----------+--------------+\n");
  }
  for (k = 0, n = 2; k < num; ++n) {
    for (i = 0; i < k && n % prime_nums[i] != 0; ++i)
      ;
    if (i == k) {
      prime_nums[k] = n;
      ++k;
      if (verbose) {
        printf("| %8zu | %12d |\n", k, n);
      }
    }
  }
  if (verbose) {
    printf("+----------+--------------+\n");
  }
}


x86 assembly (clang, -O0):
<_primes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116e <_primes+0x5e>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x20(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1244 <_primes+0x134>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x29(%rbp)
jae    11bf <_primes+0xaf>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
divl   (%rcx,%rsi,4)
cmp    $0x0,%edx
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11cf <_primes+0xbf>
jmp    11e5 <_primes+0xd5>
jmp    11d4 <_primes+0xc4>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1193 <_primes+0x83>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    1231 <_primes+0x121>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     122c <_primes+0x11c>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <_primes+0x121>
jmp    1236 <_primes+0x126>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117d <_primes+0x6d>
cmpl   $0x0,-0x14(%rbp)
je     125c <_primes+0x14c>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_primes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
test   %edx,%edx
je     115b <_primes+0x3b>
lea    0xeee(%rip),%rbp
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
test   %r15,%r15
je     11d2 <_primes+0xb2>
mov    $0x2,%ebp
lea    0xe94(%rip),%r12
xor    %ecx,%ecx
jmp    117e <_primes+0x5e>
mov    %rcx,%r13
add    $0x1,%ebp
mov    %r13,%rcx
cmp    %r15,%r13
jae    11d2 <_primes+0xb2>
xor    %esi,%esi
test   %rcx,%rcx
je     11b0 <_primes+0x90>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
xor    %edx,%edx
divl   (%rbx,%rsi,4)
test   %edx,%edx
je     11b0 <_primes+0x90>
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1190 <_primes+0x70>
jmp    11b5 <_primes+0x95>
cs nopw 0x0(%rax,%rax,1)
cmp    %rcx,%rsi
jne    1170 <_primes+0x50>
lea    0x1(%rcx),%r13
mov    %ebp,(%rbx,%rcx,4)
test   %r14d,%r14d
je     1173 <_primes+0x53>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1173 <_primes+0x53>
test   %r14d,%r14d
je     11f1 <_primes+0xd1>
lea    0xe4f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"+----------+--------------+\0A\00"
@.str.1 = [29 x i8] c"| # | Prime |\0A\00"
@.str.2 = [17 x i8] c"| %8zu | %12d |\0A\00"
define void @_primes(i64 %0, i32* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i64 %0, i64* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 2, i32* %7
store i64 0, i64* %8
store i64 0, i64* %9
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %12, %3
store i64 0, i64* %8
store i32 2, i32* %7
br label %17
17: ; preds = %59, %16
%18 = load i64, i64* %8
%19 = load i64, i64* %4
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %62
21: ; preds = %17
store i64 0, i64* %9
br label %22
22: ; preds = %37, %21
%23 = load i64, i64* %9
%24 = load i64, i64* %8
%25 = icmp ult i64 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = load i32, i32* %7
%28 = load i32*, i32** %5
%29 = load i64, i64* %9
%30 = getelementptr inbounds i32, i32* %28, i64 %29
%31 = load i32, i32* %30
%32 = urem i32 %27, %31
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %26, %22
%35 = phi i1 [ false, %22 ], [ %33, %26 ]
br i1 %35, label %36, label %40
36: ; preds = %34
br label %37
37: ; preds = %36
%38 = load i64, i64* %9
%39 = add i64 %38, 1
store i64 %39, i64* %9
br label %22
40: ; preds = %34
%41 = load i64, i64* %9
%42 = load i64, i64* %8
%43 = icmp eq i64 %41, %42
br i1 %43, label %44, label %58
44: ; preds = %40
%45 = load i32, i32* %7
%46 = load i32*, i32** %5
%47 = load i64, i64* %8
%48 = getelementptr inbounds i32, i32* %46, i64 %47
store i32 %45, i32* %48
%49 = load i64, i64* %8
%50 = add i64 %49, 1
store i64 %50, i64* %8
%51 = load i32, i32* %6
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %44
%54 = load i64, i64* %8
%55 = load i32, i32* %7
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 %54, i32 %55)
br label %57
57: ; preds = %53, %44
br label %58
58: ; preds = %57, %40
br label %59
59: ; preds = %58
%60 = load i32, i32* %7
%61 = add i32 %60, 1
store i32 %61, i32* %7
br label %17
62: ; preds = %17
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %67
67: ; preds = %65, %62
ret void
}

LLVM IR (-O2):
@.str.2 = [17 x i8] c"| %8zu | %12d |\0A\00"
@str.4 = [28 x i8] c"| # | Prime |\00"
@str.5 = [28 x i8] c"+----------+--------------+\00"
define void @_primes(i64 %0, i32* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
br label %9
9: ; preds = %5, %3
%10 = icmp eq i64 %0, 0
br i1 %10, label %36, label %11
11: ; preds = %9, %32
%12 = phi i64 [ %33, %32 ], [ 0, %9 ]
%13 = phi i32 [ %34, %32 ], [ 2, %9 ]
%14 = icmp eq i64 %12, 0
br i1 %14, label %24, label %15
15: ; preds = %11, %21
%16 = phi i64 [ %22, %21 ], [ 0, %11 ]
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = load i32, i32* %17
%19 = urem i32 %13, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = add nuw i64 %16, 1
%23 = icmp eq i64 %22, %12
br i1 %23, label %27, label %15
24: ; preds = %15, %11
%25 = phi i64 [ 0, %11 ], [ %16, %15 ]
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %32
27: ; preds = %21, %24
%28 = getelementptr inbounds i32, i32* %1, i64 %12
store i32 %13, i32* %28
%29 = add i64 %12, 1
br i1 %4, label %32, label %30
30: ; preds = %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 %29, i32 %13)
br label %32
32: ; preds = %24, %30, %27
%33 = phi i64 [ %29, %30 ], [ %29, %27 ], [ %12, %24 ]
%34 = add i32 %13, 1
%35 = icmp ult i64 %33, %0
br i1 %35, label %11, label %36
36: ; preds = %32, %9
br i1 %4, label %39, label %37
37: ; preds = %36
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.5, i64 0, i64 0))
br label %39
39: ; preds = %37, %36
ret void
}