#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 */
typedef size_t K;

/* Variables and functions */
int /*<<< orphan*/ resample_post_theta(int, int, int **, int *, double **,
                                       double **, double *, int *, int ***);
void initialize_post_theta(double **post_theta, double **post_theta_train,
                           int *entity_map, double *global_topic_counts, int D,
                           int K, int **M, int *N, int ***z) {
  int dvv_loop_var_1;
  int dvv_loop_var_2;
  for (dvv_loop_var_1 = 1; dvv_loop_var_1 <= D; dvv_loop_var_1++) {
    for (dvv_loop_var_2 = 1; dvv_loop_var_2 <= K; dvv_loop_var_2++) {
      post_theta[dvv_loop_var_1 - 1][dvv_loop_var_2 - 1] = 0.0;
    }
    post_theta[dvv_loop_var_1 - 1][(K) + (1) - 1] = (0.0) * (((1) + (K)) - (1));
  }
  resample_post_theta(D, K, M, N, post_theta, post_theta_train,
                      global_topic_counts, entity_map, z);
}


x86 assembly (clang, -O0):
<initialize_post_theta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11d6 <initialize_post_theta+0xc6>
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     1192 <initialize_post_theta+0x82>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1156 <initialize_post_theta+0x46>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
xorps  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1143 <initialize_post_theta+0x33>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    0x10(%rbp),%rdx
mov    0x18(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x10(%rbp),%r9
mov    -0x20(%rbp),%r11
mov    -0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <resample_post_theta@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_post_theta>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,%ebp
mov    %rcx,%r15
mov    %rdx,%rax
mov    %rsi,%r9
mov    %rdi,%r12
mov    0x90(%rsp),%rbx
test   %r8d,%r8d
jle    11f5 <initialize_post_theta+0xd5>
cvtsi2sd %ebp,%xmm0
xorpd  %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movslq %ebp,%r13
mov    %r13d,%ecx
shl    $0x3,%rcx
mov    %rcx,0x10(%rsp)
mov    %r8d,%ecx
cmp    $0x1,%r8d
mov    %r15,0x38(%rsp)
mov    %rax,0x28(%rsp)
mov    %r9,0x20(%rsp)
mov    %r8d,0xc(%rsp)
mov    %rcx,0x30(%rsp)
jne    1229 <initialize_post_theta+0x109>
xor    %r14d,%r14d
testb  $0x1,0x30(%rsp)
mov    0x38(%rsp),%r15
mov    0x28(%rsp),%rax
mov    0x20(%rsp),%r9
mov    0x90(%rsp),%rbx
mov    0xc(%rsp),%r8d
je     11f5 <initialize_post_theta+0xd5>
mov    (%r12,%r14,8),%rbx
test   %ebp,%ebp
jle    11d2 <initialize_post_theta+0xb2>
mov    %rbx,%rdi
xor    %esi,%esi
mov    0x10(%rsp),%rdx
call   1030 <memset@plt>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rbx,%r13,8)
mov    0x28(%rsp),%rax
mov    0x20(%rsp),%r9
mov    0x90(%rsp),%rbx
mov    0xc(%rsp),%r8d
sub    $0x8,%rsp
mov    %r8d,%edi
mov    %ebp,%esi
mov    0x88(%rsp),%rdx
mov    0x90(%rsp),%rcx
mov    %r12,%r8
push   %rbx
push   %rax
push   %r15
call   1040 <resample_post_theta@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffe,%ecx
mov    %rcx,0x40(%rsp)
xor    %r14d,%r14d
jmp    125b <initialize_post_theta+0x13b>
cs nopw 0x0(%rax,%rax,1)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rbx,%r13,8)
add    $0x2,%r14
cmp    %r14,0x40(%rsp)
je     1198 <initialize_post_theta+0x78>
mov    (%r12,%r14,8),%r15
test   %ebp,%ebp
jle    1272 <initialize_post_theta+0x152>
mov    %r15,%rdi
xor    %esi,%esi
mov    0x10(%rsp),%rdx
call   1030 <memset@plt>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%r15,%r13,8)
mov    0x8(%r12,%r14,8),%rbx
test   %ebp,%ebp
jle    1240 <initialize_post_theta+0x120>
mov    %rbx,%rdi
xor    %esi,%esi
mov    0x10(%rsp),%rdx
call   1030 <memset@plt>
jmp    1240 <initialize_post_theta+0x120>

LLVM IR (-O0):
define void @initialize_post_theta(double** %0, double** %1, i32* %2, double* %3, i32 %4, i32 %5, i32** %6, i32* %7, i32*** %8) {
%10 = alloca double**
%11 = alloca double**
%12 = alloca i32*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32**
%17 = alloca i32*
%18 = alloca i32***
%19 = alloca i32
%20 = alloca i32
store double** %0, double*** %10
store double** %1, double*** %11
store i32* %2, i32** %12
store double* %3, double** %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32** %6, i32*** %16
store i32* %7, i32** %17
store i32*** %8, i32**** %18
store i32 1, i32* %19
br label %21
21: ; preds = %61, %9
%22 = load i32, i32* %19
%23 = load i32, i32* %14
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %64
25: ; preds = %21
store i32 1, i32* %20
br label %26
26: ; preds = %41, %25
%27 = load i32, i32* %20
%28 = load i32, i32* %15
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %44
30: ; preds = %26
%31 = load double**, double*** %10
%32 = load i32, i32* %19
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double*, double** %31, i64 %34
%36 = load double*, double** %35
%37 = load i32, i32* %20
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %36, i64 %39
store double 0.000000e+00, double* %40
br label %41
41: ; preds = %30
%42 = load i32, i32* %20
%43 = add nsw i32 %42, 1
store i32 %43, i32* %20
br label %26
44: ; preds = %26
%45 = load i32, i32* %15
%46 = add nsw i32 1, %45
%47 = sub nsw i32 %46, 1
%48 = sitofp i32 %47 to double
%49 = fmul double 0.000000e+00, %48
%50 = load double**, double*** %10
%51 = load i32, i32* %19
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double*, double** %50, i64 %53
%55 = load double*, double** %54
%56 = load i32, i32* %15
%57 = add nsw i32 %56, 1
%58 = sub nsw i32 %57, 1
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %55, i64 %59
store double %49, double* %60
br label %61
61: ; preds = %44
%62 = load i32, i32* %19
%63 = add nsw i32 %62, 1
store i32 %63, i32* %19
br label %21
64: ; preds = %21
%65 = load i32, i32* %14
%66 = load i32, i32* %15
%67 = load i32**, i32*** %16
%68 = load i32*, i32** %17
%69 = load double**, double*** %10
%70 = load double**, double*** %11
%71 = load double*, double** %13
%72 = load i32*, i32** %12
%73 = load i32***, i32**** %18
%74 = call i32 @resample_post_theta(i32 %65, i32 %66, i32** %67, i32* %68, double** %69, double** %70, double* %71, i32* %72, i32*** %73)
ret void
}

LLVM IR (-O2):
define void @initialize_post_theta(double** %0, double** %1, i32* %2, double* %3, i32 %4, i32 %5, i32** %6, i32* %7, i32*** %8) {
%10 = icmp slt i32 %4, 1
br i1 %10, label %54, label %11
11: ; preds = %9
%12 = icmp slt i32 %5, 1
%13 = sitofp i32 %5 to double
%14 = fmul double %13, 0.000000e+00
%15 = sext i32 %5 to i64
%16 = zext i32 %5 to i64
%17 = shl nuw nsw i64 %16, 3
%18 = zext i32 %4 to i64
%19 = and i64 %18, 1
%20 = icmp eq i32 %4, 1
br i1 %20, label %44, label %21
21: ; preds = %11
%22 = and i64 %18, 4294967294
br label %23
23: ; preds = %37, %21
%24 = phi i64 [ 1, %21 ], [ %39, %37 ]
%25 = phi i64 [ 0, %21 ], [ %40, %37 ]
%26 = add nsw i64 %24, -1
%27 = getelementptr inbounds double*, double** %0, i64 %26
%28 = load double*, double** %27
br i1 %12, label %31, label %29
29: ; preds = %23
%30 = bitcast double* %28 to i8*
br label %31
31: ; preds = %23, %29
%32 = getelementptr inbounds double, double* %28, i64 %15
store double %14, double* %32
%33 = getelementptr inbounds double*, double** %0, i64 %24
%34 = load double*, double** %33
br i1 %12, label %37, label %35
35: ; preds = %31
%36 = bitcast double* %34 to i8*
br label %37
37: ; preds = %35, %31
%38 = getelementptr inbounds double, double* %34, i64 %15
store double %14, double* %38
%39 = add nuw nsw i64 %24, 2
%40 = add i64 %25, 2
%41 = icmp eq i64 %40, %22
br i1 %41, label %42, label %23
42: ; preds = %37
%43 = add nuw i64 %24, 1
br label %44
44: ; preds = %42, %11
%45 = phi i64 [ 0, %11 ], [ %43, %42 ]
%46 = icmp eq i64 %19, 0
br i1 %46, label %54, label %47
47: ; preds = %44
%48 = getelementptr inbounds double*, double** %0, i64 %45
%49 = load double*, double** %48
br i1 %12, label %52, label %50
50: ; preds = %47
%51 = bitcast double* %49 to i8*
br label %52
52: ; preds = %50, %47
%53 = getelementptr inbounds double, double* %49, i64 %15
store double %14, double* %53
br label %54
54: ; preds = %52, %44, %9
%55 = tail call i32 @resample_post_theta(i32 %4, i32 %5, i32** %6, i32* %7, double** %0, double** %1, double* %3, i32* %2, i32*** %8)
ret void
}