#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 ascprob_subsample(int, int, int, int);
void ascbias_adjust_expect(double *fsp, int n, int min_obs, int d) {
  int i;
  double asc_sum;
  asc_sum = 0;
  for (i = 0; i <= n; i++)
    asc_sum += fsp[i] * ascprob_subsample(i, d, min_obs, n);
  for (i = 0; i <= n; i++)
    fsp[i] = fsp[i] * ascprob_subsample(i, d, min_obs, n) / asc_sum;
}


x86 assembly (clang, -O0):
<ascbias_adjust_expect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     118b <ascbias_adjust_expect+0x7b>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1030 <ascprob_subsample@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <ascbias_adjust_expect+0x24>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11ed <ascbias_adjust_expect+0xdd>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1030 <ascprob_subsample@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1192 <ascbias_adjust_expect+0x82>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ascbias_adjust_expect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
js     11d1 <ascbias_adjust_expect+0xc1>
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
lea    0x1(%r12),%r13d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
nopl   (%rax)
movsd  %xmm1,0x10(%rsp)
movsd  0x0(%rbp,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1030 <ascprob_subsample@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <ascbias_adjust_expect+0x30>
test   %r12d,%r12d
js     11d1 <ascbias_adjust_expect+0xc1>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm1,0x10(%rsp)
movsd  0x0(%rbp,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1030 <ascprob_subsample@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <ascbias_adjust_expect+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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