#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned int spng_dec_read_bit(int /*<<< orphan*/ *);
unsigned int spng_dec_read_bitsR(int /*<<< orphan*/ *, int);
unsigned int spng_dec_read_literal(FILE *fp) {
  unsigned int bit;
  bit = spng_dec_read_bitsR(fp, 7);
  if (bit < 24)
    return bit + 256;
  bit = (bit << 1) | spng_dec_read_bit(fp);
  if (bit < 192)
    return bit - 48;
  if (bit < 200)
    return bit - 192 + 280;
  bit = (bit << 1) | spng_dec_read_bit(fp);
  return bit - 400 + 144;
}


x86 assembly (clang, -O0):
<spng_dec_read_literal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x7,%esi
call   1040 <spng_dec_read_bitsR@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x18,-0x14(%rbp)
jae    1157 <spng_dec_read_literal+0x37>
mov    -0x14(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x4(%rbp)
jmp    11dc <spng_dec_read_literal+0xbc>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <spng_dec_read_bit@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xc0,-0x14(%rbp)
jae    118e <spng_dec_read_literal+0x6e>
mov    -0x14(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11dc <spng_dec_read_literal+0xbc>
cmpl   $0xc8,-0x14(%rbp)
jae    11b0 <spng_dec_read_literal+0x90>
mov    -0x14(%rbp),%eax
sub    $0xc0,%eax
add    $0x118,%eax
mov    %eax,-0x4(%rbp)
jmp    11dc <spng_dec_read_literal+0xbc>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <spng_dec_read_bit@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x190,%eax
add    $0x90,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spng_dec_read_literal>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x7,%esi
call   1040 <spng_dec_read_bitsR@plt>
mov    %eax,%ebp
cmp    $0x17,%eax
ja     1140 <spng_dec_read_literal+0x20>
add    $0x100,%ebp
jmp    1180 <spng_dec_read_literal+0x60>
add    %ebp,%ebp
mov    %r14,%rdi
call   1030 <spng_dec_read_bit@plt>
mov    %eax,%ebx
or     %ebp,%ebx
cmp    $0xbf,%ebx
ja     115d <spng_dec_read_literal+0x3d>
add    $0xffffffd0,%ebx
mov    %ebx,%ebp
jmp    1180 <spng_dec_read_literal+0x60>
cmp    $0xc7,%ebx
ja     116c <spng_dec_read_literal+0x4c>
add    $0x58,%ebx
mov    %ebx,%ebp
jmp    1180 <spng_dec_read_literal+0x60>
add    %ebx,%ebx
mov    %r14,%rdi
call   1030 <spng_dec_read_bit@plt>
mov    %eax,%ebp
or     %ebx,%ebp
add    $0xffffff00,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @spng_dec_read_literal(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 @spng_dec_read_bitsR(i32* %5, i32 7)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ult i32 %7, 24
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %4
%11 = add i32 %10, 256
store i32 %11, i32* %2
br label %39
12: ; preds = %1
%13 = load i32, i32* %4
%14 = shl i32 %13, 1
%15 = load i32*, i32** %3
%16 = call i32 @spng_dec_read_bit(i32* %15)
%17 = or i32 %14, %16
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp ult i32 %18, 192
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i32, i32* %4
%22 = sub i32 %21, 48
store i32 %22, i32* %2
br label %39
23: ; preds = %12
%24 = load i32, i32* %4
%25 = icmp ult i32 %24, 200
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %4
%28 = sub i32 %27, 192
%29 = add i32 %28, 280
store i32 %29, i32* %2
br label %39
30: ; preds = %23
%31 = load i32, i32* %4
%32 = shl i32 %31, 1
%33 = load i32*, i32** %3
%34 = call i32 @spng_dec_read_bit(i32* %33)
%35 = or i32 %32, %34
store i32 %35, i32* %4
%36 = load i32, i32* %4
%37 = sub i32 %36, 400
%38 = add i32 %37, 144
store i32 %38, i32* %2
br label %39
39: ; preds = %30, %26, %20, %9
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @spng_dec_read_literal(i32* %0) {
%2 = tail call i32 @spng_dec_read_bitsR(i32* %0, i32 7)
%3 = icmp ult i32 %2, 24
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = add nuw nsw i32 %2, 256
br label %22
6: ; preds = %1
%7 = shl i32 %2, 1
%8 = tail call i32 @spng_dec_read_bit(i32* %0)
%9 = or i32 %8, %7
%10 = icmp ult i32 %9, 192
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = add nsw i32 %9, -48
br label %22
13: ; preds = %6
%14 = icmp ult i32 %9, 200
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = add nuw nsw i32 %9, 88
br label %22
17: ; preds = %13
%18 = shl i32 %9, 1
%19 = tail call i32 @spng_dec_read_bit(i32* %0)
%20 = or i32 %19, %18
%21 = add i32 %20, -256
br label %22
22: ; preds = %17, %15, %11, %4
%23 = phi i32 [ %5, %4 ], [ %12, %11 ], [ %16, %15 ], [ %21, %17 ]
ret i32 %23
}