#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fwrite(double *, int, int, int /*<<< orphan*/ *);
int posterior_somedisk(int nstates, size_t nobs, const double *f_big,
                       const double *s_big, const double *b_big, FILE *fout_d) {
  size_t pos;
  double posterior;
  int i;
  const double *f_curr = f_big;
  const double *s_curr = s_big;
  const double *b_curr = b_big + nstates * (nobs - 1);
  for (pos = 0; pos < nobs; pos++) {
    for (i = 0; i < nstates; i++) {
      posterior = f_curr[i] * s_curr[0] * b_curr[i];
      fwrite(&posterior, sizeof(double), 1, fout_d);
    }
    f_curr += nstates;
    s_curr++;
    b_curr -= nstates;
  }
  return 0;
}


x86 assembly (clang, -O0):
<posterior_somedisk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    $0x1,%rdx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    121f <posterior_somedisk+0x10f>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d3 <posterior_somedisk+0xc3>
mov    -0x50(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x60(%rbp),%rax
movslq -0x44(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rcx
lea    -0x40(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117b <posterior_somedisk+0x6b>
mov    -0x4(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x58(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x60(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1166 <posterior_somedisk+0x56>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<posterior_somedisk>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edi,0x4(%rsp)
mov    %rsi,0x8(%rsp)
test   %rsi,%rsi
je     11ea <posterior_somedisk+0xda>
mov    %r9,%r13
mov    %rcx,%rbx
mov    %rdx,%r12
movslq 0x4(%rsp),%rcx
mov    0x8(%rsp),%rax
add    $0xffffffffffffffff,%rax
imul   %rcx,%rax
lea    (%r8,%rax,8),%rsi
mov    %ecx,%r15d
shl    $0x3,%rcx
mov    %rcx,0x18(%rsp)
neg    %rcx
mov    %rcx,0x10(%rsp)
xor    %eax,%eax
lea    0x30(%rsp),%r14
jmp    118e <posterior_somedisk+0x7e>
nopl   0x0(%rax)
add    $0x8,%rbx
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x10(%rsp),%rsi
add    0x18(%rsp),%r12
cmp    0x8(%rsp),%rax
je     11ea <posterior_somedisk+0xda>
mov    %rax,0x20(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    1170 <posterior_somedisk+0x60>
xor    %ebp,%ebp
mov    %rsi,0x28(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r12,%rbp,8),%xmm0
mulsd  (%rbx),%xmm0
mulsd  (%rsi,%rbp,8),%xmm0
movsd  %xmm0,0x30(%rsp)
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r13,%rcx
call   1030 <fwrite@plt>
mov    0x28(%rsp),%rsi
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11b0 <posterior_somedisk+0xa0>
jmp    1170 <posterior_somedisk+0x60>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @posterior_somedisk(i32 %0, i64 %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, i32* nocapture %5) {
%7 = alloca double
%8 = bitcast double* %7 to i8*
%9 = sext i32 %0 to i64
%10 = icmp eq i64 %1, 0
br i1 %10, label %41, label %11
11: ; preds = %6
%12 = add i64 %1, -1
%13 = mul i64 %12, %9
%14 = getelementptr inbounds double, double* %4, i64 %13
%15 = icmp sgt i32 %0, 0
%16 = sub nsw i64 0, %9
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %11, %35
%19 = phi double* [ %14, %11 ], [ %38, %35 ]
%20 = phi double* [ %3, %11 ], [ %37, %35 ]
%21 = phi double* [ %2, %11 ], [ %36, %35 ]
%22 = phi i64 [ 0, %11 ], [ %39, %35 ]
br i1 %15, label %23, label %35
23: ; preds = %18, %23
%24 = phi i64 [ %33, %23 ], [ 0, %18 ]
%25 = getelementptr inbounds double, double* %21, i64 %24
%26 = load double, double* %25
%27 = load double, double* %20
%28 = fmul double %26, %27
%29 = getelementptr inbounds double, double* %19, i64 %24
%30 = load double, double* %29
%31 = fmul double %28, %30
store double %31, double* %7
%32 = call i32 @fwrite(double* %7, i32 8, i32 1, i32* %5)
%33 = add nuw nsw i64 %24, 1
%34 = icmp eq i64 %33, %17
br i1 %34, label %35, label %23
35: ; preds = %23, %18
%36 = getelementptr inbounds double, double* %21, i64 %9
%37 = getelementptr inbounds double, double* %20, i64 1
%38 = getelementptr inbounds double, double* %19, i64 %16
%39 = add nuw i64 %22, 1
%40 = icmp eq i64 %39, %1
br i1 %40, label %41, label %18
41: ; preds = %35, %6
ret i32 0
}