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


x86 assembly (clang, -O0):
<ulaw_c>:
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  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1179 <ulaw_c+0x69>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    119a <ulaw_c+0x8a>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm0,%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xe4b(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe24(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ulaw_c>:
sub    $0x18,%rsp
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm0
movapd 0xedc(%rip),%xmm3
movapd %xmm1,%xmm4
jae    1132 <ulaw_c+0x22>
movapd %xmm1,%xmm4
xorpd  %xmm3,%xmm4
movapd %xmm4,(%rsp)
xorpd  %xmm0,%xmm3
cmplesd %xmm0,%xmm5
movapd %xmm5,%xmm4
andnpd %xmm3,%xmm4
andpd  %xmm0,%xmm5
orpd   %xmm4,%xmm5
mulsd  %xmm2,%xmm5
divsd  %xmm1,%xmm5
addsd  0xeb0(%rip),%xmm5
cvttsd2si %xmm5,%edi
movsd  %xmm2,0x10(%rsp)
call   1030 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xe82(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ulaw_c(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 = load double, double* %4
%17 = fcmp oge double %16, 0.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = load double, double* %4
br label %23
20: ; preds = %3
%21 = load double, double* %4
%22 = fneg double %21
br label %23
23: ; preds = %20, %18
%24 = phi double [ %19, %18 ], [ %22, %20 ]
%25 = fmul double %15, %24
%26 = load double, double* %5
%27 = fdiv double %25, %26
%28 = fadd double 1.000000e+00, %27
%29 = fptosi double %28 to i32
%30 = call i32 @log(i32 %29)
%31 = sitofp i32 %30 to double
%32 = fmul double %14, %31
%33 = load double, double* %6
%34 = fadd double 1.000000e+00, %33
%35 = fptosi double %34 to i32
%36 = call i32 @log(i32 %35)
%37 = sitofp i32 %36 to double
%38 = fdiv double %32, %37
store double %38, double* %7
%39 = load double, double* %7
ret double %39
}

LLVM IR (-O2):
define double @ulaw_c(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 = fneg double %0
%8 = select i1 %4, double %0, double %7
%9 = fmul double %8, %2
%10 = fdiv double %9, %1
%11 = fadd double %10, 1.000000e+00
%12 = fptosi double %11 to i32
%13 = tail call i32 @log(i32 %12)
%14 = sitofp i32 %13 to double
%15 = fmul double %6, %14
%16 = fadd double %2, 1.000000e+00
%17 = fptosi double %16 to i32
%18 = tail call i32 @log(i32 %17)
%19 = sitofp i32 %18 to double
%20 = fdiv double %15, %19
ret double %20
}