#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*/ fb_once(int, int, double *, double *, double *, double *,
                           double *, double *);
void forward_backward(int M, int T, int K, double *p_x_z, double *A, double *pi,
                      double *g, double *xi, double *ln_z) {
  int i = 0;
  for (i = 0; i < M; i++) {
    fb_once(T, K, &(p_x_z[i * T * K]), A, pi, &(g[i * T * K]),
            &(xi[i * (T - 1) * K * K]), ln_z);
  }
}


x86 assembly (clang, -O0):
<forward_backward>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d5 <forward_backward+0xc5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%eax
imul   -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    0x10(%rbp),%r9
mov    -0x2c(%rbp),%eax
imul   -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r9
mov    0x18(%rbp),%r10
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%r11d
sub    $0x1,%r11d
imul   %r11d,%eax
imul   -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r10
mov    0x20(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <fb_once@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1147 <forward_backward+0x37>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<forward_backward>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0x4(%rsp)
mov    %rsi,0x10(%rsp)
test   %edi,%edi
jle    11a9 <forward_backward+0x99>
mov    %r9,%rbx
mov    %r8,%rbp
mov    %rcx,%r14
mov    0x10(%rsp),%rsi
lea    -0x1(%rsi),%eax
mov    %edi,%r13d
mov    0x4(%rsp),%edx
mov    %edx,%edi
imul   %edx,%edi
imul   %eax,%edi
mov    %edi,0xc(%rsp)
imul   %esi,%edx
mov    %edx,0x8(%rsp)
xor    %r12d,%r12d
xor    %r15d,%r15d
nopl   0x0(%rax)
movslq %r12d,%r12
lea    (%r14,%r12,8),%rdx
mov    0x50(%rsp),%rax
lea    (%rax,%r12,8),%r9
movslq %r15d,%r15
mov    0x58(%rsp),%rax
lea    (%rax,%r15,8),%rax
mov    0x10(%rsp),%rdi
mov    0x4(%rsp),%esi
mov    %rbp,%rcx
mov    %rbx,%r8
push   0x60(%rsp)
push   %rax
call   1030 <fb_once@plt>
add    $0x10,%rsp
add    0xc(%rsp),%r15d
add    0x8(%rsp),%r12d
add    $0xffffffffffffffff,%r13
jne    1160 <forward_backward+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @forward_backward(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* %5, double* %6, double* %7, double* %8) {
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %29
11: ; preds = %9
%12 = add nsw i32 %1, -1
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %27, %14 ]
%16 = trunc i64 %15 to i32
%17 = mul i32 %16, %2
%18 = mul i32 %17, %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %3, i64 %19
%21 = getelementptr inbounds double, double* %6, i64 %19
%22 = mul i32 %17, %12
%23 = mul i32 %22, %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %7, i64 %24
%26 = tail call i32 @fb_once(i32 %1, i32 %2, double* %20, double* %4, double* %5, double* %21, double* %25, double* %8)
%27 = add nuw nsw i64 %15, 1
%28 = icmp eq i64 %27, %13
br i1 %28, label %29, label %14
29: ; preds = %14, %9
ret void
}