#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);
double pow(double, double const);
double cross_section_compute(int mode, int proget, double *cs0, double *cs1,
                             double p1, double p2) {
  if (mode == 0) {
    return cs0[proget] * (1. - p1) + cs1[proget] * p1;
  } else {
    const double a = log(cs1[proget] / cs0[proget]) * p1;
    return cs0[proget] * pow(p2, a);
  }
}


x86 assembly (clang, -O0):
<cross_section_compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1188 <cross_section_compute+0x68>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xea1(%rip),%xmm2
subsd  -0x28(%rbp),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <cross_section_compute+0xc3>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
call   1030 <log@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cross_section_compute>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movapd %xmm0,%xmm2
mov    %rdx,%r14
movslq %esi,%rbx
test   %edi,%edi
je     117a <cross_section_compute+0x5a>
movsd  (%rcx,%rbx,8),%xmm0
divsd  (%r14,%rbx,8),%xmm0
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1030 <log@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0x8(%rsp),%xmm0
jmp    1195 <cross_section_compute+0x75>
movsd  0xe7e(%rip),%xmm0
subsd  %xmm2,%xmm0
mulsd  (%rcx,%rbx,8),%xmm2
mulsd  (%r14,%rbx,8),%xmm0
addsd  %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define double @cross_section_compute(i32 %0, i32 %1, double* nocapture %2, double* nocapture %3, double %4, double %5) {
%7 = icmp eq i32 %0, 0
%8 = sext i32 %1 to i64
br i1 %7, label %9, label %17
9: ; preds = %6
%10 = getelementptr inbounds double, double* %2, i64 %8
%11 = load double, double* %10
%12 = fsub double 1.000000e+00, %4
%13 = getelementptr inbounds double, double* %3, i64 %8
%14 = load double, double* %13
%15 = fmul double %14, %4
%16 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %15)
br label %28
17: ; preds = %6
%18 = getelementptr inbounds double, double* %3, i64 %8
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %2, i64 %8
%21 = load double, double* %20
%22 = fdiv double %19, %21
%23 = tail call double @log(double %22)
%24 = fmul double %23, %4
%25 = load double, double* %20
%26 = tail call double @pow(double %5, double %24)
%27 = fmul double %25, %26
br label %28
28: ; preds = %17, %9
%29 = phi double [ %16, %9 ], [ %27, %17 ]
ret double %29
}