#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 exp(double);
int fabs(double);
double lgamma(double);
double log(double);
void gser(double *xptr, double a, double x, double *yptr) {
  double xp, yp, ap, sum, del;
  yp = lgamma(a);
  ap = a;
  sum = 1 / a;
  del = sum;
  while (fabs(del) > fabs(sum) * 1e-7) {
    ap++;
    del *= x / ap;
    sum += del;
  }
  xp = sum * exp(-x + a * log(x) - yp);
  *xptr = xp;
  *yptr = yp;
}


x86 assembly (clang, -O0):
<gser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <lgamma@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe85(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  -0x50(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
movsd  0xe4b(%rip),%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1205 <gser+0xc5>
movsd  0xe2d(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    118f <gser+0x4f>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <log@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gser>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
call   1050 <lgamma@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0xe94(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe65(%rip),%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1245 <gser+0x105>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  0xe28(%rip),%xmm2
movsd  %xmm2,0x30(%rsp)
movsd  0x18(%rsp),%xmm1
divsd  %xmm2,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  (%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x30(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdd1(%rip),%xmm0
movsd  0x28(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     11d0 <gser+0x90>
jmp    1250 <gser+0x110>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <log@plt>
mulsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
call   1040 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @gser(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
%12 = alloca double
%13 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%14 = load double, double* %6
%15 = call double @lgamma(double %14)
store double %15, double* %10
%16 = load double, double* %6
store double %16, double* %11
%17 = load double, double* %6
%18 = fdiv double 1.000000e+00, %17
store double %18, double* %12
%19 = load double, double* %12
store double %19, double* %13
br label %20
20: ; preds = %29, %4
%21 = load double, double* %13
%22 = call i32 @fabs(double %21)
%23 = sitofp i32 %22 to double
%24 = load double, double* %12
%25 = call i32 @fabs(double %24)
%26 = sitofp i32 %25 to double
%27 = fmul double %26, 0x3E7AD7F29ABCAF48
%28 = fcmp ogt double %23, %27
br i1 %28, label %29, label %40
29: ; preds = %20
%30 = load double, double* %11
%31 = fadd double %30, 1.000000e+00
store double %31, double* %11
%32 = load double, double* %7
%33 = load double, double* %11
%34 = fdiv double %32, %33
%35 = load double, double* %13
%36 = fmul double %35, %34
store double %36, double* %13
%37 = load double, double* %13
%38 = load double, double* %12
%39 = fadd double %38, %37
store double %39, double* %12
br label %20
40: ; preds = %20
%41 = load double, double* %12
%42 = load double, double* %7
%43 = fneg double %42
%44 = load double, double* %6
%45 = load double, double* %7
%46 = call double @log(double %45)
%47 = call double @llvm.fmuladd.f64(double %44, double %46, double %43)
%48 = load double, double* %10
%49 = fsub double %47, %48
%50 = call double @exp(double %49)
%51 = fmul double %41, %50
store double %51, double* %9
%52 = load double, double* %9
%53 = load double*, double** %5
store double %52, double* %53
%54 = load double, double* %10
%55 = load double*, double** %8
store double %54, double* %55
ret void
}

LLVM IR (-O2):
define void @gser(double* nocapture writeonly %0, double %1, double %2, double* nocapture writeonly %3) {
%5 = tail call double @lgamma(double %1)
%6 = fdiv double 1.000000e+00, %1
%7 = tail call i32 @fabs(double %6)
%8 = sitofp i32 %7 to double
%9 = tail call i32 @fabs(double %6)
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 0x3E7AD7F29ABCAF48
%12 = fcmp olt double %11, %8
br i1 %12, label %13, label %27
13: ; preds = %4, %13
%14 = phi double [ %19, %13 ], [ %6, %4 ]
%15 = phi double [ %20, %13 ], [ %6, %4 ]
%16 = phi double [ %17, %13 ], [ %1, %4 ]
%17 = fadd double %16, 1.000000e+00
%18 = fdiv double %2, %17
%19 = fmul double %14, %18
%20 = fadd double %15, %19
%21 = tail call i32 @fabs(double %19)
%22 = sitofp i32 %21 to double
%23 = tail call i32 @fabs(double %20)
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 0x3E7AD7F29ABCAF48
%26 = fcmp olt double %25, %22
br i1 %26, label %13, label %27
27: ; preds = %13, %4
%28 = phi double [ %6, %4 ], [ %20, %13 ]
%29 = fneg double %2
%30 = tail call double @log(double %2)
%31 = tail call double @llvm.fmuladd.f64(double %1, double %30, double %29)
%32 = fsub double %31, %5
%33 = tail call double @exp(double %32)
%34 = fmul double %28, %33
store double %34, double* %0
store double %5, double* %3
ret void
}