#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) * 2000000);
  for (long a = 2; a <= 2000000; ++a)
    sieve[a] = a;
  return sieve;
}


x86 assembly (clang, -O0):
<generateSieve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xf42400,%edi
call   1030 <malloc@plt>
mov    %rax,-0x8(%rbp)
movq   $0x2,-0x10(%rbp)
cmpq   $0x1e8480,-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    $0xf42400,%edi
call   1030 <malloc@plt>
movdqa 0xedd(%rip),%xmm3
mov    $0x10,%ecx
movdqa 0xedf(%rip),%xmm8
movdqa 0xee6(%rip),%xmm9
movdqa 0xeed(%rip),%xmm10
movdqa 0xef5(%rip),%xmm4
movdqa 0xefd(%rip),%xmm5
movdqa 0xf05(%rip),%xmm6
movdqa 0xf0d(%rip),%xmm7
movdqa 0xf15(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movdqa %xmm3,%xmm0
paddq  %xmm8,%xmm0
movdqu %xmm3,-0x70(%rax,%rcx,8)
movdqu %xmm0,-0x60(%rax,%rcx,8)
movdqa %xmm3,%xmm0
paddq  %xmm9,%xmm0
movdqa %xmm3,%xmm2
paddq  %xmm10,%xmm2
movdqu %xmm0,-0x50(%rax,%rcx,8)
movdqu %xmm2,-0x40(%rax,%rcx,8)
movdqa %xmm3,%xmm0
paddq  %xmm4,%xmm0
movdqa %xmm3,%xmm2
paddq  %xmm5,%xmm2
movdqu %xmm0,-0x30(%rax,%rcx,8)
movdqu %xmm2,-0x20(%rax,%rcx,8)
cmp    $0x1e8480,%rcx
je     11ed <generateSieve+0xdd>
movdqa %xmm3,%xmm0
paddq  %xmm6,%xmm0
movdqa %xmm3,%xmm2
paddq  %xmm7,%xmm2
movdqu %xmm0,-0x10(%rax,%rcx,8)
movdqu %xmm2,(%rax,%rcx,8)
paddq  %xmm1,%xmm3
add    $0x10,%rcx
jmp    1170 <generateSieve+0x60>
movq   $0x1e847e,0xf423f0(%rax)
movq   $0x1e847f,0xf423f8(%rax)
movq   $0x1e8480,0xf42400(%rax)
pop    %rcx
ret

LLVM IR (-O0):
define i64* @generateSieve() {
%1 = alloca i64*
%2 = alloca i64
%3 = call i64* @malloc(i32 16000000)
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, 2000000
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 16000000)
br label %2
2: ; preds = %26, %0
%3 = phi i64 [ 0, %0 ], [ %34, %26 ]
%4 = phi <2 x i64> [ <i64 2, i64 3>, %0 ], [ %35, %26 ]
%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 <2 x i64> %4, <i64 4, i64 4>
%12 = add <2 x i64> %4, <i64 6, i64 6>
%13 = or i64 %3, 6
%14 = getelementptr inbounds i64, i64* %1, i64 %13
%15 = bitcast i64* %14 to <2 x i64>*
store <2 x i64> %11, <2 x i64>* %15
%16 = getelementptr inbounds i64, i64* %14, i64 2
%17 = bitcast i64* %16 to <2 x i64>*
store <2 x i64> %12, <2 x i64>* %17
%18 = add <2 x i64> %4, <i64 8, i64 8>
%19 = add <2 x i64> %4, <i64 10, i64 10>
%20 = or i64 %3, 10
%21 = getelementptr inbounds i64, i64* %1, i64 %20
%22 = bitcast i64* %21 to <2 x i64>*
store <2 x i64> %18, <2 x i64>* %22
%23 = getelementptr inbounds i64, i64* %21, i64 2
%24 = bitcast i64* %23 to <2 x i64>*
store <2 x i64> %19, <2 x i64>* %24
%25 = icmp eq i64 %3, 1999984
br i1 %25, label %36, label %26
26: ; preds = %2
%27 = add <2 x i64> %4, <i64 12, i64 12>
%28 = add <2 x i64> %4, <i64 14, i64 14>
%29 = or i64 %3, 14
%30 = getelementptr inbounds i64, i64* %1, i64 %29
%31 = bitcast i64* %30 to <2 x i64>*
store <2 x i64> %27, <2 x i64>* %31
%32 = getelementptr inbounds i64, i64* %30, i64 2
%33 = bitcast i64* %32 to <2 x i64>*
store <2 x i64> %28, <2 x i64>* %33
%34 = add nuw nsw i64 %3, 16
%35 = add <2 x i64> %4, <i64 16, i64 16>
br label %2
36: ; preds = %2
%37 = getelementptr inbounds i64, i64* %1, i64 1999998
store i64 1999998, i64* %37
%38 = getelementptr inbounds i64, i64* %1, i64 1999999
store i64 1999999, i64* %38
%39 = getelementptr inbounds i64, i64* %1, i64 2000000
store i64 2000000, i64* %39
ret i64* %1
}