#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 */
int pow(int, double const);
double ulaw_d(const double x, const double max, const double mu) {
  double y;
  y = ((x >= 0) ? 1 : (-1)) * max *
      (pow(1 + mu, ((x >= 0) ? (x) : (-(x))) / max) - 1) / mu;
  return (y);
}


x86 assembly (clang, -O0):
<ulaw_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmovae %ecx,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeaa(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1183 <ulaw_d+0x73>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11a4 <ulaw_d+0x94>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%edi
movsd  -0x38(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <pow@plt>
movsd  -0x30(%rbp),%xmm0
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ulaw_d>:
sub    $0x28,%rsp
movapd %xmm0,%xmm5
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm5
movapd 0xed8(%rip),%xmm3
movapd %xmm1,%xmm4
jae    1136 <ulaw_d+0x26>
movapd %xmm1,%xmm4
xorpd  %xmm3,%xmm4
movapd %xmm4,0x10(%rsp)
movsd  0xecc(%rip),%xmm4
addsd  %xmm2,%xmm4
cvttsd2si %xmm4,%edi
xorpd  %xmm5,%xmm3
cmplesd %xmm5,%xmm0
movapd %xmm0,%xmm4
andnpd %xmm3,%xmm4
andpd  %xmm5,%xmm0
orpd   %xmm4,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <pow@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @ulaw_d(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%8 = load double, double* %4
%9 = fcmp oge double %8, 0.000000e+00
%10 = zext i1 %9 to i64
%11 = select i1 %9, i32 1, i32 -1
%12 = sitofp i32 %11 to double
%13 = load double, double* %5
%14 = fmul double %12, %13
%15 = load double, double* %6
%16 = fadd double 1.000000e+00, %15
%17 = fptosi double %16 to i32
%18 = load double, double* %4
%19 = fcmp oge double %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %3
%21 = load double, double* %4
br label %25
22: ; preds = %3
%23 = load double, double* %4
%24 = fneg double %23
br label %25
25: ; preds = %22, %20
%26 = phi double [ %21, %20 ], [ %24, %22 ]
%27 = load double, double* %5
%28 = fdiv double %26, %27
%29 = call i32 @pow(i32 %17, double %28)
%30 = sub nsw i32 %29, 1
%31 = sitofp i32 %30 to double
%32 = fmul double %14, %31
%33 = load double, double* %6
%34 = fdiv double %32, %33
store double %34, double* %7
%35 = load double, double* %7
ret double %35
}

LLVM IR (-O2):
define double @ulaw_d(double %0, double %1, double %2) {
%4 = fcmp oge double %0, 0.000000e+00
%5 = fneg double %1
%6 = select i1 %4, double %1, double %5
%7 = fadd double %2, 1.000000e+00
%8 = fptosi double %7 to i32
%9 = fneg double %0
%10 = select i1 %4, double %0, double %9
%11 = fdiv double %10, %1
%12 = tail call i32 @pow(i32 %8, double %11)
%13 = add nsw i32 %12, -1
%14 = sitofp i32 %13 to double
%15 = fmul double %6, %14
%16 = fdiv double %15, %2
ret double %16
}