#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 */
unsigned int rand();
int /*<<< orphan*/ srand(unsigned int);
void generate(unsigned char *buf, size_t size, unsigned int seed) {
  srand(seed);
  unsigned int *p = (unsigned int *)buf;
  for (size_t i = 0; i < size / sizeof(unsigned int); i++) {
    *p = rand();
    p++;
  }
}


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <srand@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
shr    $0x2,%rcx
cmp    %rcx,%rax
jae    118c <generate+0x6c>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    114b <generate+0x2b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %edx,%edi
call   1030 <srand@plt>
cmp    $0x4,%r15
jb     1154 <generate+0x34>
shr    $0x2,%r15
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <generate+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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