#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 */
int EOF;
int getc_unlocked(int /*<<< orphan*/ *);
int read_lit(FILE *input, int *lit) {
  int l = 0, lc, shift = 0;
  do {
    lc = getc_unlocked(input);
    if ((shift == 0) && (lc == EOF))
      return EOF;
    l |= (lc & 127) << shift;
    shift += 7;
  } while (lc > 127);
  if (l % 2)
    *lit = (l >> 1) * -1;
  else
    *lit = (l >> 1);
  return 1;
}


x86 assembly (clang, -O0):
<read_lit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc_unlocked@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1167 <read_lit+0x57>
mov    -0x20(%rbp),%eax
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
jne    1167 <read_lit+0x57>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <read_lit+0xb6>
mov    -0x20(%rbp),%eax
and    $0x7f,%eax
mov    -0x24(%rbp),%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x7,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x7f,-0x20(%rbp)
jg     112e <read_lit+0x1e>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11b3 <read_lit+0xa3>
mov    -0x1c(%rbp),%eax
sar    $0x1,%eax
imul   $0xffffffff,%eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11bf <read_lit+0xaf>
mov    -0x1c(%rbp),%ecx
sar    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_lit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
mov    0x2ec1(%rip),%r12
xor    %ebp,%ebp
jmp    1143 <read_lit+0x33>
nopl   0x0(%rax,%rax,1)
mov    %eax,%edx
and    $0x7f,%edx
mov    %ebp,%ecx
shl    %cl,%edx
or     %edx,%ebx
add    $0x7,%ebp
cmp    $0x7f,%eax
jle    1157 <read_lit+0x47>
mov    %r15,%rdi
call   1030 <getc_unlocked@plt>
test   %ebp,%ebp
jne    1130 <read_lit+0x20>
cmp    (%r12),%eax
jne    1130 <read_lit+0x20>
jmp    116d <read_lit+0x5d>
mov    %ebx,%eax
sar    %eax
mov    %eax,%ecx
neg    %ecx
test   $0x1,%bl
cmove  %eax,%ecx
mov    %ecx,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @read_lit(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 0, i32* %6
store i32 0, i32* %8
br label %9
9: ; preds = %29, %2
%10 = load i32*, i32** %4
%11 = call i32 @getc_unlocked(i32* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i32, i32* %7
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i32, i32* @EOF
store i32 %19, i32* %3
br label %46
20: ; preds = %14, %9
%21 = load i32, i32* %7
%22 = and i32 %21, 127
%23 = load i32, i32* %8
%24 = shl i32 %22, %23
%25 = load i32, i32* %6
%26 = or i32 %25, %24
store i32 %26, i32* %6
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 7
store i32 %28, i32* %8
br label %29
29: ; preds = %20
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 127
br i1 %31, label %9, label %32
32: ; preds = %29
%33 = load i32, i32* %6
%34 = srem i32 %33, 2
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* %6
%38 = ashr i32 %37, 1
%39 = mul nsw i32 %38, -1
%40 = load i32*, i32** %5
store i32 %39, i32* %40
br label %45
41: ; preds = %32
%42 = load i32, i32* %6
%43 = ashr i32 %42, 1
%44 = load i32*, i32** %5
store i32 %43, i32* %44
br label %45
45: ; preds = %41, %36
store i32 1, i32* %3
br label %46
46: ; preds = %45, %18
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @read_lit(i32* nocapture %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %11, %2
%4 = phi i32 [ 0, %2 ], [ %14, %11 ]
%5 = phi i32 [ 0, %2 ], [ %15, %11 ]
%6 = tail call i32 @getc_unlocked(i32* %0)
%7 = icmp eq i32 %5, 0
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %6, %8
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %23, label %11
11: ; preds = %3
%12 = and i32 %6, 127
%13 = shl i32 %12, %5
%14 = or i32 %13, %4
%15 = add nuw nsw i32 %5, 7
%16 = icmp sgt i32 %6, 127
br i1 %16, label %3, label %17
17: ; preds = %11
%18 = and i32 %14, 1
%19 = icmp eq i32 %18, 0
%20 = ashr i32 %14, 1
%21 = sub nsw i32 0, %20
%22 = select i1 %19, i32 %20, i32 %21
store i32 %22, i32* %1
br label %23
23: ; preds = %3, %17
%24 = phi i32 [ 1, %17 ], [ %6, %3 ]
ret i32 %24
}