#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 EOF;
unsigned int fputc(unsigned int, int /*<<< orphan*/ *);
int varintlen(unsigned int);
unsigned int fputvl(unsigned int value, FILE *stream) {
  int i;
  int len = varintlen(value);
  unsigned int result;
  for (i = 0; i < len; i++) {
    result =
        fputc(((value >> (7 * i)) & 0x7F) | ((i < len - 1) ? 0x80 : 0), stream);
    if (result == EOF) {
      return EOF;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<fputvl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <varintlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b2 <fputvl+0x92>
mov    -0x8(%rbp),%edi
imul   $0x7,-0x14(%rbp),%ecx
shr    %cl,%edi
and    $0x7f,%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
xor    %eax,%eax
mov    $0x80,%ecx
cmp    %esi,%edx
cmovl  %ecx,%eax
or     %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <fputc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%eax
jne    119f <fputvl+0x7f>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <fputvl+0x98>
jmp    11a4 <fputvl+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <fputvl+0x21>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputvl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
call   1030 <varintlen@plt>
test   %eax,%eax
jle    1185 <fputvl+0x65>
mov    %eax,%r13d
add    $0xffffffff,%r13d
xor    %ebp,%ebp
mov    0x2e9e(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15d,%eax
mov    %ebp,%ecx
shr    %cl,%eax
and    $0x7f,%eax
xor    %edi,%edi
cmp    %r13d,%ebx
setl   %dil
shl    $0x7,%edi
or     %eax,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
cmp    (%r12),%eax
je     1185 <fputvl+0x65>
lea    0x1(%rbx),%ecx
add    $0x7,%ebp
cmp    %ebx,%r13d
mov    %ecx,%ebx
jne    1150 <fputvl+0x30>
jmp    1185 <fputvl+0x65>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @fputvl(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
%9 = load i32, i32* %4
%10 = call i32 @varintlen(i32 %9)
store i32 %10, i32* %7
store i32 0, i32* %6
br label %11
11: ; preds = %36, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32, i32* %6
%18 = mul nsw i32 7, %17
%19 = lshr i32 %16, %18
%20 = and i32 %19, 127
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = sub nsw i32 %22, 1
%24 = icmp slt i32 %21, %23
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 128, i32 0
%27 = or i32 %20, %26
%28 = load i32*, i32** %5
%29 = call i32 @fputc(i32 %27, i32* %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %15
%34 = load i32, i32* @EOF
store i32 %34, i32* %3
br label %41
35: ; preds = %15
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %11
39: ; preds = %11
%40 = load i32, i32* %8
store i32 %40, i32* %3
br label %41
41: ; preds = %39, %33
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @fputvl(i32 %0, i32* nocapture %1) {
%3 = tail call i32 @varintlen(i32 %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %21
5: ; preds = %2
%6 = add nsw i32 %3, -1
br label %7
7: ; preds = %7, %5
%8 = phi i32 [ 0, %5 ], [ %18, %7 ]
%9 = mul nuw nsw i32 %8, 7
%10 = lshr i32 %0, %9
%11 = and i32 %10, 127
%12 = icmp slt i32 %8, %6
%13 = select i1 %12, i32 128, i32 0
%14 = or i32 %11, %13
%15 = tail call i32 @fputc(i32 %14, i32* %1)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
%18 = add nuw nsw i32 %8, 1
%19 = icmp eq i32 %18, %3
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %21, label %7
21: ; preds = %7, %2
%22 = phi i32 [ undef, %2 ], [ %15, %7 ]
ret i32 %22
}