#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 /*<<< orphan*/ sieve(int *, int *, int *, int *);
int main() {
  int i;
  int list[10000];
  int list_len = 10000 - 2;
  int primes[10000];
  int primes_index = -1;
  for (i = 2; i < 10000; i++)
    list[i - 2] = i;
  sieve(&list_len, list, primes, &primes_index);
  for (i = 0; i <= primes_index; i++) {
    printf("%d ", primes[i]);
  }
  for (i = 0; i < list_len; i++) {
    printf("%d ", list[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x270e,-0x9c54(%rbp)
movl   $0xffffffff,-0x138a4(%rbp)
ff ff ff
movl   $0x2,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jge    117a <main+0x5a>
mov    -0x8(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cltq
mov    %ecx,-0x9c50(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x2d>
lea    -0x9c50(%rbp),%rsi
lea    -0x138a0(%rbp),%rdx
lea    -0x9c54(%rbp),%rdi
lea    -0x138a4(%rbp),%rcx
call   1040 <sieve@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x138a4(%rbp),%eax
jg     11d8 <main+0xb8>
movslq -0x8(%rbp),%rax
mov    -0x138a0(%rbp,%rax,4),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a2 <main+0x82>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    1215 <main+0xf5>
movslq -0x8(%rbp),%rax
mov    -0x9c50(%rbp,%rax,4),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11df <main+0xbf>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x138b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x13898,%rsp
movl   $0x270e,0xc(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
movdqa 0xeae(%rip),%xmm1
mov    $0x1c,%eax
movdqa 0xeb0(%rip),%xmm10
movdqa 0xeb7(%rip),%xmm8
movdqa 0xebe(%rip),%xmm9
movdqa 0xec6(%rip),%xmm4
movdqa 0xece(%rip),%xmm5
movdqa 0xed6(%rip),%xmm6
movdqa 0xede(%rip),%xmm7
movdqa 0xee6(%rip),%xmm2
nopw   0x0(%rax,%rax,1)
movdqa %xmm1,%xmm0
paddd  %xmm10,%xmm0
movdqa %xmm1,-0x60(%rsp,%rax,4)
movdqa %xmm0,-0x50(%rsp,%rax,4)
cmp    $0x271c,%rax
je     121c <main+0xec>
movdqa %xmm1,%xmm0
paddd  %xmm8,%xmm0
movdqa %xmm1,%xmm3
paddd  %xmm9,%xmm3
movdqa %xmm0,-0x40(%rsp,%rax,4)
movdqa %xmm3,-0x30(%rsp,%rax,4)
movdqa %xmm1,%xmm0
paddd  %xmm4,%xmm0
movdqa %xmm1,%xmm3
paddd  %xmm5,%xmm3
movdqa %xmm0,-0x20(%rsp,%rax,4)
movdqa %xmm3,-0x10(%rsp,%rax,4)
movdqa %xmm1,%xmm0
paddd  %xmm6,%xmm0
movdqa %xmm1,%xmm3
paddd  %xmm7,%xmm3
movdqa %xmm0,(%rsp,%rax,4)
movdqa %xmm3,0x10(%rsp,%rax,4)
paddd  %xmm2,%xmm1
add    $0x20,%rax
jmp    11a0 <main+0x70>
movaps 0xe6d(%rip),%xmm0
movaps %xmm0,0x9c30(%rsp)
movabs $0x270f0000270e,%rax
mov    %rax,0x9c40(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x9c50(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <sieve@plt>
cmpl   $0x0,0x8(%rsp)
js     128f <main+0x15f>
mov    $0xffffffffffffffff,%rbx
lea    0xe32(%rip),%r14
xchg   %ax,%ax
mov    0x9c54(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbx
cmp    %rax,%rbx
jl     1270 <main+0x140>
cmpl   $0x0,0xc(%rsp)
jle    12bc <main+0x18c>
lea    0xe03(%rip),%r14
xor    %ebx,%ebx
nop
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     12a0 <main+0x170>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x13898,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [10000 x i32]
%2 = alloca i32
%3 = alloca [10000 x i32]
%4 = alloca i32
%5 = bitcast [10000 x i32]* %1 to i8*
%6 = bitcast i32* %2 to i8*
store i32 9998, i32* %2
%7 = bitcast [10000 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
br label %9
9: ; preds = %19, %0
%10 = phi i64 [ 0, %0 ], [ %40, %19 ]
%11 = phi <4 x i32> [ <i32 2, i32 3, i32 4, i32 5>, %0 ], [ %41, %19 ]
%12 = add <4 x i32> %11, <i32 4, i32 4, i32 4, i32 4>
%13 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %10
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %11, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %13, i64 4
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %16
%17 = or i64 %10, 8
%18 = icmp eq i64 %17, 9992
br i1 %18, label %42, label %19
19: ; preds = %9
%20 = add <4 x i32> %11, <i32 8, i32 8, i32 8, i32 8>
%21 = add <4 x i32> %11, <i32 12, i32 12, i32 12, i32 12>
%22 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %17
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %23
%24 = getelementptr inbounds i32, i32* %22, i64 4
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %25
%26 = or i64 %10, 16
%27 = add <4 x i32> %11, <i32 16, i32 16, i32 16, i32 16>
%28 = add <4 x i32> %11, <i32 20, i32 20, i32 20, i32 20>
%29 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %26
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %30
%31 = getelementptr inbounds i32, i32* %29, i64 4
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %32
%33 = or i64 %10, 24
%34 = add <4 x i32> %11, <i32 24, i32 24, i32 24, i32 24>
%35 = add <4 x i32> %11, <i32 28, i32 28, i32 28, i32 28>
%36 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %33
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %37
%38 = getelementptr inbounds i32, i32* %36, i64 4
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> %35, <4 x i32>* %39
%40 = add nuw nsw i64 %10, 32
%41 = add <4 x i32> %11, <i32 32, i32 32, i32 32, i32 32>
br label %9
42: ; preds = %9
%43 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 9992
store i32 9994, i32* %43
%44 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 9993
store i32 9995, i32* %44
%45 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 9994
store i32 9996, i32* %45
%46 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 9995
store i32 9997, i32* %46
%47 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 9996
store i32 9998, i32* %47
%48 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 9997
store i32 9999, i32* %48
%49 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 0
%50 = getelementptr inbounds [10000 x i32], [10000 x i32]* %3, i64 0, i64 0
%51 = call i32 @sieve(i32* %2, i32* %49, i32* %50, i32* %4)
%52 = load i32, i32* %4
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %57, %42
%55 = load i32, i32* %2
%56 = icmp sgt i32 %55, 0
br i1 %56, label %66, label %75
57: ; preds = %42, %57
%58 = phi i64 [ %62, %57 ], [ 0, %42 ]
%59 = getelementptr inbounds [10000 x i32], [10000 x i32]* %3, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = add nuw nsw i64 %58, 1
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = icmp slt i64 %58, %64
br i1 %65, label %57, label %54
66: ; preds = %54, %66
%67 = phi i64 [ %71, %66 ], [ 0, %54 ]
%68 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %67
%69 = load i32, i32* %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %69)
%71 = add nuw nsw i64 %67, 1
%72 = load i32, i32* %2
%73 = sext i32 %72 to i64
%74 = icmp slt i64 %71, %73
br i1 %74, label %66, label %75
75: ; preds = %66, %54
%76 = call i32 @putchar(i32 10)
ret i32 0
}