#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 /*<<< orphan*/ AppendDebugTraceFile(char *);
double rand1();
void InitReserve(int puno, double prop, int *R) {
  int i;
  AppendDebugTraceFile("InitReserve start\n");
  for (i = 0; i < puno; i++)
    R[i] = rand1() < prop ? 1 : 0;
  AppendDebugTraceFile("InitReserve end\n");
}


x86 assembly (clang, -O0):
<InitReserve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xec5(%rip),%rdi
call   1040 <AppendDebugTraceFile@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1189 <InitReserve+0x69>
mov    $0x0,%al
call   1030 <rand1@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
xor    %edx,%edx
mov    $0x1,%eax
ucomisd %xmm1,%xmm0
cmova  %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1147 <InitReserve+0x27>
lea    0xe83(%rip),%rdi
call   1040 <AppendDebugTraceFile@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InitReserve>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebp
lea    0xec6(%rip),%rdi
call   1040 <AppendDebugTraceFile@plt>
test   %ebp,%ebp
jle    1173 <InitReserve+0x53>
mov    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand1@plt>
xor    %eax,%eax
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %al
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <InitReserve+0x30>
lea    0xe99(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <AppendDebugTraceFile@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"InitReserve start\0A\00"
@.str.1 = [17 x i8] c"InitReserve end\0A\00"
define void @InitReserve(i32 %0, double %1, i32* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store i32* %2, i32** %6
%8 = call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %9
9: ; preds = %23, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = call double (...) @rand1()
%15 = load double, double* %5
%16 = fcmp olt double %14, %15
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 1, i32 0
%19 = load i32*, i32** %6
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %13
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %9
26: ; preds = %9
%27 = call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"InitReserve start\0A\00"
@.str.1 = [17 x i8] c"InitReserve end\0A\00"
define void @InitReserve(i32 %0, double %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %14, %8 ]
%10 = tail call double (...) @rand1()
%11 = fcmp olt double %10, %1
%12 = zext i1 %11 to i32
%13 = getelementptr inbounds i32, i32* %2, i64 %9
store i32 %12, i32* %13
%14 = add nuw nsw i64 %9, 1
%15 = icmp eq i64 %14, %7
br i1 %15, label %16, label %8
16: ; preds = %8, %3
%17 = tail call i32 @AppendDebugTraceFile(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
ret void
}