#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 const);
double pow(double const, double const);
double glog(const double r, const double x) {
  if (r == 0.0) {
    return (log(x));
  } else {
    if (r < 0.0)
      return ((pow(1 / x, -r) - 1.0) / r);
    else
      return ((pow(x, r) - 1.0) / r);
  }
}


x86 assembly (clang, -O0):
<glog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115e <glog+0x3e>
jp     115e <glog+0x3e>
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11da <glog+0xba>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b5 <glog+0x95>
movsd  0xe8c(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
call   1040 <pow@plt>
movsd  0xe5e(%rip),%xmm1
subsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11da <glog+0xba>
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <pow@plt>
movsd  0xe34(%rip),%xmm1
subsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glog>:
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1138 <glog+0x18>
jp     1138 <glog+0x18>
movaps %xmm1,%xmm0
jmp    1030 <log@plt>
sub    $0x18,%rsp
ucomisd %xmm2,%xmm0
movapd %xmm2,(%rsp)
jbe    1161 <glog+0x41>
movsd  0xeb9(%rip),%xmm0
divsd  %xmm1,%xmm0
movapd 0xeb5(%rip),%xmm1
xorpd  %xmm2,%xmm1
jmp    1169 <glog+0x49>
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
call   1040 <pow@plt>
addsd  0xe8a(%rip),%xmm0
divsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @glog(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load double, double* %5
%10 = call double @log(double %9)
store double %10, double* %3
br label %30
11: ; preds = %2
%12 = load double, double* %4
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load double, double* %5
%16 = fdiv double 1.000000e+00, %15
%17 = load double, double* %4
%18 = fneg double %17
%19 = call double @pow(double %16, double %18)
%20 = fsub double %19, 1.000000e+00
%21 = load double, double* %4
%22 = fdiv double %20, %21
store double %22, double* %3
br label %30
23: ; preds = %11
%24 = load double, double* %5
%25 = load double, double* %4
%26 = call double @pow(double %24, double %25)
%27 = fsub double %26, 1.000000e+00
%28 = load double, double* %4
%29 = fdiv double %27, %28
store double %29, double* %3
br label %30
30: ; preds = %23, %14, %8
%31 = load double, double* %3
ret double %31
}

LLVM IR (-O2):
define double @glog(double %0, double %1) {
%3 = fcmp oeq double %0, 0.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call double @log(double %1)
br label %18
6: ; preds = %2
%7 = fcmp olt double %0, 0.000000e+00
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = fdiv double 1.000000e+00, %1
%10 = fneg double %0
%11 = tail call double @pow(double %9, double %10)
%12 = fadd double %11, -1.000000e+00
%13 = fdiv double %12, %0
br label %18
14: ; preds = %6
%15 = tail call double @pow(double %1, double %0)
%16 = fadd double %15, -1.000000e+00
%17 = fdiv double %16, %0
br label %18
18: ; preds = %14, %8, %4
%19 = phi double [ %5, %4 ], [ %13, %8 ], [ %17, %14 ]
ret double %19
}