#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("Zero or negative argument in DSTREM");
  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    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     1179 <dstrem+0x29>
lea    0xeb4(%rip),%rdi
call   1060 <ftnstop@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe77(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1198 <dstrem+0x48>
jmp    11f3 <dstrem+0xa3>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe78(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe60(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2efc(%rip)
lea    0x2e85(%rip),%rdi
lea    0x2ece(%rip),%rsi
lea    0x2ee7(%rip),%rdx
call   1070 <devlpl@plt>
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,0x2ec2(%rip)
jmp    125a <dstrem+0x10a>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe0d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xddb(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,0x2e77(%rip)
mov    -0x8(%rbp),%rdi
call   1030 <dlngam@plt>
subsd  0x2e66(%rip),%xmm0
movsd  %xmm0,0x2e56(%rip)
movsd  0x2e4e(%rip),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dstrem>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jb     1166 <dstrem+0x26>
lea    0xec3(%rip),%rdi
call   1050 <ftnstop@plt>
movsd  (%rbx),%xmm0
ucomisd 0xe92(%rip),%xmm0
jbe    11a8 <dstrem+0x68>
mulsd  %xmm0,%xmm0
movsd  0xe9c(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x2f30(%rip)
lea    0x2f29(%rip),%rdx
lea    0x2eba(%rip),%rdi
lea    0x2f03(%rip),%rsi
call   1060 <devlpl@plt>
mulsd  (%rbx),%xmm0
jmp    11e9 <dstrem+0xa9>
movsd  0xe58(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <log@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xe43(%rip),%xmm0
subsd  (%rbx),%xmm0
movsd  %xmm0,0x2ed7(%rip)
mov    %rbx,%rdi
call   1030 <dlngam@plt>
subsd  0x2ec7(%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 = [36 x i8] c"Zero or negative argument in DSTREM\00"
define double @dstrem(double* %0) {
%2 = alloca double*
store double* %0, double** %2
%3 = load double*, double** %2
%4 = load double, double* %3
%5 = fcmp ole double %4, 0.000000e+00
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @ftnstop(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load double*, double** %2
%10 = load double, double* %9
%11 = fcmp ogt double %10, 6.000000e+00
br i1 %11, label %13, label %12
12: ; preds = %8
br label %22
13: ; preds = %8
%14 = load double*, double** %2
%15 = load double, double* %14
%16 = call double @pow(double %15, double 2.000000e+00)
%17 = fdiv double 1.000000e+00, %16
store double %17, double* @dstrem.T2
%18 = call double @devlpl(double* getelementptr inbounds ([10 x double], [10 x double]* @dstrem.coef, i64 0, i64 0), i32* @dstrem.K1, double* @dstrem.T2)
%19 = load double*, double** %2
%20 = load double, double* %19
%21 = fmul double %18, %20
store double %21, double* @dstrem.dstrem
br label %37
22: ; preds = %12
%23 = load double*, double** %2
%24 = load double, double* %23
%25 = fsub double %24, 5.000000e-01
%26 = load double*, double** %2
%27 = load double, double* %26
%28 = call double @log(double %27)
%29 = call double @llvm.fmuladd.f64(double %25, double %28, double 0x3FED67F1C864BEB5)
%30 = load double*, double** %2
%31 = load double, double* %30
%32 = fsub double %29, %31
store double %32, double* @dstrem.sterl
%33 = load double*, double** %2
%34 = call double @dlngam(double* %33)
%35 = load double, double* @dstrem.sterl
%36 = fsub double %34, %35
store double %36, double* @dstrem.dstrem
br label %37
37: ; preds = %22, %13
%38 = load double, double* @dstrem.dstrem
ret double %38
}

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 = [36 x i8] c"Zero or negative 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 %7, label %4
4: ; preds = %1
%5 = tail call i32 @ftnstop(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = load double, double* %0
br label %7
7: ; preds = %4, %1
%8 = phi double [ %6, %4 ], [ %2, %1 ]
%9 = fcmp ogt double %8, 6.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = fmul double %8, %8
%12 = fdiv double 1.000000e+00, %11
store double %12, double* @dstrem.T2
%13 = 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)
%14 = load double, double* %0
%15 = fmul double %13, %14
br label %25
16: ; preds = %7
%17 = fadd double %8, -5.000000e-01
%18 = tail call double @log(double %8)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %18, double 0x3FED67F1C864BEB5)
%20 = load double, double* %0
%21 = fsub double %19, %20
store double %21, double* @dstrem.sterl
%22 = tail call double @dlngam(double* %0)
%23 = load double, double* @dstrem.sterl
%24 = fsub double %22, %23
br label %25
25: ; preds = %16, %10
%26 = phi double [ %24, %16 ], [ %15, %10 ]
ret double %26
}