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


x86 assembly (clang, -O0):
<fgetvl>:
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 <fgetvl+0x49>
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <fgetvl+0x95>
mov    -0x1c(%rbp),%eax
and    $0x7f,%eax
imul   $0x7,-0x18(%rbp),%ecx
shl    %cl,%eax
or     -0x14(%rbp),%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    1194 <fgetvl+0x84>
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 <fgetvl+0x1a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgetvl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %ebp,%ebp
mov    0x2ec4(%rip),%r15
xor    %r12d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%eax
je     115f <fgetvl+0x4f>
mov    %eax,%edx
and    $0x7f,%edx
mov    %ebp,%ecx
shl    %cl,%edx
or     %edx,%r12d
cmp    $0x2,%ebx
ja     1162 <fgetvl+0x52>
add    $0x1,%ebx
and    $0x80,%eax
add    $0x7,%ebp
test   %eax,%eax
jne    1130 <fgetvl+0x20>
jmp    1162 <fgetvl+0x52>
mov    %eax,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fgetvl(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 = %32, %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 %36
15: ; preds = %7
%16 = load i32, i32* %6
%17 = and i32 %16, 127
%18 = load i32, i32* %5
%19 = mul nsw i32 7, %18
%20 = shl i32 %17, %19
%21 = load i32, i32* %4
%22 = or i32 %21, %20
store i32 %22, i32* %4
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %25
25: ; preds = %15
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 4
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %6
%30 = and i32 %29, 128
%31 = icmp ne i32 %30, 0
br label %32
32: ; preds = %28, %25
%33 = phi i1 [ false, %25 ], [ %31, %28 ]
br i1 %33, label %7, label %34
34: ; preds = %32
%35 = load i32, i32* %4
store i32 %35, i32* %2
br label %36
36: ; preds = %34, %13
%37 = load i32, i32* %2
ret i32 %37
}

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