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

/* Variables and functions */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int fvuimsbfGet(FILE *fp, off_t *o) {
  int cc;
  int flen = 0;
  if ((cc = fgetc(fp)) != EOF) {
    off_t value = 0;
    int len;
    len = (cc >> 5) & 0x1f;
    flen = 1 + len;
    value = (off_t)(cc & 0x1f);
    if (len > 0) {
      do {
        if ((cc = fgetc(fp)) != EOF)
          value = (value << 8) | (off_t)(cc);
        else {
          flen = 0;
          break;
        }
      } while (--len > 0);
    }
    if ((flen > 0) && (o != NULL))
      *o = value;
  }
  return flen;
}


x86 assembly (clang, -O0):
<fvuimsbfGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2eae(%rip),%rcx
cmp    (%rcx),%eax
je     11ed <fvuimsbfGet+0xdd>
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x5,%eax
and    $0x1f,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    11ca <fvuimsbfGet+0xba>
jmp    1176 <fvuimsbfGet+0x66>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%eax
je     11a2 <fvuimsbfGet+0x92>
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ae <fvuimsbfGet+0x9e>
movl   $0x0,-0x18(%rbp)
jmp    11c5 <fvuimsbfGet+0xb5>
jmp    11b3 <fvuimsbfGet+0xa3>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jg     1176 <fvuimsbfGet+0x66>
jmp    11ca <fvuimsbfGet+0xba>
cmpl   $0x0,-0x18(%rbp)
jle    11e8 <fvuimsbfGet+0xd8>
cmpq   $0x0,-0x10(%rbp)
je     11e8 <fvuimsbfGet+0xd8>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ed <fvuimsbfGet+0xdd>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fvuimsbfGet>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
call   1030 <fgetc@plt>
mov    0x2ebb(%rip),%r12
cmp    (%r12),%eax
jne    1138 <fvuimsbfGet+0x28>
xor    %r15d,%r15d
jmp    1173 <fvuimsbfGet+0x63>
mov    %eax,%ebp
mov    %eax,%ebx
shr    $0x5,%ebx
and    $0x1f,%ebx
and    $0x1f,%ebp
test   %ebx,%ebx
je     1185 <fvuimsbfGet+0x75>
lea    0x1(%rbx),%r15d
add    $0x1,%ebx
mov    %r13,%rdi
call   1030 <fgetc@plt>
cmp    (%r12),%eax
je     1133 <fvuimsbfGet+0x23>
shl    $0x8,%ebp
or     %eax,%ebp
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1150 <fvuimsbfGet+0x40>
test   %r14,%r14
je     1173 <fvuimsbfGet+0x63>
mov    %ebp,(%r14)
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r15d
test   %r14,%r14
jne    1170 <fvuimsbfGet+0x60>
jmp    1173 <fvuimsbfGet+0x63>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fvuimsbfGet(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** %3
store i32* %1, i32** %4
store i32 0, i32* %6
%9 = load i32*, i32** %3
%10 = call i32 @fgetc(i32* %9)
store i32 %10, i32* %5
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %51
13: ; preds = %2
store i32 0, i32* %7
%14 = load i32, i32* %5
%15 = ashr i32 %14, 5
%16 = and i32 %15, 31
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = add nsw i32 1, %17
store i32 %18, i32* %6
%19 = load i32, i32* %5
%20 = and i32 %19, 31
store i32 %20, i32* %7
%21 = load i32, i32* %8
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %41
23: ; preds = %13
br label %24
24: ; preds = %36, %23
%25 = load i32*, i32** %3
%26 = call i32 @fgetc(i32* %25)
store i32 %26, i32* %5
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i32, i32* %7
%31 = shl i32 %30, 8
%32 = load i32, i32* %5
%33 = or i32 %31, %32
store i32 %33, i32* %7
br label %35
34: ; preds = %24
store i32 0, i32* %6
br label %40
35: ; preds = %29
br label %36
36: ; preds = %35
%37 = load i32, i32* %8
%38 = add nsw i32 %37, -1
store i32 %38, i32* %8
%39 = icmp sgt i32 %38, 0
br i1 %39, label %24, label %40
40: ; preds = %36, %34
br label %41
41: ; preds = %40, %13
%42 = load i32, i32* %6
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %41
%45 = load i32*, i32** %4
%46 = icmp ne i32* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i32, i32* %7
%49 = load i32*, i32** %4
store i32 %48, i32* %49
br label %50
50: ; preds = %47, %44, %41
br label %51
51: ; preds = %50, %2
%52 = load i32, i32* %6
ret i32 %52
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @fvuimsbfGet(i32* nocapture %0, i32* writeonly %1) {
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %28, label %6
6: ; preds = %2
%7 = lshr i32 %3, 5
%8 = and i32 %7, 31
%9 = add nuw nsw i32 %8, 1
%10 = and i32 %3, 31
%11 = icmp eq i32 %8, 0
br i1 %11, label %23, label %12
12: ; preds = %6, %18
%13 = phi i32 [ %20, %18 ], [ %10, %6 ]
%14 = phi i32 [ %21, %18 ], [ %8, %6 ]
%15 = tail call i32 @fgetc(i32* %0)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %28, label %18
18: ; preds = %12
%19 = shl i32 %13, 8
%20 = or i32 %15, %19
%21 = add nsw i32 %14, -1
%22 = icmp sgt i32 %14, 1
br i1 %22, label %12, label %23
23: ; preds = %18, %6
%24 = phi i32 [ 1, %6 ], [ %9, %18 ]
%25 = phi i32 [ %10, %6 ], [ %20, %18 ]
%26 = icmp eq i32* %1, null
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 %25, i32* %1
br label %28
28: ; preds = %12, %23, %27, %2
%29 = phi i32 [ 0, %2 ], [ %24, %27 ], [ %24, %23 ], [ 0, %12 ]
ret i32 %29
}