void write_bytes(char *addr) {
  unsigned long i;
  for (i = 0; i < (256UL * 1024 * 1024); i++)
    *(addr + i) = (char)i;
}


x86 assembly (clang, -O0):
<write_bytes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x10000000,-0x10(%rbp)
10
jae    1140 <write_bytes+0x40>
mov    -0x10(%rbp),%rax
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <write_bytes+0x10>
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_bytes>:
movdqa 0xef8(%rip),%xmm2
xor    %eax,%eax
movdqa 0xefd(%rip),%xmm8
movdqa 0xf04(%rip),%xmm9
movdqa 0xf0c(%rip),%xmm3
movdqa 0xf14(%rip),%xmm4
movdqa 0xf1c(%rip),%xmm5
movdqa 0xf24(%rip),%xmm6
movdqa 0xf2c(%rip),%xmm7
movdqa 0xf34(%rip),%xmm1
nopl   0x0(%rax)
movdqu %xmm2,(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm8,%xmm0
movdqu %xmm0,0x10(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm9,%xmm0
movdqu %xmm0,0x20(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm3,%xmm0
movdqu %xmm0,0x30(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm4,%xmm0
movdqu %xmm0,0x40(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm5,%xmm0
movdqu %xmm0,0x50(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm6,%xmm0
movdqu %xmm0,0x60(%rdi,%rax,1)
movdqa %xmm2,%xmm0
paddb  %xmm7,%xmm0
movdqu %xmm0,0x70(%rdi,%rax,1)
sub    $0xffffffffffffff80,%rax
pxor   %xmm1,%xmm2
cmp    $0x10000000,%rax
jne    1150 <write_bytes+0x50>
ret

LLVM IR (-O0):
define void @write_bytes(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
store i64 0, i64* %3
br label %4
4: ; preds = %13, %1
%5 = load i64, i64* %3
%6 = icmp ult i64 %5, 268435456
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = load i64, i64* %3
%9 = trunc i64 %8 to i8
%10 = load i8*, i8** %2
%11 = load i64, i64* %3
%12 = getelementptr inbounds i8, i8* %10, i64 %11
store i8 %9, i8* %12
br label %13
13: ; preds = %7
%14 = load i64, i64* %3
%15 = add i64 %14, 1
store i64 %15, i64* %3
br label %4
16: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @write_bytes(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %35, %2 ]
%4 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %1 ], [ %36, %2 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %3
%6 = bitcast i8* %5 to <16 x i8>*
store <16 x i8> %4, <16 x i8>* %6
%7 = or i64 %3, 16
%8 = add <16 x i8> %4, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = bitcast i8* %9 to <16 x i8>*
store <16 x i8> %8, <16 x i8>* %10
%11 = or i64 %3, 32
%12 = add <16 x i8> %4, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%13 = getelementptr inbounds i8, i8* %0, i64 %11
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> %12, <16 x i8>* %14
%15 = or i64 %3, 48
%16 = add <16 x i8> %4, <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = bitcast i8* %17 to <16 x i8>*
store <16 x i8> %16, <16 x i8>* %18
%19 = or i64 %3, 64
%20 = add <16 x i8> %4, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%21 = getelementptr inbounds i8, i8* %0, i64 %19
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> %20, <16 x i8>* %22
%23 = or i64 %3, 80
%24 = add <16 x i8> %4, <i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80, i8 80>
%25 = getelementptr inbounds i8, i8* %0, i64 %23
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> %24, <16 x i8>* %26
%27 = or i64 %3, 96
%28 = add <16 x i8> %4, <i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96, i8 96>
%29 = getelementptr inbounds i8, i8* %0, i64 %27
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> %28, <16 x i8>* %30
%31 = or i64 %3, 112
%32 = add <16 x i8> %4, <i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112, i8 112>
%33 = getelementptr inbounds i8, i8* %0, i64 %31
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %34
%35 = add nuw nsw i64 %3, 128
%36 = xor <16 x i8> %4, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%37 = icmp eq i64 %35, 268435456
br i1 %37, label %38, label %2
38: ; preds = %2
ret void
}