#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 log(double);
int /*<<< orphan*/ normalize_loglikely_vector(double *, int);
void RootSequenceDistribution(double smx[20][20], double *pri, double *ct,
                              double *rd) {
  int child;
  int root;
  for (root = 0; root < 20; root++) {
    rd[root] = log(pri[root]);
    for (child = 0; child < 20; child++)
      rd[root] += ct[child] * smx[root][child];
  }
  normalize_loglikely_vector(rd, 20);
}


x86 assembly (clang, -O0):
<RootSequenceDistribution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x14,-0x28(%rbp)
jge    11dc <RootSequenceDistribution+0xbc>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <log@plt>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x24(%rbp)
cmpl   $0x14,-0x24(%rbp)
jge    11c9 <RootSequenceDistribution+0xa9>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116f <RootSequenceDistribution+0x4f>
jmp    11ce <RootSequenceDistribution+0xae>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113f <RootSequenceDistribution+0x1f>
mov    -0x20(%rbp),%rdi
mov    $0x14,%esi
call   1030 <normalize_loglikely_vector@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RootSequenceDistribution>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r13
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
call   1040 <log@plt>
movsd  %xmm0,(%r14,%rbx,8)
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
movsd  -0x8(%r12,%rax,8),%xmm1
mulsd  -0x8(%r13,%rax,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
movsd  (%r12,%rax,8),%xmm0
mulsd  0x0(%r13,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x2,%rax
cmp    $0x15,%rax
jne    1160 <RootSequenceDistribution+0x40>
add    $0x1,%rbx
add    $0xa0,%r13
cmp    $0x14,%rbx
jne    1140 <RootSequenceDistribution+0x20>
mov    %r14,%rdi
mov    $0x14,%esi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <normalize_loglikely_vector@plt>

LLVM IR (-O0):
define void @RootSequenceDistribution([20 x double]* %0, double* %1, double* %2, double* %3) {
%5 = alloca [20 x double]*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
store [20 x double]* %0, [20 x double]** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store i32 0, i32* %10
br label %11
11: ; preds = %52, %4
%12 = load i32, i32* %10
%13 = icmp slt i32 %12, 20
br i1 %13, label %14, label %55
14: ; preds = %11
%15 = load double*, double** %6
%16 = load i32, i32* %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = call double @log(double %19)
%21 = load double*, double** %8
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
store double %20, double* %24
store i32 0, i32* %9
br label %25
25: ; preds = %48, %14
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 20
br i1 %27, label %28, label %51
28: ; preds = %25
%29 = load double*, double** %7
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load [20 x double]*, [20 x double]** %5
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x double], [20 x double]* %34, i64 %36
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [20 x double], [20 x double]* %37, i64 0, i64 %39
%41 = load double, double* %40
%42 = load double*, double** %8
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = call double @llvm.fmuladd.f64(double %33, double %41, double %46)
store double %47, double* %45
br label %48
48: ; preds = %28
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %25
51: ; preds = %25
br label %52
52: ; preds = %51
%53 = load i32, i32* %10
%54 = add nsw i32 %53, 1
store i32 %54, i32* %10
br label %11
55: ; preds = %11
%56 = load double*, double** %8
%57 = call i32 @normalize_loglikely_vector(double* %56, i32 20)
ret void
}

LLVM IR (-O2):
define void @RootSequenceDistribution([20 x double]* nocapture %0, double* nocapture %1, double* nocapture %2, double* %3) {
br label %5
5: ; preds = %4, %27
%6 = phi i64 [ 0, %4 ], [ %28, %27 ]
%7 = getelementptr inbounds double, double* %1, i64 %6
%8 = load double, double* %7
%9 = tail call double @log(double %8)
%10 = getelementptr inbounds double, double* %3, i64 %6
store double %9, double* %10
br label %11
11: ; preds = %11, %5
%12 = phi double [ %9, %5 ], [ %24, %11 ]
%13 = phi i64 [ 0, %5 ], [ %25, %11 ]
%14 = getelementptr inbounds double, double* %2, i64 %13
%15 = load double, double* %14
%16 = getelementptr inbounds [20 x double], [20 x double]* %0, i64 %6, i64 %13
%17 = load double, double* %16
%18 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %12)
store double %18, double* %10
%19 = or i64 %13, 1
%20 = getelementptr inbounds double, double* %2, i64 %19
%21 = load double, double* %20
%22 = getelementptr inbounds [20 x double], [20 x double]* %0, i64 %6, i64 %19
%23 = load double, double* %22
%24 = tail call double @llvm.fmuladd.f64(double %21, double %23, double %18)
store double %24, double* %10
%25 = add nuw nsw i64 %13, 2
%26 = icmp eq i64 %25, 20
br i1 %26, label %27, label %11
27: ; preds = %11
%28 = add nuw nsw i64 %6, 1
%29 = icmp eq i64 %28, 20
br i1 %29, label %30, label %5
30: ; preds = %27
%31 = tail call i32 @normalize_loglikely_vector(double* %3, i32 20)
ret void
}