#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 const log(double const);
int /*<<< orphan*/ power_1(double *, double const *, double const *);
void bjs_value(const double r, const double *p, double *f) {
  if (r == 0.0)
    *f = 0.0;
  else {
    double power = 0.0;
    power_1(&power, &r, &p[1]);
    *f = p[0] * (1.0 - p[1] * log(r)) * power + p[2] * r;
  }
}


x86 assembly (clang, -O0):
<bjs_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115d <bjs_value+0x3d>
jp     115d <bjs_value+0x3d>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11fa <bjs_value+0xda>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdx
add    $0x8,%rdx
lea    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <power_1@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe31(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bjs_value>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1145 <bjs_value+0x25>
jp     1145 <bjs_value+0x25>
movq   $0x0,(%r14)
jmp    11b6 <bjs_value+0x96>
mov    %rdi,%rbx
movq   $0x0,0x10(%rsp)
lea    0x8(%rdi),%rdx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <power_1@plt>
movsd  (%rbx),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0xe6e(%rip),%xmm1
subsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
movsd  0x10(%rbx),%xmm0
mulsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @bjs_value(double %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
store double %0, double* %4
store double* %1, double** %5
store double* %2, double** %6
%8 = load double, double* %4
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = load double*, double** %6
store double 0.000000e+00, double* %11
br label %35
12: ; preds = %3
store double 0.000000e+00, double* %7
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = call i32 @power_1(double* %7, double* %4, double* %14)
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = load double, double* %4
%23 = call double @log(double %22)
%24 = fneg double %21
%25 = call double @llvm.fmuladd.f64(double %24, double %23, double 1.000000e+00)
%26 = fmul double %18, %25
%27 = load double, double* %7
%28 = load double*, double** %5
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = load double, double* %4
%32 = fmul double %30, %31
%33 = call double @llvm.fmuladd.f64(double %26, double %27, double %32)
%34 = load double*, double** %6
store double %33, double* %34
br label %35
35: ; preds = %12, %10
ret void
}

LLVM IR (-O2):
define void @bjs_value(double %0, double* %1, double* nocapture writeonly %2) {
%4 = alloca double
%5 = alloca double
store double %0, double* %4
%6 = fcmp oeq double %0, 0.000000e+00
br i1 %6, label %7, label %8
7: ; preds = %3
store double 0.000000e+00, double* %2
br label %25
8: ; preds = %3
%9 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = call i32 @power_1(double* %5, double* %4, double* %10)
%12 = load double, double* %1
%13 = load double, double* %10
%14 = load double, double* %4
%15 = call double @log(double %14)
%16 = fneg double %13
%17 = call double @llvm.fmuladd.f64(double %16, double %15, double 1.000000e+00)
%18 = fmul double %12, %17
%19 = load double, double* %5
%20 = getelementptr inbounds double, double* %1, i64 2
%21 = load double, double* %20
%22 = load double, double* %4
%23 = fmul double %21, %22
%24 = call double @llvm.fmuladd.f64(double %18, double %19, double %23)
store double %24, double* %2
br label %25
25: ; preds = %8, %7
ret void
}