#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 *, int);
void primes(int n) {
  int i = 3, count, c;
  for (count = 2; count <= n;) {
    for (c = 2; c <= i - 1; c++) {
      if (i % c == 0)
        break;
    }
    if (c == i) {
      printf("%d\n", i);
      count++;
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<primes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11a7 <primes+0x97>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1175 <primes+0x65>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1162 <primes+0x52>
jmp    1175 <primes+0x65>
jmp    1167 <primes+0x57>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113c <primes+0x2c>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1199 <primes+0x89>
mov    -0x8(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <primes+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jge    1126 <primes+0x16>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r15d
mov    $0x3,%ebp
mov    $0x2,%r12d
mov    $0xffffffff,%ebx
lea    0xec0(%rip),%r14
jmp    1169 <primes+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r12d
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    %r15d,%r12d
jg     111d <primes+0xd>
mov    $0x2,%ecx
xchg   %ax,%ax
mov    %ebp,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
je     1190 <primes+0x80>
lea    (%rbx,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x2,%eax
jne    1170 <primes+0x60>
jmp    1150 <primes+0x40>
nopw   0x0(%rax,%rax,1)
add    %ebx,%ecx
cmp    $0x2,%ecx
je     1150 <primes+0x40>
jmp    115e <primes+0x4e>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @primes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 3, i32* %3
store i32 2, i32* %4
br label %6
6: ; preds = %35, %1
%7 = load i32, i32* %4
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %38
10: ; preds = %6
store i32 2, i32* %5
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 1
%15 = icmp sle i32 %12, %14
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %11
26: ; preds = %21, %11
%27 = load i32, i32* %5
%28 = load i32, i32* %3
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i32, i32* %3
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %35
35: ; preds = %30, %26
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %6
38: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @primes(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %22, label %3
3: ; preds = %1, %18
%4 = phi i32 [ %19, %18 ], [ 2, %1 ]
%5 = phi i32 [ %20, %18 ], [ 3, %1 ]
br label %6
6: ; preds = %3, %10
%7 = phi i32 [ %11, %10 ], [ 2, %3 ]
%8 = urem i32 %5, %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = add nuw nsw i32 %7, 1
%12 = icmp eq i32 %11, %5
br i1 %12, label %15, label %6
13: ; preds = %6
%14 = icmp eq i32 %7, %5
br i1 %14, label %15, label %18
15: ; preds = %10, %13
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%17 = add nsw i32 %4, 1
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ %17, %15 ], [ %4, %13 ]
%20 = add nuw nsw i32 %5, 1
%21 = icmp sgt i32 %19, %0
br i1 %21, label %22, label %3
22: ; preds = %18, %1
ret void
}