#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ dble_sum2(double *, int, int, double *, double);
int /*<<< orphan*/ free(double *);
double rand_gamma(int, double);
void update_alpha_beta(double *beta, double *alpha_beta, double epsilon, int D,
                       int M) {
  int d;
  int a = (int)1 + M / 2;
  double *bb = (double *)calloc(D, sizeof(double));
  dble_sum2(beta, D, M, bb, epsilon);
  alpha_beta[0] = rand_gamma(a + 999, 1.0 / (double)(bb[0] + 999));
  for (d = 1; d < D; d++)
    alpha_beta[d] = rand_gamma(a, 1.0 / (double)(bb[d]));
  free(bb);
}


x86 assembly (clang, -O0):
<update_alpha_beta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x30(%rbp),%rcx
movsd  -0x18(%rbp),%xmm0
call   1040 <dble_sum2@plt>
mov    -0x28(%rbp),%edi
add    $0x3e7,%edi
mov    -0x30(%rbp),%rax
movsd  0xe5e(%rip),%xmm1
addsd  (%rax),%xmm1
movsd  0xe4a(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1060 <rand_gamma@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1212 <update_alpha_beta+0xd2>
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xe13(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
call   1060 <rand_gamma@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ce <update_alpha_beta+0x8e>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_alpha_beta>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %edx,%r12d
movsd  %xmm0,(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %ecx,%r13d
shr    $0x1f,%r13d
add    %ecx,%r13d
sar    %r13d
mov    %edx,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %rax,%rcx
movsd  (%rsp),%xmm0
call   1040 <dble_sum2@plt>
lea    0x3e8(%r13),%edi
movsd  (%r15),%xmm1
addsd  0xe60(%rip),%xmm1
movsd  0xe60(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1060 <rand_gamma@plt>
movsd  %xmm0,(%r14)
cmp    $0x2,%r12d
jl     11f5 <update_alpha_beta+0xb5>
add    $0x1,%r13d
mov    %r12d,%ebp
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0xe30(%rip),%xmm0
divsd  (%r15,%rbx,8),%xmm0
mov    %r13d,%edi
call   1060 <rand_gamma@plt>
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11d0 <update_alpha_beta+0x90>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @update_alpha_beta(double* %0, double* %1, double %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%14 = load i32, i32* %10
%15 = sdiv i32 %14, 2
%16 = add nsw i32 1, %15
store i32 %16, i32* %12
%17 = load i32, i32* %9
%18 = call i64 @calloc(i32 %17, i32 8)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %13
%20 = load double*, double** %6
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = load double*, double** %13
%24 = load double, double* %8
%25 = call i32 @dble_sum2(double* %20, i32 %21, i32 %22, double* %23, double %24)
%26 = load i32, i32* %12
%27 = add nsw i32 %26, 999
%28 = load double*, double** %13
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = fadd double %30, 9.990000e+02
%32 = fdiv double 1.000000e+00, %31
%33 = call double @rand_gamma(i32 %27, double %32)
%34 = load double*, double** %7
%35 = getelementptr inbounds double, double* %34, i64 0
store double %33, double* %35
store i32 1, i32* %11
br label %36
36: ; preds = %53, %5
%37 = load i32, i32* %11
%38 = load i32, i32* %9
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %56
40: ; preds = %36
%41 = load i32, i32* %12
%42 = load double*, double** %13
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = fdiv double 1.000000e+00, %46
%48 = call double @rand_gamma(i32 %41, double %47)
%49 = load double*, double** %7
%50 = load i32, i32* %11
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
store double %48, double* %52
br label %53
53: ; preds = %40
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %36
56: ; preds = %36
%57 = load double*, double** %13
%58 = call i32 @free(double* %57)
ret void
}

LLVM IR (-O2):
define void @update_alpha_beta(double* %0, double* nocapture writeonly %1, double %2, i32 %3, i32 %4) {
%6 = sdiv i32 %4, 2
%7 = add nsw i32 %6, 1
%8 = tail call i64 @calloc(i32 %3, i32 8)
%9 = inttoptr i64 %8 to double*
%10 = tail call i32 @dble_sum2(double* %0, i32 %3, i32 %4, double* %9, double %2)
%11 = add nsw i32 %6, 1000
%12 = load double, double* %9
%13 = fadd double %12, 9.990000e+02
%14 = fdiv double 1.000000e+00, %13
%15 = tail call double @rand_gamma(i32 %11, double %14)
store double %15, double* %1
%16 = icmp sgt i32 %3, 1
br i1 %16, label %17, label %28
17: ; preds = %5
%18 = zext i32 %3 to i64
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 1, %17 ], [ %26, %19 ]
%21 = getelementptr inbounds double, double* %9, i64 %20
%22 = load double, double* %21
%23 = fdiv double 1.000000e+00, %22
%24 = tail call double @rand_gamma(i32 %7, double %23)
%25 = getelementptr inbounds double, double* %1, i64 %20
store double %24, double* %25
%26 = add nuw nsw i64 %20, 1
%27 = icmp eq i64 %26, %18
br i1 %27, label %28, label %19
28: ; preds = %19, %5
%29 = tail call i32 @free(double* %9)
ret void
}