#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*/ isPrimo(size_t);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  printf("[");
  int primosCount = 0;
  size_t i = 0;
  while (primosCount < 3510) {
    while (!isPrimo(++i))
      ;
    printf(" %d,", i);
    primosCount++;
  }
  printf(" ]\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpl   $0xdb6,-0x8(%rbp)
jge    11a9 <main+0x89>
jmp    115e <main+0x3e>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x10(%rbp)
call   1040 <isPrimo@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1184 <main+0x64>
jmp    1189 <main+0x69>
jmp    115e <main+0x3e>
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114c <main+0x2c>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x5b,%edi
call   1030 <putchar@plt>
lea    0xeab(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1060 <isPrimo@plt>
test   %eax,%eax
je     1160 <main+0x20>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0xdb6,%ebp
jne    1160 <main+0x20>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"[\00"
@.str.1 = [5 x i8] c" %d,\00"
@.str.2 = [4 x i8] c" ]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
store i64 0, i64* %3
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 3510
br i1 %7, label %8, label %21
8: ; preds = %5
br label %9
9: ; preds = %15, %8
%10 = load i64, i64* %3
%11 = add i64 %10, 1
store i64 %11, i64* %3
%12 = call i32 @isPrimo(i64 %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %16
15: ; preds = %9
br label %9
16: ; preds = %9
%17 = load i64, i64* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %17)
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %5
21: ; preds = %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c" %d,\00"
@str = [3 x i8] c" ]\00"
define i32 @main() {
%1 = tail call i32 @putchar(i32 91)
br label %2
2: ; preds = %0, %10
%3 = phi i64 [ 0, %0 ], [ %7, %10 ]
%4 = phi i32 [ 0, %0 ], [ %12, %10 ]
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ %7, %5 ], [ %3, %2 ]
%7 = add i64 %6, 1
%8 = tail call i32 @isPrimo(i64 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %5, label %10
10: ; preds = %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, 3510
br i1 %13, label %14, label %2
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 0
}