void find_pentagonals(int *pentagonals, int size) {
  for (int i = 1; i <= 10000; i++) {
    int pentagonal = (i * (3 * i - 1)) / 2;
    *pentagonals++ = pentagonal;
  }
}


x86 assembly (clang, -O0):
<find_pentagonals>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x2710,-0x10(%rbp)
jg     1159 <find_pentagonals+0x59>
mov    -0x10(%rbp),%eax
imul   $0x3,-0x10(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <find_pentagonals+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_pentagonals>:
movdqa 0xef8(%rip),%xmm0
mov    $0x4,%eax
pcmpeqd %xmm1,%xmm1
movdqa 0xef7(%rip),%xmm2
movdqa 0xeff(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm4
paddd  %xmm0,%xmm4
paddd  %xmm0,%xmm4
paddd  %xmm1,%xmm4
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm0,%xmm4
pshufd $0xe8,%xmm4,%xmm4
pshufd $0xf5,%xmm0,%xmm6
pmuludq %xmm5,%xmm6
pshufd $0xe8,%xmm6,%xmm5
punpckldq %xmm5,%xmm4
movdqa %xmm4,%xmm5
psrld  $0x1f,%xmm5
paddd  %xmm4,%xmm5
psrad  $0x1,%xmm5
movdqu %xmm5,-0x10(%rdi,%rax,4)
movdqa %xmm0,%xmm4
paddd  %xmm2,%xmm4
movdqa %xmm4,%xmm5
paddd  %xmm4,%xmm5
movdqa %xmm4,%xmm6
paddd  %xmm1,%xmm6
paddd  %xmm5,%xmm6
pshufd $0xf5,%xmm6,%xmm5
pmuludq %xmm4,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm5,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm6
movdqa %xmm6,%xmm4
psrld  $0x1f,%xmm4
paddd  %xmm6,%xmm4
psrad  $0x1,%xmm4
movdqu %xmm4,(%rdi,%rax,4)
paddd  %xmm3,%xmm0
add    $0x8,%rax
cmp    $0x2714,%rax
jne    1130 <find_pentagonals+0x30>
ret

LLVM IR (-O0):
define void @find_pentagonals(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 1, i32* %5
br label %7
7: ; preds = %20, %2
%8 = load i32, i32* %5
%9 = icmp sle i32 %8, 10000
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i32, i32* %5
%12 = load i32, i32* %5
%13 = mul nsw i32 3, %12
%14 = sub nsw i32 %13, 1
%15 = mul nsw i32 %11, %14
%16 = sdiv i32 %15, 2
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %3
store i32 %17, i32* %18
br label %20
20: ; preds = %10
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %7
23: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @find_pentagonals(i32* nocapture writeonly %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %20, %3 ]
%5 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %2 ], [ %21, %3 ]
%6 = getelementptr i32, i32* %0, i64 %4
%7 = mul nuw nsw <4 x i32> %5, <i32 3, i32 3, i32 3, i32 3>
%8 = add nsw <4 x i32> %7, <i32 -1, i32 -1, i32 -1, i32 -1>
%9 = mul nsw <4 x i32> %8, %5
%10 = sdiv <4 x i32> %9, <i32 2, i32 2, i32 2, i32 2>
%11 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %11
%12 = or i64 %4, 4
%13 = add <4 x i32> %5, <i32 4, i32 4, i32 4, i32 4>
%14 = getelementptr i32, i32* %0, i64 %12
%15 = mul nuw nsw <4 x i32> %13, <i32 3, i32 3, i32 3, i32 3>
%16 = add nsw <4 x i32> %15, <i32 -1, i32 -1, i32 -1, i32 -1>
%17 = mul nsw <4 x i32> %16, %13
%18 = sdiv <4 x i32> %17, <i32 2, i32 2, i32 2, i32 2>
%19 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %19
%20 = add nuw nsw i64 %4, 8
%21 = add <4 x i32> %5, <i32 8, i32 8, i32 8, i32 8>
%22 = icmp eq i64 %20, 10000
br i1 %22, label %23, label %3
23: ; preds = %3
ret void
}