#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 */
long *malloc(int);
long *generateSieve() {
  long *sieve = malloc(sizeof(long) * 250000);
  for (long a = 2; a <= 250000; ++a)
    sieve[a] = a;
  return sieve;
}


x86 assembly (clang, -O0):
<generateSieve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1e8480,%edi
call   1030 <malloc@plt>
mov    %rax,-0x8(%rbp)
movq   $0x2,-0x10(%rbp)
cmpq   $0x3d090,-0x10(%rbp)
jg     115d <generateSieve+0x4d>
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112e <generateSieve+0x1e>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateSieve>:
push   %rax
mov    $0x1e8480,%edi
call   1030 <malloc@plt>
movdqa 0xedd(%rip),%xmm0
mov    $0xc,%ecx
movdqa 0xedf(%rip),%xmm8
movdqa 0xee7(%rip),%xmm2
movdqa 0xeef(%rip),%xmm3
movdqa 0xef7(%rip),%xmm4
movdqa 0xeff(%rip),%xmm5
movdqa 0xf07(%rip),%xmm6
nopl   0x0(%rax)
movdqa %xmm0,%xmm7
paddq  %xmm8,%xmm7
movdqu %xmm0,-0x50(%rax,%rcx,8)
movdqu %xmm7,-0x40(%rax,%rcx,8)
movdqa %xmm0,%xmm7
paddq  %xmm2,%xmm7
movdqa %xmm0,%xmm1
paddq  %xmm3,%xmm1
movdqu %xmm7,-0x30(%rax,%rcx,8)
movdqu %xmm1,-0x20(%rax,%rcx,8)
movdqa %xmm0,%xmm1
paddq  %xmm4,%xmm1
movdqa %xmm0,%xmm7
paddq  %xmm5,%xmm7
movdqu %xmm1,-0x10(%rax,%rcx,8)
movdqu %xmm7,(%rax,%rcx,8)
paddq  %xmm6,%xmm0
add    $0xc,%rcx
cmp    $0x3d098,%rcx
jne    1160 <generateSieve+0x50>
movq   $0x3d08e,0x1e8470(%rax)
movq   $0x3d08f,0x1e8478(%rax)
movq   $0x3d090,0x1e8480(%rax)
pop    %rcx
ret

LLVM IR (-O0):
define i64* @generateSieve() {
%1 = alloca i64*
%2 = alloca i64
%3 = call i64* @malloc(i32 2000000)
store i64* %3, i64** %1
store i64 2, i64* %2
br label %4
4: ; preds = %12, %0
%5 = load i64, i64* %2
%6 = icmp sle i64 %5, 250000
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i64, i64* %2
%9 = load i64*, i64** %1
%10 = load i64, i64* %2
%11 = getelementptr inbounds i64, i64* %9, i64 %10
store i64 %8, i64* %11
br label %12
12: ; preds = %7
%13 = load i64, i64* %2
%14 = add nsw i64 %13, 1
store i64 %14, i64* %2
br label %4
15: ; preds = %4
%16 = load i64*, i64** %1
ret i64* %16
}

LLVM IR (-O2):
define noalias i64* @generateSieve() {
%1 = tail call i64* @malloc(i32 2000000)
br label %2
2: ; preds = %2, %0
%3 = phi i64 [ 0, %0 ], [ %27, %2 ]
%4 = phi <2 x i64> [ <i64 2, i64 3>, %0 ], [ %28, %2 ]
%5 = add <2 x i64> %4, <i64 2, i64 2>
%6 = or i64 %3, 2
%7 = getelementptr inbounds i64, i64* %1, i64 %6
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> %4, <2 x i64>* %8
%9 = getelementptr inbounds i64, i64* %7, i64 2
%10 = bitcast i64* %9 to <2 x i64>*
store <2 x i64> %5, <2 x i64>* %10
%11 = add nuw nsw i64 %3, 4
%12 = add <2 x i64> %4, <i64 4, i64 4>
%13 = add <2 x i64> %4, <i64 6, i64 6>
%14 = or i64 %11, 2
%15 = getelementptr inbounds i64, i64* %1, i64 %14
%16 = bitcast i64* %15 to <2 x i64>*
store <2 x i64> %12, <2 x i64>* %16
%17 = getelementptr inbounds i64, i64* %15, i64 2
%18 = bitcast i64* %17 to <2 x i64>*
store <2 x i64> %13, <2 x i64>* %18
%19 = add nuw nsw i64 %3, 8
%20 = add <2 x i64> %4, <i64 8, i64 8>
%21 = add <2 x i64> %4, <i64 10, i64 10>
%22 = or i64 %19, 2
%23 = getelementptr inbounds i64, i64* %1, i64 %22
%24 = bitcast i64* %23 to <2 x i64>*
store <2 x i64> %20, <2 x i64>* %24
%25 = getelementptr inbounds i64, i64* %23, i64 2
%26 = bitcast i64* %25 to <2 x i64>*
store <2 x i64> %21, <2 x i64>* %26
%27 = add nuw nsw i64 %3, 12
%28 = add <2 x i64> %4, <i64 12, i64 12>
%29 = icmp eq i64 %27, 249996
br i1 %29, label %30, label %2
30: ; preds = %2
%31 = getelementptr inbounds i64, i64* %1, i64 249998
store i64 249998, i64* %31
%32 = getelementptr inbounds i64, i64* %1, i64 249999
store i64 249999, i64* %32
%33 = getelementptr inbounds i64, i64* %1, i64 250000
store i64 250000, i64* %33
ret i64* %1
}