#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*/ bal1(double *, int);
double rangam(double);
int /*<<< orphan*/ vzero(double *, int);
void randirichlet(double *x, double *pp, int n) {
  int i;
  vzero(x, n);
  for (i = 0; i < n; i++) {
    if (pp[i] > 0.0) {
      x[i] = rangam(pp[i]);
    }
  }
  bal1(x, n);
}


x86 assembly (clang, -O0):
<randirichlet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <vzero@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ae <randirichlet+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    119b <randirichlet+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <rangam@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11a0 <randirichlet+0x70>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <randirichlet+0x26>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <bal1@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randirichlet>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%r15
mov    %edx,%esi
call   1050 <vzero@plt>
test   %r14d,%r14d
jle    1186 <randirichlet+0x56>
mov    %r14d,%ebx
xor    %ebp,%ebp
xorpd  %xmm1,%xmm1
jmp    1169 <randirichlet+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1186 <randirichlet+0x56>
movsd  (%r12,%rbp,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1160 <randirichlet+0x30>
call   1040 <rangam@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r15,%rbp,8)
jmp    1160 <randirichlet+0x30>
mov    %r15,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <bal1@plt>

LLVM IR (-O0):
define void @randirichlet(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%8 = load double*, double** %4
%9 = load i32, i32* %6
%10 = call i32 @vzero(double* %8, i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %34, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %11
%16 = load double*, double** %5
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %22, label %33
22: ; preds = %15
%23 = load double*, double** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = call double @rangam(double %27)
%29 = load double*, double** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %22, %15
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %11
37: ; preds = %11
%38 = load double*, double** %4
%39 = load i32, i32* %6
%40 = call i32 @bal1(double* %38, i32 %39)
ret void
}

LLVM IR (-O2):
define void @randirichlet(double* %0, double* nocapture %1, i32 %2) {
%4 = tail call i32 @vzero(double* %0, i32 %2)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %16
%9 = phi i64 [ 0, %6 ], [ %17, %16 ]
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = load double, double* %10
%12 = fcmp ogt double %11, 0.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = tail call double @rangam(double %11)
%15 = getelementptr inbounds double, double* %0, i64 %9
store double %14, double* %15
br label %16
16: ; preds = %8, %13
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, %7
br i1 %18, label %19, label %8
19: ; preds = %16, %3
%20 = tail call i32 @bal1(double* %0, i32 %2)
ret void
}