#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 */
typedef int u_char;

/* Variables and functions */
void packet_fill(u_char *packet) {
  int i;
  for (i = 0; i < 16 * (1024 * 1024); i++)
    packet[i] = (i & 0xff);
}


x86 assembly (clang, -O0):
<packet_fill>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1000000,-0xc(%rbp)
jge    113e <packet_fill+0x3e>
mov    -0xc(%rbp),%edx
and    $0xff,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <packet_fill+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<packet_fill>:
movdqa 0xef8(%rip),%xmm0
xor    %eax,%eax
movdqa 0xefe(%rip),%xmm1
movdqa 0xf06(%rip),%xmm2
movdqa 0xf0e(%rip),%xmm3
movdqa 0xf16(%rip),%xmm4
movdqa 0xf1e(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqa %xmm0,%xmm6
paddd  %xmm1,%xmm6
movdqa %xmm0,%xmm7
pand   %xmm2,%xmm7
pand   %xmm2,%xmm6
movdqu %xmm7,(%rdi,%rax,4)
movdqu %xmm6,0x10(%rdi,%rax,4)
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
movdqa %xmm0,%xmm7
paddd  %xmm4,%xmm7
pand   %xmm2,%xmm6
pand   %xmm2,%xmm7
movdqu %xmm6,0x20(%rdi,%rax,4)
movdqu %xmm7,0x30(%rdi,%rax,4)
add    $0x10,%rax
paddd  %xmm5,%xmm0
cmp    $0x1000000,%rax
jne    1140 <packet_fill+0x40>
ret

LLVM IR (-O0):
define void @packet_fill(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %4
4: ; preds = %14, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 16777216
br i1 %6, label %7, label %17
7: ; preds = %4
%8 = load i32, i32* %3
%9 = and i32 %8, 255
%10 = load i32*, i32** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
store i32 %9, i32* %13
br label %14
14: ; preds = %7
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %4
17: ; preds = %4
ret void
}

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