#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 */
scalar_t__ EOF;
int /*<<< orphan*/ beschb(double, double *, double *, double *, double *);
int exp(int /*<<< orphan*/);
int /*<<< orphan*/ gammln(float);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, double *);
int main(void) {
  double gam1, gam2, gampl, gammi, x, xgam1, xgam2, xgampl, xgammi;
  for (;;) {
    printf("Enter x:\n");
    if (scanf("%lf", &x) == EOF)
      break;
    beschb(x, &xgam1, &xgam2, &xgampl, &xgammi);
    printf("%5s\n%17s %16s %17s %15s\n%17s %16s %17s %15s\n", "x", "gam1",
           "gam2", "gampl", "gammi", "xgam1", "xgam2", "xgampl", "xgammi");
    gampl = 1 / exp(gammln((float)(1 + x)));
    gammi = 1 / exp(gammln((float)(1 - x)));
    gam1 = (gammi - gampl) / (2 * x);
    gam2 = (gammi + gampl) / 2;
    printf("%5.2f\n\t%16.6e %16.6e %16.6e %16.6e\n", x, gam1, gam2, gampl,
           gammi);
    printf("\t%16.6e %16.6e %16.6e %16.6e\n", xgam1, xgam2, xgampl, xgammi);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
jne    1193 <main+0x43>
jmp    12f6 <main+0x1a6>
movsd  -0x38(%rbp),%xmm0
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1030 <beschb@plt>
lea    0xe6a(%rip),%rdi
lea    0xe90(%rip),%rsi
lea    0xe8c(%rip),%rdx
lea    0xe8b(%rip),%rcx
lea    0xe8a(%rip),%r8
lea    0xe8a(%rip),%r9
lea    0xe6f(%rip),%rbx
lea    0xe6e(%rip),%r11
lea    0xe6d(%rip),%r10
lea    0xe6d(%rip),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xdf3(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <gammln@plt>
mov    %eax,%edi
call   1050 <exp@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdc3(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <gammln@plt>
mov    %eax,%edi
call   1050 <exp@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xd81(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xd61(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
lea    0xd9f(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
lea    0xd83(%rip),%rdi
mov    $0x4,%al
call   1040 <printf@plt>
jmp    1160 <main+0x10>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e56(%rip),%rbx
cmp    (%rbx),%rax
je     1319 <main+0x1b9>
xor    %r13d,%r13d
lea    0xedc(%rip),%r14
lea    0xe64(%rip),%r15
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
lea    0x30(%rsp),%rdi
lea    0x28(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   1040 <beschb@plt>
lea    0xe2e(%rip),%rdi
lea    0xe54(%rip),%rsi
lea    0xe50(%rip),%rdx
lea    0xe4f(%rip),%rcx
lea    0xe4e(%rip),%r8
lea    0xe4e(%rip),%r9
xor    %eax,%eax
lea    0xe44(%rip),%rbp
push   %rbp
lea    0xe35(%rip),%rbp
push   %rbp
lea    0xe27(%rip),%rbp
push   %rbp
lea    0xe19(%rip),%rbp
push   %rbp
call   1050 <printf@plt>
add    $0x20,%rsp
movsd  0x8(%rsp),%xmm0
movsd  0xdbe(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
mov    %eax,%edi
call   1060 <exp@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovae %r13d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xd8b(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
mov    %eax,%edi
call   1060 <exp@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovae %r13d,%eax
cvtsi2sd %eax,%xmm4
movapd %xmm4,%xmm1
movsd  0x10(%rsp),%xmm3
subsd  %xmm3,%xmm1
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
movapd %xmm3,%xmm2
addsd  %xmm4,%xmm2
mulsd  0xd3f(%rip),%xmm2
lea    0xd8d(%rip),%rdi
mov    $0x5,%al
call   1050 <printf@plt>
movsd  0x30(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
lea    0xd6d(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
cmp    (%rbx),%rax
jne    11c0 <main+0x60>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Enter x:\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.2 = [45 x i8] c"%5s\0A%17s %16s %17s %15s\0A%17s %16s %17s %15s\0A\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [5 x i8] c"gam1\00"
@.str.5 = [5 x i8] c"gam2\00"
@.str.6 = [6 x i8] c"gampl\00"
@.str.7 = [6 x i8] c"gammi\00"
@.str.8 = [6 x i8] c"xgam1\00"
@.str.9 = [6 x i8] c"xgam2\00"
@.str.10 = [7 x i8] c"xgampl\00"
@.str.11 = [7 x i8] c"xgammi\00"
@.str.12 = [36 x i8] c"%5.2f\0A\09%16.6e %16.6e %16.6e %16.6e\0A\00"
@.str.13 = [30 x i8] c"\09%16.6e %16.6e %16.6e %16.6e\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 0, i32* %1
br label %11
11: ; preds = %17, %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %6)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %11
br label %56
17: ; preds = %11
%18 = load double, double* %6
%19 = call i32 @beschb(double %18, double* %7, double* %8, double* %9, double* %10)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%21 = load double, double* %6
%22 = fadd double 1.000000e+00, %21
%23 = fptrunc double %22 to float
%24 = call i32 @gammln(float %23)
%25 = call i32 @exp(i32 %24)
%26 = sdiv i32 1, %25
%27 = sitofp i32 %26 to double
store double %27, double* %4
%28 = load double, double* %6
%29 = fsub double 1.000000e+00, %28
%30 = fptrunc double %29 to float
%31 = call i32 @gammln(float %30)
%32 = call i32 @exp(i32 %31)
%33 = sdiv i32 1, %32
%34 = sitofp i32 %33 to double
store double %34, double* %5
%35 = load double, double* %5
%36 = load double, double* %4
%37 = fsub double %35, %36
%38 = load double, double* %6
%39 = fmul double 2.000000e+00, %38
%40 = fdiv double %37, %39
store double %40, double* %2
%41 = load double, double* %5
%42 = load double, double* %4
%43 = fadd double %41, %42
%44 = fdiv double %43, 2.000000e+00
store double %44, double* %3
%45 = load double, double* %6
%46 = load double, double* %2
%47 = load double, double* %3
%48 = load double, double* %4
%49 = load double, double* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), double %45, double %46, double %47, double %48, double %49)
%51 = load double, double* %7
%52 = load double, double* %8
%53 = load double, double* %9
%54 = load double, double* %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), double %51, double %52, double %53, double %54)
br label %11
56: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@EOF = global i64 0
@.str.2 = [45 x i8] c"%5s\0A%17s %16s %17s %15s\0A%17s %16s %17s %15s\0A\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [5 x i8] c"gam1\00"
@.str.5 = [5 x i8] c"gam2\00"
@.str.6 = [6 x i8] c"gampl\00"
@.str.7 = [6 x i8] c"gammi\00"
@.str.8 = [6 x i8] c"xgam1\00"
@.str.9 = [6 x i8] c"xgam2\00"
@.str.10 = [7 x i8] c"xgampl\00"
@.str.11 = [7 x i8] c"xgammi\00"
@.str.12 = [36 x i8] c"%5.2f\0A\09%16.6e %16.6e %16.6e %16.6e\0A\00"
@.str.13 = [30 x i8] c"\09%16.6e %16.6e %16.6e %16.6e\0A\00"
@str = [9 x i8] c"Enter x:\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%12 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %53, label %15
15: ; preds = %0, %15
%16 = load double, double* %1
%17 = call i32 @beschb(double %16, double* %2, double* %3, double* %4, double* %5)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%19 = load double, double* %1
%20 = fadd double %19, 1.000000e+00
%21 = fptrunc double %20 to float
%22 = call i32 @gammln(float %21)
%23 = call i32 @exp(i32 %22)
%24 = add i32 %23, 1
%25 = icmp ult i32 %24, 3
%26 = select i1 %25, i32 %23, i32 0
%27 = sitofp i32 %26 to double
%28 = load double, double* %1
%29 = fsub double 1.000000e+00, %28
%30 = fptrunc double %29 to float
%31 = call i32 @gammln(float %30)
%32 = call i32 @exp(i32 %31)
%33 = add i32 %32, 1
%34 = icmp ult i32 %33, 3
%35 = select i1 %34, i32 %32, i32 0
%36 = sitofp i32 %35 to double
%37 = fsub double %36, %27
%38 = load double, double* %1
%39 = fmul double %38, 2.000000e+00
%40 = fdiv double %37, %39
%41 = fadd double %27, %36
%42 = fmul double %41, 5.000000e-01
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), double %38, double %40, double %42, double %27, double %36)
%44 = load double, double* %2
%45 = load double, double* %3
%46 = load double, double* %4
%47 = load double, double* %5
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), double %44, double %45, double %46, double %47)
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%50 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%51 = load i64, i64* @EOF
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %15
53: ; preds = %15, %0
ret i32 0
}