#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);
double LogL16toY(int p16) {
  int Le = p16 & 0x7fff;
  double Y;
  if (!Le)
    return (0.);
  Y = exp(0.69314718055994530942 / 256. * (Le + .5) -
          0.69314718055994530942 * 64.);
  return (!(p16 & 0x8000) ? Y : -Y);
}


x86 assembly (clang, -O0):
<LogL16toY>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7fff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    113d <LogL16toY+0x2d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bb <LogL16toY+0xab>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xec6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xeaa(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea6(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
jne    1190 <LogL16toY+0x80>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11b1 <LogL16toY+0xa1>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LogL16toY>:
mov    %edi,%eax
and    $0x7fff,%eax
je     114f <LogL16toY+0x3f>
push   %rbx
mov    %edi,%ebx
cvtsi2sd %eax,%xmm0
addsd  0xed8(%rip),%xmm0
mulsd  0xed8(%rip),%xmm0
addsd  0xed8(%rip),%xmm0
call   1030 <exp@plt>
test   $0x8000,%ebx
je     114d <LogL16toY+0x3d>
xorpd  0xed3(%rip),%xmm0
pop    %rbx
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @LogL16toY(i32 %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = and i32 %6, 32767
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store double 0.000000e+00, double* %2
br label %27
11: ; preds = %1
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to double
%14 = fadd double %13, 5.000000e-01
%15 = call double @llvm.fmuladd.f64(double 0x3F662E42FEFA39EF, double %14, double 0xC0462E42FEFA39EF)
%16 = call double @exp(double %15)
store double %16, double* %5
%17 = load i32, i32* %3
%18 = and i32 %17, 32768
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %11
%21 = load double, double* %5
br label %25
22: ; preds = %11
%23 = load double, double* %5
%24 = fneg double %23
br label %25
25: ; preds = %22, %20
%26 = phi double [ %21, %20 ], [ %24, %22 ]
store double %26, double* %2
br label %27
27: ; preds = %25, %10
%28 = load double, double* %2
ret double %28
}

LLVM IR (-O2):
define double @LogL16toY(i32 %0) {
%2 = and i32 %0, 32767
%3 = icmp eq i32 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = sitofp i32 %2 to double
%6 = fadd double %5, 5.000000e-01
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x3F662E42FEFA39EF, double 0xC0462E42FEFA39EF)
%8 = tail call double @exp(double %7)
%9 = and i32 %0, 32768
%10 = icmp eq i32 %9, 0
%11 = fneg double %8
%12 = select i1 %10, double %8, double %11
br label %13
13: ; preds = %1, %4
%14 = phi double [ %12, %4 ], [ 0.000000e+00, %1 ]
ret double %14
}