#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 */

/* Variables and functions */
char *vp_encode_size(unsigned int size, char *buf) {
  if (buf == NULL)
    return NULL;
  buf[0] = ((size >> 28) & 0x7f) | 0x80;
  buf[1] = ((size >> 21) & 0x7f) | 0x80;
  buf[2] = ((size >> 14) & 0x7f) | 0x80;
  buf[3] = ((size >> 7) & 0x7f) | 0x80;
  buf[4] = (size & 0x7f) | 0x80;
  return buf;
}


x86 assembly (clang, -O0):
<vp_encode_size>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1123 <vp_encode_size+0x23>
movq   $0x0,-0x8(%rbp)
jmp    119a <vp_encode_size+0x9a>
mov    -0xc(%rbp),%eax
shr    $0x1c,%eax
and    $0x7f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
shr    $0x15,%eax
and    $0x7f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xc(%rbp),%eax
shr    $0xe,%eax
and    $0x7f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0xc(%rbp),%eax
shr    $0x7,%eax
and    $0x7f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0xc(%rbp),%eax
and    $0x7f,%eax
or     $0x80,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp_encode_size>:
mov    %rsi,%rax
test   %rsi,%rsi
je     113b <vp_encode_size+0x3b>
mov    %edi,%ecx
shr    $0x1c,%ecx
or     $0x80,%cl
mov    %cl,(%rax)
mov    %edi,%ecx
shr    $0x15,%ecx
or     $0x80,%cl
mov    %cl,0x1(%rax)
mov    %edi,%ecx
shr    $0xe,%ecx
or     $0x80,%cl
mov    %cl,0x2(%rax)
mov    %edi,%ecx
shr    $0x7,%ecx
or     $0x80,%cl
mov    %cl,0x3(%rax)
or     $0x80,%dil
mov    %dil,0x4(%rax)
ret

LLVM IR (-O0):
define i8* @vp_encode_size(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %2
store i8* null, i8** %3
br label %45
9: ; preds = %2
%10 = load i32, i32* %4
%11 = lshr i32 %10, 28
%12 = and i32 %11, 127
%13 = or i32 %12, 128
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
store i8 %14, i8* %16
%17 = load i32, i32* %4
%18 = lshr i32 %17, 21
%19 = and i32 %18, 127
%20 = or i32 %19, 128
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %21, i8* %23
%24 = load i32, i32* %4
%25 = lshr i32 %24, 14
%26 = and i32 %25, 127
%27 = or i32 %26, 128
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8 %28, i8* %30
%31 = load i32, i32* %4
%32 = lshr i32 %31, 7
%33 = and i32 %32, 127
%34 = or i32 %33, 128
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 3
store i8 %35, i8* %37
%38 = load i32, i32* %4
%39 = and i32 %38, 127
%40 = or i32 %39, 128
%41 = trunc i32 %40 to i8
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i64 4
store i8 %41, i8* %43
%44 = load i8*, i8** %5
store i8* %44, i8** %3
br label %45
45: ; preds = %9, %8
%46 = load i8*, i8** %3
ret i8* %46
}

LLVM IR (-O2):
define i8* @vp_encode_size(i32 %0, i8* writeonly %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = lshr i32 %0, 28
%6 = trunc i32 %5 to i8
%7 = or i8 %6, -128
store i8 %7, i8* %1
%8 = lshr i32 %0, 21
%9 = trunc i32 %8 to i8
%10 = or i8 %9, -128
%11 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %10, i8* %11
%12 = lshr i32 %0, 14
%13 = trunc i32 %12 to i8
%14 = or i8 %13, -128
%15 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %14, i8* %15
%16 = lshr i32 %0, 7
%17 = trunc i32 %16 to i8
%18 = or i8 %17, -128
%19 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %18, i8* %19
%20 = trunc i32 %0 to i8
%21 = or i8 %20, -128
%22 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %21, i8* %22
br label %23
23: ; preds = %2, %4
ret i8* %1
}