#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*/ fflush(int /*<<< orphan*/);
int getNextPrimeNumber(int *, int, int const);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int const);
int /*<<< orphan*/ stdin;
int main(void) {
  const int end = 1000;
  int crossed[end], i, j, primenumbers[end], pnmlength = 0;
  for (i = 0; i < end; i++)
    crossed[i] = 1;
  i = 1;
  crossed[0] = 0;
  while (i < end) {
    primenumbers[pnmlength++] = i + 1;
    for (j = i; j < end; j += i + 1) {
      crossed[j] = 0;
    }
    i = getNextPrimeNumber(crossed, i + 1, end);
  }
  printf("Die Primzahlen von 1 bis %d sind:\n", end);
  for (i = 0; i < pnmlength; i++)
    printf("%5d", primenumbers[i]);
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    1198 <main+0x58>
movslq -0x14(%rbp),%rax
movl   $0x1,-0xfc0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x2e>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0xfc0(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    1222 <main+0xe2>
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %ecx,-0x1f60(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x3e8,-0x18(%rbp)
jge    1203 <main+0xc3>
movslq -0x18(%rbp),%rax
movl   $0x0,-0xfc0(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11d6 <main+0x96>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    -0xfc0(%rbp),%rdi
mov    $0x3e8,%edx
call   1060 <getNextPrimeNumber@plt>
mov    %eax,-0x14(%rbp)
jmp    11a9 <main+0x69>
lea    0xdd7(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    126b <main+0x12b>
movslq -0x14(%rbp),%rax
mov    -0x1f60(%rbp,%rax,4),%esi
lea    0xdcb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123a <main+0xfa>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x1f60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1f40,%rsp
xor    %eax,%eax
movaps 0xeab(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movaps %xmm0,(%rsp,%rax,4)
movaps %xmm0,0x10(%rsp,%rax,4)
movaps %xmm0,0x20(%rsp,%rax,4)
movaps %xmm0,0x30(%rsp,%rax,4)
movaps %xmm0,0x40(%rsp,%rax,4)
movaps %xmm0,0x50(%rsp,%rax,4)
movaps %xmm0,0x60(%rsp,%rax,4)
movaps %xmm0,0x70(%rsp,%rax,4)
movaps %xmm0,0x80(%rsp,%rax,4)
movaps %xmm0,0x90(%rsp,%rax,4)
add    $0x28,%rax
cmp    $0x3e8,%rax
jne    1160 <main+0x20>
movl   $0x0,(%rsp)
mov    $0x1,%ecx
xor    %ebx,%ebx
mov    %rsp,%r14
mov    $0x1,%eax
nopl   0x0(%rax)
mov    %ecx,%r15d
lea    0x1(%rax),%esi
mov    %esi,0xfa0(%rsp,%rbx,4)
add    $0x1,%rbx
cltq
movslq %esi,%rcx
cs nopw 0x0(%rax,%rax,1)
movl   $0x0,(%rsp,%rax,4)
add    %rcx,%rax
cmp    $0x3e8,%rax
jl     11e0 <main+0xa0>
mov    %r14,%rdi
mov    $0x3e8,%edx
call   1060 <getNextPrimeNumber@plt>
lea    0x1(%r15),%ecx
cmp    $0x3e8,%eax
jl     11c0 <main+0x80>
lea    0xdff(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <printf@plt>
mov    %r15d,%r15d
xor    %ebx,%ebx
lea    0xe0c(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    0xfa0(%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1230 <main+0xf0>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x1f40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Die Primzahlen von 1 bis %d sind:\0A\00"
@.str.1 = [4 x i8] c"%5d\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1000, i32* %2
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i32, i64 1000
%9 = alloca i32, i64 1000
store i32 0, i32* %6
store i32 0, i32* %4
br label %10
10: ; preds = %17, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1000
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %8, i64 %15
store i32 1, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %10
20: ; preds = %10
store i32 1, i32* %4
%21 = getelementptr inbounds i32, i32* %8, i64 0
store i32 0, i32* %21
br label %22
22: ; preds = %45, %20
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 1000
br i1 %24, label %25, label %49
25: ; preds = %22
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i32, i32* %9, i64 %30
store i32 %27, i32* %31
%32 = load i32, i32* %4
store i32 %32, i32* %5
br label %33
33: ; preds = %40, %25
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 1000
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %8, i64 %38
store i32 0, i32* %39
br label %40
40: ; preds = %36
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
%43 = load i32, i32* %5
%44 = add nsw i32 %43, %42
store i32 %44, i32* %5
br label %33
45: ; preds = %33
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
%48 = call i32 @getNextPrimeNumber(i32* %8, i32 %47, i32 1000)
store i32 %48, i32* %4
br label %22
49: ; preds = %22
%50 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 1000)
store i32 0, i32* %4
br label %51
51: ; preds = %61, %49
%52 = load i32, i32* %4
%53 = load i32, i32* %6
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %64
55: ; preds = %51
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %9, i64 %57
%59 = load i32, i32* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %55
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
store i32 %63, i32* %4
br label %51
64: ; preds = %51
%65 = load i32, i32* @stdin
%66 = call i32 @fflush(i32 %65)
%67 = call i32 (...) @getchar()
store i32 0, i32* %1
%68 = load i8*, i8** %3
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@.str = [35 x i8] c"Die Primzahlen von 1 bis %d sind:\0A\00"
@.str.1 = [4 x i8] c"%5d\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca [1000 x i32]
%2 = alloca [1000 x i32]
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %29, %3 ]
%5 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %4
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %5, i64 4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %8
%9 = add nuw nsw i64 %4, 8
%10 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %9
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %11
%12 = getelementptr inbounds i32, i32* %10, i64 4
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %13
%14 = add nuw nsw i64 %4, 16
%15 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %14
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %16
%17 = getelementptr inbounds i32, i32* %15, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %18
%19 = add nuw nsw i64 %4, 24
%20 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %19
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %21
%22 = getelementptr inbounds i32, i32* %20, i64 4
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %23
%24 = add nuw nsw i64 %4, 32
%25 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %24
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %25, i64 4
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %28
%29 = add nuw nsw i64 %4, 40
%30 = icmp eq i64 %29, 1000
br i1 %30, label %31, label %3
31: ; preds = %3
%32 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
store i32 0, i32* %32
br label %33
33: ; preds = %46, %31
%34 = phi i64 [ 0, %31 ], [ %37, %46 ]
%35 = phi i32 [ 1, %31 ], [ %47, %46 ]
%36 = add nsw i32 %35, 1
%37 = add nuw i64 %34, 1
%38 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %34
store i32 %36, i32* %38
%39 = sext i32 %35 to i64
%40 = sext i32 %36 to i64
br label %41
41: ; preds = %33, %41
%42 = phi i64 [ %39, %33 ], [ %44, %41 ]
%43 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %42
store i32 0, i32* %43
%44 = add i64 %42, %40
%45 = icmp slt i64 %44, 1000
br i1 %45, label %41, label %46
46: ; preds = %41
%47 = call i32 @getNextPrimeNumber(i32* %32, i32 %36, i32 1000)
%48 = icmp slt i32 %47, 1000
br i1 %48, label %33, label %49
49: ; preds = %46
%50 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 1000)
%51 = add i64 %34, 1
%52 = and i64 %51, 4294967295
br label %53
53: ; preds = %49, %53
%54 = phi i64 [ 0, %49 ], [ %58, %53 ]
%55 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = add nuw nsw i64 %54, 1
%59 = icmp eq i64 %58, %52
br i1 %59, label %60, label %53
60: ; preds = %53
%61 = load i32, i32* @stdin
%62 = call i32 @fflush(i32 %61)
%63 = call i32 (...) @getchar()
ret i32 0
}