#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 */
unsigned int vp_decode_size(const char *buf) {
  if (buf == NULL)
    return 0;
  return ((unsigned int)(buf[0] & 0x7f) << 28) +
         ((unsigned int)(buf[1] & 0x7f) << 21) +
         ((unsigned int)(buf[2] & 0x7f) << 14) +
         ((unsigned int)(buf[3] & 0x7f) << 7) + ((unsigned int)(buf[4] & 0x7f));
}


x86 assembly (clang, -O0):
<vp_decode_size>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    111f <vp_decode_size+0x1f>
movl   $0x0,-0x4(%rbp)
jmp    116c <vp_decode_size+0x6c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0x7f,%eax
shl    $0x1c,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
and    $0x7f,%ecx
shl    $0x15,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
and    $0x7f,%ecx
shl    $0xe,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x3(%rcx),%ecx
and    $0x7f,%ecx
shl    $0x7,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x4(%rcx),%ecx
and    $0x7f,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<vp_decode_size>:
test   %rdi,%rdi
je     1139 <vp_decode_size+0x39>
movzbl (%rdi),%eax
shl    $0x1c,%eax
movzbl 0x1(%rdi),%ecx
and    $0x7f,%ecx
shl    $0x15,%ecx
or     %eax,%ecx
movzbl 0x2(%rdi),%eax
and    $0x7f,%eax
shl    $0xe,%eax
or     %ecx,%eax
movzbl 0x3(%rdi),%ecx
and    $0x7f,%ecx
shl    $0x7,%ecx
or     %eax,%ecx
movzbl 0x4(%rdi),%eax
and    $0x7f,%eax
or     %ecx,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @vp_decode_size(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = zext i8 %4 to i32
%6 = shl i32 %5, 28
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = and i8 %8, 127
%10 = zext i8 %9 to i32
%11 = shl nuw nsw i32 %10, 21
%12 = or i32 %11, %6
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = and i8 %14, 127
%16 = zext i8 %15 to i32
%17 = shl nuw nsw i32 %16, 14
%18 = or i32 %12, %17
%19 = getelementptr inbounds i8, i8* %0, i64 3
%20 = load i8, i8* %19
%21 = and i8 %20, 127
%22 = zext i8 %21 to i32
%23 = shl nuw nsw i32 %22, 7
%24 = or i32 %18, %23
%25 = getelementptr inbounds i8, i8* %0, i64 4
%26 = load i8, i8* %25
%27 = and i8 %26, 127
%28 = zext i8 %27 to i32
%29 = or i32 %24, %28
br label %30
30: ; preds = %1, %3
%31 = phi i32 [ %29, %3 ], [ 0, %1 ]
ret i32 %31
}