#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);
void stretch_fun(double x, double *par, double *f, double *dfdx) {
  double xN, L_dx, scrh;
  xN = par[0];
  L_dx = par[1];
  scrh = x * (pow(x, xN) - 1.0) / (x - 1.0);
  *f = log(scrh) - log(L_dx);
  *dfdx =
      1.0 / x + xN * pow(x, xN - 1.0) / (pow(x, xN) - 1.0) - 1.0 / (x - 1.0);
}


x86 assembly (clang, -O0):
<stretch_fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
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
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  0xe83(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe6e(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe2c(%rip),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe06(%rip),%xmm2
subsd  %xmm2,%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <pow@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  0xdc8(%rip),%xmm3
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  0xdaf(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  0xda3(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stretch_fun>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movapd %xmm0,%xmm2
movsd  %xmm0,0x10(%rsp)
movsd  (%rdi),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x8(%rdi),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm0
call   1040 <pow@plt>
movsd  0xea3(%rip),%xmm3
addsd  %xmm3,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movapd %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x20(%rsp)
divsd  %xmm2,%xmm0
call   1030 <log@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  0xe61(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
addsd  0xe3b(%rip),%xmm1
call   1040 <pow@plt>
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <pow@plt>
movsd  0xe14(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  (%rsp),%xmm2
divsd  %xmm0,%xmm2
addsd  0x8(%rsp),%xmm2
divsd  0x20(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @stretch_fun(double %0, double* %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
store double %14, double* %9
%15 = load double*, double** %6
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
store double %17, double* %10
%18 = load double, double* %5
%19 = load double, double* %5
%20 = load double, double* %9
%21 = call double @pow(double %19, double %20)
%22 = fsub double %21, 1.000000e+00
%23 = fmul double %18, %22
%24 = load double, double* %5
%25 = fsub double %24, 1.000000e+00
%26 = fdiv double %23, %25
store double %26, double* %11
%27 = load double, double* %11
%28 = call double @log(double %27)
%29 = load double, double* %10
%30 = call double @log(double %29)
%31 = fsub double %28, %30
%32 = load double*, double** %7
store double %31, double* %32
%33 = load double, double* %5
%34 = fdiv double 1.000000e+00, %33
%35 = load double, double* %9
%36 = load double, double* %5
%37 = load double, double* %9
%38 = fsub double %37, 1.000000e+00
%39 = call double @pow(double %36, double %38)
%40 = fmul double %35, %39
%41 = load double, double* %5
%42 = load double, double* %9
%43 = call double @pow(double %41, double %42)
%44 = fsub double %43, 1.000000e+00
%45 = fdiv double %40, %44
%46 = fadd double %34, %45
%47 = load double, double* %5
%48 = fsub double %47, 1.000000e+00
%49 = fdiv double 1.000000e+00, %48
%50 = fsub double %46, %49
%51 = load double*, double** %8
store double %50, double* %51
ret void
}

LLVM IR (-O2):
define void @stretch_fun(double %0, double* nocapture %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = load double, double* %1
%6 = getelementptr inbounds double, double* %1, i64 1
%7 = load double, double* %6
%8 = tail call double @pow(double %0, double %5)
%9 = fadd double %8, -1.000000e+00
%10 = fmul double %9, %0
%11 = fadd double %0, -1.000000e+00
%12 = fdiv double %10, %11
%13 = tail call double @log(double %12)
%14 = tail call double @log(double %7)
%15 = fsub double %13, %14
store double %15, double* %2
%16 = fdiv double 1.000000e+00, %0
%17 = fadd double %5, -1.000000e+00
%18 = tail call double @pow(double %0, double %17)
%19 = fmul double %5, %18
%20 = tail call double @pow(double %0, double %5)
%21 = fadd double %20, -1.000000e+00
%22 = fdiv double %19, %21
%23 = fadd double %16, %22
%24 = fdiv double 1.000000e+00, %11
%25 = fsub double %23, %24
store double %25, double* %3
ret void
}