#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 */
double RAND_MAX;
double rand();
void __sdel_random_buf(unsigned long bufsize, char *buf) {
  int loop;
  for (loop = 0; loop < bufsize; loop++)
    *buf++ = (unsigned char)(256.0 * rand() / (RAND_MAX + 1.0));
}


x86 assembly (clang, -O0):
<__sdel_random_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    1188 <__sdel_random_buf+0x78>
xor    %eax,%eax
call   1030 <rand@plt>
movsd  0xebc(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2e99(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xead(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <__sdel_random_buf+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sdel_random_buf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1161 <__sdel_random_buf+0x51>
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2ebe(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <rand@plt>
mulsd  0xec1(%rip),%xmm0
movsd  (%r15),%xmm1
addsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <__sdel_random_buf+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define void @__sdel_random_buf(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
store i64 %0, i64* %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %2
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = load i64, i64* %3
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = call double (...) @rand()
%13 = fmul double 2.560000e+02, %12
%14 = load double, double* @RAND_MAX
%15 = fadd double %14, 1.000000e+00
%16 = fdiv double %13, %15
%17 = fptoui double %16 to i8
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
store i8 %17, i8* %18
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
ret void
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define void @__sdel_random_buf(i64 %0, i8* nocapture writeonly %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %14, %4 ], [ 0, %2 ]
%6 = phi i8* [ %13, %4 ], [ %1, %2 ]
%7 = tail call double (...) @rand()
%8 = fmul double %7, 2.560000e+02
%9 = load double, double* @RAND_MAX
%10 = fadd double %9, 1.000000e+00
%11 = fdiv double %8, %10
%12 = fptoui double %11 to i8
%13 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %12, i8* %6
%14 = add nuw i64 %5, 1
%15 = icmp eq i64 %14, %0
br i1 %15, label %16, label %4
16: ; preds = %4, %2
ret void
}