#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 */
char *malloc(int);
char *test0() {
  size_t i;
  char *start = malloc(2560);
  char *t = start;
  for (i = 1; i <= 2560; i++) {
    char *p;
    p = t;
    *p = (i % 256);
    t++;
  }
  return start;
}


x86 assembly (clang, -O0):
<test0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xa00,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x1,-0x8(%rbp)
cmpq   $0xa00,-0x8(%rbp)
ja     117b <test0+0x6b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1136 <test0+0x26>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test0>:
push   %rax
mov    $0xa00,%edi
call   1030 <malloc@plt>
movdqa 0xedd(%rip),%xmm2
mov    $0x70,%ecx
movdqa 0xedf(%rip),%xmm8
movdqa 0xee6(%rip),%xmm9
movdqa 0xeee(%rip),%xmm3
movdqa 0xef6(%rip),%xmm4
movdqa 0xefe(%rip),%xmm5
movdqa 0xf06(%rip),%xmm6
movdqa 0xf0e(%rip),%xmm7
movdqa 0xf16(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movdqu %xmm2,-0x70(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm8,%xmm0
movdqu %xmm0,-0x60(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm9,%xmm0
movdqu %xmm0,-0x50(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm3,%xmm0
movdqu %xmm0,-0x40(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm4,%xmm0
movdqu %xmm0,-0x30(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm5,%xmm0
movdqu %xmm0,-0x20(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm6,%xmm0
movdqu %xmm0,-0x10(%rax,%rcx,1)
movdqa %xmm2,%xmm0
paddb  %xmm7,%xmm0
movdqu %xmm0,(%rax,%rcx,1)
pxor   %xmm1,%xmm2
sub    $0xffffffffffffff80,%rcx
cmp    $0xa70,%rcx
jne    1170 <test0+0x60>
pop    %rcx
ret

LLVM IR (-O0):
define i8* @test0() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = call i8* @malloc(i32 2560)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
store i64 1, i64* %1
br label %7
7: ; preds = %18, %0
%8 = load i64, i64* %1
%9 = icmp ule i64 %8, 2560
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i8*, i8** %3
store i8* %11, i8** %4
%12 = load i64, i64* %1
%13 = urem i64 %12, 256
%14 = trunc i64 %13 to i8
%15 = load i8*, i8** %4
store i8 %14, i8* %15
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %3
br label %18
18: ; preds = %10
%19 = load i64, i64* %1
%20 = add i64 %19, 1
store i64 %20, i64* %1
br label %7
21: ; preds = %7
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
define noalias i8* @test0() {
%1 = tail call dereferenceable_or_null(2560) i8* @malloc(i32 2560)
br label %2
2: ; preds = %2, %0
%3 = phi i64 [ 0, %0 ], [ %35, %2 ]
%4 = phi <16 x i8> [ <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, i8 16>, %0 ], [ %36, %2 ]
%5 = getelementptr i8, i8* %1, 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 i8, i8* %1, 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 i8, i8* %1, 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 i8, i8* %1, 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 i8, i8* %1, 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 i8, i8* %1, 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 i8, i8* %1, 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 i8, i8* %1, 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, 2560
br i1 %37, label %38, label %2
38: ; preds = %2
ret i8* %1
}