#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 get_scaled_llr(double, int, double *, double *);
void brute1(int A, double *dd, int N, double alpha, double *o, double *e,
            double *p, double prob) {
  int i;
  int llr;
  if (N == 0) {
    llr = get_scaled_llr(alpha, A, o, e);
    p[llr] += prob;
  } else {
    for (i = 0; i < A; i++) {
      o[i]++;
      brute1(A, dd, N - 1, alpha, o, e, p, prob * dd[i]);
      o[i]--;
    }
  }
}


x86 assembly (clang, -O0):
<brute1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1186 <brute1+0x66>
movsd  -0x20(%rbp),%xmm0
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <get_scaled_llr@plt>
mov    %eax,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x48(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1216 <brute1+0xf6>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1211 <brute1+0xf1>
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe5f(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
movsd  -0x40(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%r10
mulsd  (%rax,%r10,8),%xmm1
call   1040 <brute1@plt>
mov    -0x28(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xe07(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    118d <brute1+0x6d>
jmp    1216 <brute1+0xf6>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<brute1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movapd %xmm1,%xmm2
mov    %r9,%r13
mov    %r8,%r12
mov    %rcx,%rbx
mov    %edi,0xc(%rsp)
test   %edx,%edx
je     11e4 <brute1+0xc4>
cmpl   $0x0,0xc(%rsp)
jle    120f <brute1+0xef>
mov    %edx,%r14d
mov    %rsi,%rbp
add    $0xffffffff,%r14d
mov    0xc(%rsp),%eax
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
movsd  %xmm2,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%r15,8),%xmm1
addsd  0xe72(%rip),%xmm1
movsd  %xmm1,(%rbx,%r15,8)
movsd  0x0(%rbp,%r15,8),%xmm1
mulsd  %xmm2,%xmm1
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    %r14d,%edx
mov    %rbx,%rcx
mov    %r12,%r8
mov    %r13,%r9
call   1040 <brute1@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
movsd  (%rbx,%r15,8),%xmm1
addsd  0xe37(%rip),%xmm1
movsd  %xmm1,(%rbx,%r15,8)
add    $0x1,%r15
cmp    %r15,0x18(%rsp)
jne    1180 <brute1+0x60>
jmp    120f <brute1+0xef>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %r12,%rdx
movsd  %xmm2,0x10(%rsp)
call   1030 <get_scaled_llr@plt>
cltq
movsd  0x10(%rsp),%xmm0
addsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @brute1(i32 %0, double* nocapture %1, i32 %2, double %3, double* %4, double* %5, double* nocapture %6, double %7) {
%9 = icmp eq i32 %2, 0
br i1 %9, label %15, label %10
10: ; preds = %8
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %33
12: ; preds = %10
%13 = add nsw i32 %2, -1
%14 = zext i32 %0 to i64
br label %21
15: ; preds = %8
%16 = tail call i32 @get_scaled_llr(double %3, i32 %0, double* %4, double* %5)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %6, i64 %17
%19 = load double, double* %18
%20 = fadd double %19, %7
store double %20, double* %18
br label %33
21: ; preds = %12, %21
%22 = phi i64 [ 0, %12 ], [ %31, %21 ]
%23 = getelementptr inbounds double, double* %4, i64 %22
%24 = load double, double* %23
%25 = fadd double %24, 1.000000e+00
store double %25, double* %23
%26 = getelementptr inbounds double, double* %1, i64 %22
%27 = load double, double* %26
%28 = fmul double %27, %7
tail call void @brute1(i32 %0, double* %1, i32 %13, double %3, double* %4, double* %5, double* %6, double %28)
%29 = load double, double* %23
%30 = fadd double %29, -1.000000e+00
store double %30, double* %23
%31 = add nuw nsw i64 %22, 1
%32 = icmp eq i64 %31, %14
br i1 %32, label %33, label %21
33: ; preds = %21, %10, %15
ret void
}