#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 */
int get_value(unsigned int, int);
int /*<<< orphan*/ srand(int);
void init_buffer(void *src, int size, int rshift) {
  unsigned int i;
  int *_src = (int *)src;
  srand(1);
  for (i = 0; i < size / sizeof(int); ++i) {
    _src[i] = get_value(i, rshift);
  }
}


x86 assembly (clang, -O0):
<init_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movslq -0xc(%rbp),%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
jae    1184 <init_buffer+0x64>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <get_value@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <init_buffer+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_buffer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0x1,%edi
call   1030 <srand@plt>
cmp    $0x4,%ebp
jb     1166 <init_buffer+0x46>
movslq %ebp,%rbx
shr    $0x2,%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14d,%esi
call   1040 <get_value@plt>
mov    %eax,(%r15,%rbp,4)
add    $0x1,%ebp
cmp    %rbp,%rbx
ja     1150 <init_buffer+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @init_buffer(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %8
%11 = call i32 @srand(i32 1)
store i32 0, i32* %7
br label %12
12: ; preds = %27, %3
%13 = load i32, i32* %7
%14 = zext i32 %13 to i64
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = udiv i64 %16, 4
%18 = icmp ult i64 %14, %17
br i1 %18, label %19, label %30
19: ; preds = %12
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = call i32 @get_value(i32 %20, i32 %21)
%23 = load i32*, i32** %8
%24 = load i32, i32* %7
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
br label %27
27: ; preds = %19
%28 = load i32, i32* %7
%29 = add i32 %28, 1
store i32 %29, i32* %7
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @init_buffer(i8* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = bitcast i8* %0 to i32*
%5 = tail call i32 @srand(i32 1)
%6 = sext i32 %1 to i64
%7 = lshr i64 %6, 2
%8 = icmp ult i32 %1, 4
br i1 %8, label %17, label %9
9: ; preds = %3, %9
%10 = phi i64 [ %15, %9 ], [ 0, %3 ]
%11 = trunc i64 %10 to i32
%12 = tail call i32 @get_value(i32 %11, i32 %2)
%13 = getelementptr inbounds i32, i32* %4, i64 %10
store i32 %12, i32* %13
%14 = add nuw nsw i64 %10, 1
%15 = and i64 %14, 4294967295
%16 = icmp ugt i64 %7, %15
br i1 %16, label %9, label %17
17: ; preds = %9, %3
ret void
}