int st_ulaw_to_linear(unsigned char ulawbyte) {
  static int exp_lut[8] = {0, 132, 396, 924, 1980, 4092, 8316, 16764};
  int sign, exponent, mantissa, sample;
  ulawbyte = ~ulawbyte;
  sign = (ulawbyte & 0x80);
  exponent = (ulawbyte >> 4) & 0x07;
  mantissa = ulawbyte & 0x0F;
  sample = exp_lut[exponent] + (mantissa << (exponent + 3));
  if (sign != 0)
    sample = -sample;
  return sample;
}


x86 assembly (clang, -O0):
<st_ulaw_to_linear>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
xor    $0xffffffff,%eax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
mov    %eax,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
sar    $0x4,%eax
and    $0x7,%eax
mov    %eax,-0xc(%rbp)
movzbl -0x1(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x10(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2eee(%rip),%rax
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
shl    %cl,%edx
mov    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1169 <st_ulaw_to_linear+0x69>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<st_ulaw_to_linear>:
not    %dil
movzbl %dil,%edx
mov    %edx,%eax
shr    $0x4,%eax
and    $0x7,%eax
mov    %edx,%esi
and    $0xf,%esi
mov    %eax,%ecx
add    $0x3,%cl
shl    %cl,%esi
lea    0xede(%rip),%rcx
add    (%rcx,%rax,4),%esi
mov    %esi,%eax
neg    %eax
test   $0x80,%dl
cmove  %esi,%eax
ret

LLVM IR (-O0):
@st_ulaw_to_linear.exp_lut = internal global [8 x i32] [i32 0, i32 132, i32 396, i32 924, i32 1980, i32 4092, i32 8316, i32 16764]
define i32 @st_ulaw_to_linear(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %2
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
%9 = xor i32 %8, -1
%10 = trunc i32 %9 to i8
store i8 %10, i8* %2
%11 = load i8, i8* %2
%12 = zext i8 %11 to i32
%13 = and i32 %12, 128
store i32 %13, i32* %3
%14 = load i8, i8* %2
%15 = zext i8 %14 to i32
%16 = ashr i32 %15, 4
%17 = and i32 %16, 7
store i32 %17, i32* %4
%18 = load i8, i8* %2
%19 = zext i8 %18 to i32
%20 = and i32 %19, 15
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [8 x i32], [8 x i32]* @st_ulaw_to_linear.exp_lut, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 3
%28 = shl i32 %25, %27
%29 = add nsw i32 %24, %28
store i32 %29, i32* %6
%30 = load i32, i32* %3
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %1
%33 = load i32, i32* %6
%34 = sub nsw i32 0, %33
store i32 %34, i32* %6
br label %35
35: ; preds = %32, %1
%36 = load i32, i32* %6
ret i32 %36
}

LLVM IR (-O2):
@st_ulaw_to_linear.exp_lut = internal unnamed_addr constant [8 x i32] [i32 0, i32 132, i32 396, i32 924, i32 1980, i32 4092, i32 8316, i32 16764]
define i32 @st_ulaw_to_linear(i8 zeroext %0) {
%2 = xor i8 %0, -1
%3 = zext i8 %2 to i32
%4 = and i32 %3, 128
%5 = lshr i32 %3, 4
%6 = and i32 %5, 7
%7 = and i32 %3, 15
%8 = zext i32 %6 to i64
%9 = getelementptr inbounds [8 x i32], [8 x i32]* @st_ulaw_to_linear.exp_lut, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = add nuw nsw i32 %6, 3
%12 = shl nuw nsw i32 %7, %11
%13 = add nsw i32 %10, %12
%14 = icmp eq i32 %4, 0
%15 = sub nsw i32 0, %13
%16 = select i1 %14, i32 %13, i32 %15
ret i32 %16
}