void generateSimpleRawMaterial(unsigned char *data, unsigned int length,
                               unsigned char seed1, unsigned int seed2) {
  unsigned int i;
  for (i = 0; i < length; i++) {
    unsigned int iRolled = i * seed1;
    unsigned char byte = (iRolled + length + seed2) % 0xFF;
    data[i] = byte;
  }
}


x86 assembly (clang, -O0):
<generateSimpleRawMaterial>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1165 <generateSimpleRawMaterial+0x65>
mov    -0x18(%rbp),%eax
movzbl -0xd(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    $0xff,%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111a <generateSimpleRawMaterial+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateSimpleRawMaterial>:
test   %esi,%esi
je     169b <generateSimpleRawMaterial+0x59b>
movzbl %dl,%r10d
add    %esi,%ecx
mov    %esi,%r8d
cmp    $0x10,%esi
jae    111d <generateSimpleRawMaterial+0x1d>
xor    %esi,%esi
jmp    166f <generateSimpleRawMaterial+0x56f>
mov    %r8d,%esi
and    $0xfffffff0,%esi
movd   %r10d,%xmm0
pshufd $0x0,%xmm0,%xmm11
movd   %ecx,%xmm0
pshufd $0x0,%xmm0,%xmm10
lea    -0x10(%rsi),%rax
mov    %rax,%r9
shr    $0x4,%r9
add    $0x1,%r9
pshufd $0xf5,%xmm11,%xmm12
test   %rax,%rax
je     169c <generateSimpleRawMaterial+0x59c>
mov    %r9,%rax
and    $0xfffffffffffffffe,%rax
movdqa 0xe9b(%rip),%xmm5
movdqa 0xea3(%rip),%xmm6
movdqa 0xeaa(%rip),%xmm13
movdqa 0xeb1(%rip),%xmm15
xor    %edx,%edx
movdqa 0xeb6(%rip),%xmm14
movdqa 0xebd(%rip),%xmm8
movdqa 0xec4(%rip),%xmm9
nopl   0x0(%rax)
movdqa %xmm6,%xmm0
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm7
pshufd $0xf5,%xmm6,%xmm0
pmuludq %xmm12,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm7
movdqa %xmm5,%xmm0
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm3
pshufd $0xf5,%xmm5,%xmm0
pmuludq %xmm12,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm3
movdqa %xmm15,%xmm0
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm1
pshufd $0xf5,%xmm15,%xmm0
pmuludq %xmm12,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm13,%xmm0
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm13,%xmm2
pmuludq %xmm12,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
paddd  %xmm10,%xmm0
paddd  %xmm10,%xmm1
paddd  %xmm10,%xmm3
paddd  %xmm10,%xmm7
movdqa %xmm7,%xmm2
pmuludq %xmm14,%xmm2
pshufd $0xed,%xmm2,%xmm2
pshufd $0xf5,%xmm7,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm2
psrld  $0x7,%xmm2
movdqa %xmm2,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm2
paddd  %xmm7,%xmm2
movdqa %xmm3,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
pshufd $0xf5,%xmm3,%xmm7
pmuludq %xmm14,%xmm7
pshufd $0xed,%xmm7,%xmm7
punpckldq %xmm7,%xmm4
psrld  $0x7,%xmm4
movdqa %xmm4,%xmm7
pslld  $0x8,%xmm7
psubd  %xmm7,%xmm4
paddd  %xmm3,%xmm4
packuswb %xmm4,%xmm2
movdqa %xmm1,%xmm3
pmuludq %xmm14,%xmm3
pshufd $0xed,%xmm3,%xmm3
pshufd $0xf5,%xmm1,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm3
psrld  $0x7,%xmm3
movdqa %xmm3,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm3
paddd  %xmm1,%xmm3
movdqa %xmm0,%xmm1
pmuludq %xmm14,%xmm1
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm1
psrld  $0x7,%xmm1
movdqa %xmm1,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm1
paddd  %xmm0,%xmm1
packuswb %xmm1,%xmm3
packuswb %xmm2,%xmm3
movdqu %xmm3,(%rdi,%rdx,1)
movdqa %xmm13,%xmm0
paddd  %xmm8,%xmm0
movdqa %xmm15,%xmm1
paddd  %xmm8,%xmm1
movdqa %xmm5,%xmm2
paddd  %xmm8,%xmm2
movdqa %xmm6,%xmm3
paddd  %xmm8,%xmm3
pshufd $0xf5,%xmm3,%xmm4
pmuludq %xmm11,%xmm3
pshufd $0xe8,%xmm3,%xmm7
pmuludq %xmm12,%xmm4
pshufd $0xe8,%xmm4,%xmm3
punpckldq %xmm3,%xmm7
pshufd $0xf5,%xmm2,%xmm4
pmuludq %xmm11,%xmm2
pshufd $0xe8,%xmm2,%xmm3
pmuludq %xmm12,%xmm4
pshufd $0xe8,%xmm4,%xmm2
punpckldq %xmm2,%xmm3
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm11,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm12,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm11,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm12,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
paddd  %xmm10,%xmm0
paddd  %xmm10,%xmm1
paddd  %xmm10,%xmm3
paddd  %xmm10,%xmm7
movdqa %xmm7,%xmm2
pmuludq %xmm14,%xmm2
pshufd $0xed,%xmm2,%xmm2
pshufd $0xf5,%xmm7,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm2
psrld  $0x7,%xmm2
movdqa %xmm2,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm2
paddd  %xmm7,%xmm2
movdqa %xmm3,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
pshufd $0xf5,%xmm3,%xmm7
pmuludq %xmm14,%xmm7
pshufd $0xed,%xmm7,%xmm7
punpckldq %xmm7,%xmm4
psrld  $0x7,%xmm4
movdqa %xmm4,%xmm7
pslld  $0x8,%xmm7
psubd  %xmm7,%xmm4
paddd  %xmm3,%xmm4
packuswb %xmm4,%xmm2
movdqa %xmm1,%xmm3
pmuludq %xmm14,%xmm3
pshufd $0xed,%xmm3,%xmm3
pshufd $0xf5,%xmm1,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm3
psrld  $0x7,%xmm3
movdqa %xmm3,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm3
paddd  %xmm1,%xmm3
movdqa %xmm0,%xmm1
pmuludq %xmm14,%xmm1
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm1
psrld  $0x7,%xmm1
movdqa %xmm1,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm1
paddd  %xmm0,%xmm1
packuswb %xmm1,%xmm3
packuswb %xmm2,%xmm3
movdqu %xmm3,0x10(%rdi,%rdx,1)
add    $0x20,%rdx
paddd  %xmm9,%xmm15
paddd  %xmm9,%xmm13
paddd  %xmm9,%xmm6
paddd  %xmm9,%xmm5
add    $0xfffffffffffffffe,%rax
jne    11a0 <generateSimpleRawMaterial+0xa0>
test   $0x1,%r9b
je     166a <generateSimpleRawMaterial+0x56a>
pshufd $0xf5,%xmm6,%xmm0
pmuludq %xmm11,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pmuludq %xmm12,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm6
pshufd $0xf5,%xmm5,%xmm0
pmuludq %xmm11,%xmm5
pshufd $0xe8,%xmm5,%xmm3
pmuludq %xmm12,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm3
pshufd $0xf5,%xmm15,%xmm1
pmuludq %xmm11,%xmm15
pshufd $0xe8,%xmm15,%xmm0
pmuludq %xmm12,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
pmuludq %xmm13,%xmm11
pshufd $0xe8,%xmm11,%xmm1
pshufd $0xf5,%xmm13,%xmm2
pmuludq %xmm12,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
paddd  %xmm10,%xmm1
paddd  %xmm10,%xmm0
paddd  %xmm10,%xmm3
paddd  %xmm10,%xmm6
movdqa 0xabb(%rip),%xmm4
movdqa %xmm6,%xmm2
pmuludq %xmm4,%xmm2
pshufd $0xed,%xmm2,%xmm2
pshufd $0xf5,%xmm6,%xmm5
pmuludq %xmm4,%xmm5
pshufd $0xed,%xmm5,%xmm5
punpckldq %xmm5,%xmm2
psrld  $0x7,%xmm2
movdqa %xmm2,%xmm5
pslld  $0x8,%xmm5
psubd  %xmm5,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm3,%xmm5
pmuludq %xmm4,%xmm5
pshufd $0xed,%xmm5,%xmm5
pshufd $0xf5,%xmm3,%xmm6
pmuludq %xmm4,%xmm6
pshufd $0xed,%xmm6,%xmm6
punpckldq %xmm6,%xmm5
psrld  $0x7,%xmm5
movdqa %xmm5,%xmm6
pslld  $0x8,%xmm6
psubd  %xmm6,%xmm5
paddd  %xmm3,%xmm5
packuswb %xmm5,%xmm2
movdqa %xmm0,%xmm3
pmuludq %xmm4,%xmm3
pshufd $0xed,%xmm3,%xmm3
pshufd $0xf5,%xmm0,%xmm5
pmuludq %xmm4,%xmm5
pshufd $0xed,%xmm5,%xmm5
punpckldq %xmm5,%xmm3
psrld  $0x7,%xmm3
movdqa %xmm3,%xmm5
pslld  $0x8,%xmm5
psubd  %xmm5,%xmm3
paddd  %xmm0,%xmm3
movdqa %xmm1,%xmm0
pmuludq %xmm4,%xmm0
pshufd $0xed,%xmm0,%xmm0
pshufd $0xf5,%xmm1,%xmm5
pmuludq %xmm4,%xmm5
pshufd $0xed,%xmm5,%xmm4
punpckldq %xmm4,%xmm0
psrld  $0x7,%xmm0
movdqa %xmm0,%xmm4
pslld  $0x8,%xmm4
psubd  %xmm4,%xmm0
paddd  %xmm1,%xmm0
packuswb %xmm0,%xmm3
packuswb %xmm2,%xmm3
movdqu %xmm3,(%rdi,%rdx,1)
cmp    %r8,%rsi
je     169b <generateSimpleRawMaterial+0x59b>
mov    %r10d,%eax
imul   %esi,%eax
add    %eax,%ecx
mov    $0x80808081,%eax
nopl   0x0(%rax)
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x27,%rdx
add    %cl,%dl
mov    %dl,(%rdi,%rsi,1)
add    $0x1,%rsi
add    %r10d,%ecx
cmp    %rsi,%r8
jne    1680 <generateSimpleRawMaterial+0x580>
ret
movdqa 0x95c(%rip),%xmm5
movdqa 0x964(%rip),%xmm6
movdqa 0x96b(%rip),%xmm13
movdqa 0x972(%rip),%xmm15
xor    %edx,%edx
test   $0x1,%r9b
jne    14f1 <generateSimpleRawMaterial+0x3f1>
jmp    166a <generateSimpleRawMaterial+0x56a>

LLVM IR (-O0):
define void @generateSimpleRawMaterial(i8* %0, i32 %1, i8 zeroext %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8 %2, i8* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %33, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %6
%15 = icmp ult i32 %13, %14
br i1 %15, label %16, label %36
16: ; preds = %12
%17 = load i32, i32* %9
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = mul i32 %17, %19
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = load i32, i32* %6
%23 = add i32 %21, %22
%24 = load i32, i32* %8
%25 = add i32 %23, %24
%26 = urem i32 %25, 255
%27 = trunc i32 %26 to i8
store i8 %27, i8* %11
%28 = load i8, i8* %11
%29 = load i8*, i8** %5
%30 = load i32, i32* %9
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
br label %33
33: ; preds = %16
%34 = load i32, i32* %9
%35 = add i32 %34, 1
store i32 %35, i32* %9
br label %12
36: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @generateSimpleRawMaterial(i8* nocapture writeonly %0, i32 %1, i8 zeroext %2, i32 %3) {
%5 = icmp eq i32 %1, 0
br i1 %5, label %71, label %6
6: ; preds = %4
%7 = zext i8 %2 to i32
%8 = add i32 %3, %1
%9 = zext i32 %1 to i64
%10 = icmp ult i32 %1, 16
br i1 %10, label %59, label %11
11: ; preds = %6
%12 = and i64 %9, 4294967280
%13 = insertelement <16 x i32> poison, i32 %7, i64 0
%14 = shufflevector <16 x i32> %13, <16 x i32> poison, <16 x i32> zeroinitializer
%15 = insertelement <16 x i32> poison, i32 %8, i64 0
%16 = shufflevector <16 x i32> %15, <16 x i32> poison, <16 x i32> zeroinitializer
%17 = add nsw i64 %12, -16
%18 = lshr exact i64 %17, 4
%19 = add nuw nsw i64 %18, 1
%20 = and i64 %19, 1
%21 = icmp eq i64 %17, 0
br i1 %21, label %46, label %22
22: ; preds = %11
%23 = and i64 %19, 2305843009213693950
br label %24
24: ; preds = %24, %22
%25 = phi i64 [ 0, %22 ], [ %42, %24 ]
%26 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %22 ], [ %43, %24 ]
%27 = phi i64 [ 0, %22 ], [ %44, %24 ]
%28 = mul <16 x i32> %26, %14
%29 = add <16 x i32> %16, %28
%30 = urem <16 x i32> %29, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%31 = trunc <16 x i32> %30 to <16 x i8>
%32 = getelementptr inbounds i8, i8* %0, i64 %25
%33 = bitcast i8* %32 to <16 x i8>*
store <16 x i8> %31, <16 x i8>* %33
%34 = or i64 %25, 16
%35 = add <16 x i32> %26, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%36 = mul <16 x i32> %35, %14
%37 = add <16 x i32> %16, %36
%38 = urem <16 x i32> %37, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%39 = trunc <16 x i32> %38 to <16 x i8>
%40 = getelementptr inbounds i8, i8* %0, i64 %34
%41 = bitcast i8* %40 to <16 x i8>*
store <16 x i8> %39, <16 x i8>* %41
%42 = add nuw i64 %25, 32
%43 = add <16 x i32> %26, <i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32>
%44 = add i64 %27, 2
%45 = icmp eq i64 %44, %23
br i1 %45, label %46, label %24
46: ; preds = %24, %11
%47 = phi i64 [ 0, %11 ], [ %42, %24 ]
%48 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %11 ], [ %43, %24 ]
%49 = icmp eq i64 %20, 0
br i1 %49, label %57, label %50
50: ; preds = %46
%51 = mul <16 x i32> %48, %14
%52 = add <16 x i32> %16, %51
%53 = urem <16 x i32> %52, <i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255>
%54 = trunc <16 x i32> %53 to <16 x i8>
%55 = getelementptr inbounds i8, i8* %0, i64 %47
%56 = bitcast i8* %55 to <16 x i8>*
store <16 x i8> %54, <16 x i8>* %56
br label %57
57: ; preds = %46, %50
%58 = icmp eq i64 %12, %9
br i1 %58, label %71, label %59
59: ; preds = %6, %57
%60 = phi i64 [ 0, %6 ], [ %12, %57 ]
br label %61
61: ; preds = %59, %61
%62 = phi i64 [ %69, %61 ], [ %60, %59 ]
%63 = trunc i64 %62 to i32
%64 = mul i32 %63, %7
%65 = add i32 %8, %64
%66 = urem i32 %65, 255
%67 = trunc i32 %66 to i8
%68 = getelementptr inbounds i8, i8* %0, i64 %62
store i8 %67, i8* %68
%69 = add nuw nsw i64 %62, 1
%70 = icmp eq i64 %69, %9
br i1 %70, label %71, label %61
71: ; preds = %61, %57, %4
ret void
}