#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 devlpl(double *, int *, double *);
double dlngam(double *);
int /*<<< orphan*/ ftnstop(char *);
double log(double);
double pow(double, double);
double dstrem(double *z) {
  static double coef[10] = {0.0e0,
                            0.0833333333333333333333333333333e0,
                            -0.00277777777777777777777777777778e0,
                            0.000793650793650793650793650793651e0,
                            -0.000595238095238095238095238095238e0,
                            0.000841750841750841750841750841751e0,
                            -0.00191752691752691752691752691753e0,
                            0.00641025641025641025641025641026e0,
                            -0.0295506535947712418300653594771e0,
                            0.179644372368830573164938490016e0};
  static int K1 = 10;
  static double dstrem, sterl, T2;
  if (*z <= 0.0e0) {
    ftnstop("nonpositive argument in DSTREM");
    return 66.6;
  }
  if (!(*z > 6.0e0))
    goto S10;
  T2 = 1.0e0 / pow(*z, 2.0);
  dstrem = devlpl(coef, &K1, &T2) * *z;
  goto S20;
S10:
  sterl = 0.91893853320467274178e0 + (*z - 0.5e0) * log(*z) - *z;
  dstrem = dlngam(z) - sterl;
S20:
  return dstrem;
}


x86 assembly (clang, -O0):
<dstrem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     118b <dstrem+0x3b>
lea    0xebc(%rip),%rdi
call   1060 <ftnstop@plt>
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1279 <dstrem+0x129>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe65(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11aa <dstrem+0x5a>
jmp    1205 <dstrem+0xb5>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe66(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe4e(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2eea(%rip)
lea    0x2e73(%rip),%rdi
lea    0x2ebc(%rip),%rsi
lea    0x2ed5(%rip),%rdx
call   1070 <devlpl@plt>
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,0x2eb0(%rip)
jmp    126c <dstrem+0x11c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xdfb(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdc9(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,0x2e65(%rip)
mov    -0x10(%rbp),%rdi
call   1030 <dlngam@plt>
subsd  0x2e54(%rip),%xmm0
movsd  %xmm0,0x2e44(%rip)
movsd  0x2e3c(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dstrem>:
push   %rbx
sub    $0x10,%rsp
movsd  (%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1198 <dstrem+0x58>
mov    %rdi,%rbx
ucomisd 0xeaa(%rip),%xmm0
jbe    11ae <dstrem+0x6e>
mulsd  %xmm0,%xmm0
movsd  0xeb4(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x2f40(%rip)
lea    0x2f39(%rip),%rdx
lea    0x2eca(%rip),%rdi
lea    0x2f13(%rip),%rsi
call   1060 <devlpl@plt>
mulsd  (%rbx),%xmm0
jmp    11ef <dstrem+0xaf>
lea    0xe89(%rip),%rdi
call   1050 <ftnstop@plt>
movsd  0xe54(%rip),%xmm0
jmp    11ef <dstrem+0xaf>
movsd  0xe5a(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <log@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xe45(%rip),%xmm0
subsd  (%rbx),%xmm0
movsd  %xmm0,0x2ed1(%rip)
mov    %rbx,%rdi
call   1030 <dlngam@plt>
subsd  0x2ec1(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@dstrem.coef = internal global [10 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0xBF66C16C16C16C17, double 0x3F4A01A01A01A01A, double 0xBF43813813813814, double 0x3F4B951E2B18FF23, double 0xBF5F6AB0D9993C7D, double 0x3F7A41A41A41A41A, double 0xBF9E4286CB0F5398, double 0x3FC6FE96381E0680]
@dstrem.K1 = internal global i32 10
@dstrem.dstrem = internal global double 0.000000e+00
@dstrem.sterl = internal global double 0.000000e+00
@dstrem.T2 = internal global double 0.000000e+00
@.str = [31 x i8] c"nonpositive argument in DSTREM\00"
define double @dstrem(double* %0) {
%2 = alloca double
%3 = alloca double*
store double* %0, double** %3
%4 = load double*, double** %3
%5 = load double, double* %4
%6 = fcmp ole double %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @ftnstop(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store double 6.660000e+01, double* %2
br label %40
9: ; preds = %1
%10 = load double*, double** %3
%11 = load double, double* %10
%12 = fcmp ogt double %11, 6.000000e+00
br i1 %12, label %14, label %13
13: ; preds = %9
br label %23
14: ; preds = %9
%15 = load double*, double** %3
%16 = load double, double* %15
%17 = call double @pow(double %16, double 2.000000e+00)
%18 = fdiv double 1.000000e+00, %17
store double %18, double* @dstrem.T2
%19 = call double @devlpl(double* getelementptr inbounds ([10 x double], [10 x double]* @dstrem.coef, i64 0, i64 0), i32* @dstrem.K1, double* @dstrem.T2)
%20 = load double*, double** %3
%21 = load double, double* %20
%22 = fmul double %19, %21
store double %22, double* @dstrem.dstrem
br label %38
23: ; preds = %13
%24 = load double*, double** %3
%25 = load double, double* %24
%26 = fsub double %25, 5.000000e-01
%27 = load double*, double** %3
%28 = load double, double* %27
%29 = call double @log(double %28)
%30 = call double @llvm.fmuladd.f64(double %26, double %29, double 0x3FED67F1C864BEB5)
%31 = load double*, double** %3
%32 = load double, double* %31
%33 = fsub double %30, %32
store double %33, double* @dstrem.sterl
%34 = load double*, double** %3
%35 = call double @dlngam(double* %34)
%36 = load double, double* @dstrem.sterl
%37 = fsub double %35, %36
store double %37, double* @dstrem.dstrem
br label %38
38: ; preds = %23, %14
%39 = load double, double* @dstrem.dstrem
store double %39, double* %2
br label %40
40: ; preds = %38, %7
%41 = load double, double* %2
ret double %41
}

LLVM IR (-O2):
@dstrem.coef = internal global [10 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0xBF66C16C16C16C17, double 0x3F4A01A01A01A01A, double 0xBF43813813813814, double 0x3F4B951E2B18FF23, double 0xBF5F6AB0D9993C7D, double 0x3F7A41A41A41A41A, double 0xBF9E4286CB0F5398, double 0x3FC6FE96381E0680]
@dstrem.K1 = internal global i32 10
@dstrem.sterl = internal unnamed_addr global double 0.000000e+00
@dstrem.T2 = internal global double 0.000000e+00
@.str = [31 x i8] c"nonpositive argument in DSTREM\00"
define double @dstrem(double* %0) {
%2 = load double, double* %0
%3 = fcmp ugt double %2, 0.000000e+00
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @ftnstop(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %23
6: ; preds = %1
%7 = fcmp ogt double %2, 6.000000e+00
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = fmul double %2, %2
%10 = fdiv double 1.000000e+00, %9
store double %10, double* @dstrem.T2
%11 = tail call double @devlpl(double* getelementptr inbounds ([10 x double], [10 x double]* @dstrem.coef, i64 0, i64 0), i32* @dstrem.K1, double* @dstrem.T2)
%12 = load double, double* %0
%13 = fmul double %11, %12
br label %23
14: ; preds = %6
%15 = fadd double %2, -5.000000e-01
%16 = tail call double @log(double %2)
%17 = tail call double @llvm.fmuladd.f64(double %15, double %16, double 0x3FED67F1C864BEB5)
%18 = load double, double* %0
%19 = fsub double %17, %18
store double %19, double* @dstrem.sterl
%20 = tail call double @dlngam(double* %0)
%21 = load double, double* @dstrem.sterl
%22 = fsub double %20, %21
br label %23
23: ; preds = %8, %14, %4
%24 = phi double [ 6.660000e+01, %4 ], [ %22, %14 ], [ %13, %8 ]
ret double %24
}