#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 fgetc(int /*<<< orphan*/ *);
unsigned int fgetvb(FILE *stream) {
  unsigned int value = 0;
  int len = 0;
  int c;
  do {
    c = fgetc(stream);
    if (c == EOF) {
      return EOF;
    }
    value = (value << 7) | (c & 0x7F);
    len++;
  } while (len < 4 && (c & 0x80) != 0);
  return value;
}


x86 assembly (clang, -O0):
<fgetvb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
jne    1159 <fgetvb+0x49>
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <fgetvb+0x94>
mov    -0x14(%rbp),%eax
shl    $0x7,%eax
mov    -0x1c(%rbp),%ecx
and    $0x7f,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x4,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
jge    1193 <fgetvb+0x83>
mov    -0x1c(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    112a <fgetvb+0x1a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgetvb>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2ec5(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     115a <fgetvb+0x4a>
mov    %ebx,%ecx
shl    $0x7,%ecx
mov    %eax,%ebx
and    $0x7f,%ebx
or     %ecx,%ebx
cmp    $0x2,%ebp
ja     115c <fgetvb+0x4c>
add    $0x1,%ebp
and    $0x80,%eax
jne    1130 <fgetvb+0x20>
jmp    115c <fgetvb+0x4c>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fgetvb(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %30, %1
%8 = load i32*, i32** %3
%9 = call i32 @fgetc(i32* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = load i32, i32* @EOF
store i32 %14, i32* %2
br label %34
15: ; preds = %7
%16 = load i32, i32* %4
%17 = shl i32 %16, 7
%18 = load i32, i32* %6
%19 = and i32 %18, 127
%20 = or i32 %17, %19
store i32 %20, i32* %4
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %23
23: ; preds = %15
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* %6
%28 = and i32 %27, 128
%29 = icmp ne i32 %28, 0
br label %30
30: ; preds = %26, %23
%31 = phi i1 [ false, %23 ], [ %29, %26 ]
br i1 %31, label %7, label %32
32: ; preds = %30
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %13
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @fgetvb(i32* nocapture %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i32 [ 0, %1 ], [ %11, %8 ]
%4 = phi i32 [ 0, %1 ], [ %12, %8 ]
%5 = tail call i32 @fgetc(i32* %0)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %17, label %8
8: ; preds = %2
%9 = shl i32 %3, 7
%10 = and i32 %5, 127
%11 = or i32 %10, %9
%12 = add nuw nsw i32 %4, 1
%13 = icmp ult i32 %4, 3
%14 = and i32 %5, 128
%15 = icmp ne i32 %14, 0
%16 = and i1 %13, %15
br i1 %16, label %2, label %17
17: ; preds = %8, %2
%18 = phi i32 [ %5, %2 ], [ %11, %8 ]
ret i32 %18
}