#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*/ prime(int, int *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int primes[1000] = {2, 3};
  int i, c = 5, s = 5;
  for (i = 2; i < 1000; i++) {
    while (!prime(c, primes))
      c += 2;
    primes[i] = c;
    s += c;
    c += 2;
  }
  printf("%d\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
movl   $0x2,-0xfb0(%rbp)
movl   $0x3,-0xfac(%rbp)
movl   $0x5,-0xfb8(%rbp)
movl   $0x5,-0xfbc(%rbp)
movl   $0x2,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jge    1220 <main+0xf0>
jmp    119c <main+0x6c>
mov    -0xfb8(%rbp),%edi
lea    -0xfb0(%rbp),%rsi
call   1050 <prime@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c3 <main+0x93>
jmp    11d7 <main+0xa7>
mov    -0xfb8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xfb8(%rbp)
jmp    119c <main+0x6c>
mov    -0xfb8(%rbp),%ecx
movslq -0xfb4(%rbp),%rax
mov    %ecx,-0xfb0(%rbp,%rax,4)
mov    -0xfb8(%rbp),%eax
add    -0xfbc(%rbp),%eax
mov    %eax,-0xfbc(%rbp)
mov    -0xfb8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xfb8(%rbp)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    1187 <main+0x57>
mov    -0xfbc(%rbp),%esi
lea    0xdd3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfa8,%rsp
mov    %rsp,%r15
mov    $0xfa0,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movabs $0x300000002,%rax
mov    %rax,(%rsp)
mov    $0x5,%eax
mov    $0x2,%r12d
mov    $0x5,%ecx
xchg   %ax,%ax
mov    %eax,%r14d
add    $0xfffffffe,%ecx
mov    %ecx,%ebx
nopl   0x0(%rax,%rax,1)
add    $0x2,%ebx
mov    %ebx,%edi
mov    %r15,%rsi
call   1050 <prime@plt>
test   %eax,%eax
je     1180 <main+0x50>
mov    %ebx,(%rsp,%r12,4)
lea    (%r14,%rbx,1),%eax
add    $0x1,%r12
lea    0x2(%rbx),%ecx
cmp    $0x3e8,%r12
jne    1170 <main+0x40>
add    %ebx,%r14d
lea    0xe4d(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfa8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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