#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 unsigned int uintmax_t;
typedef unsigned int uint64_t;

/* Variables and functions */
unsigned int UINT64_MAX;
scalar_t__ likely(int);
uint64_t __attribute__((unused))
__libdw_get_uleb128(uint64_t acc, unsigned int i, const unsigned char **addrp) {
  unsigned char __b;
  do {
    for (; i < 10; ++i) {
      __b = *(*addrp)++;
      acc |= (uintmax_t)(__b & 0x7f) << (i * 7);
      if (likely((__b & 0x80) == 0))
        return acc;
    }
    return UINT64_MAX;
  } while (0);
}


x86 assembly (clang, -O0):
<__libdw_get_uleb128>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
jmp    1127 <__libdw_get_uleb128+0x17>
cmpl   $0xa,-0xc(%rbp)
jae    119b <__libdw_get_uleb128+0x8b>
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
and    $0x7f,%eax
imul   $0x7,-0xc(%rbp),%ecx
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movzbl -0x19(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <likely@plt>
cmp    $0x0,%rax
je     1188 <__libdw_get_uleb128+0x78>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <__libdw_get_uleb128+0x97>
jmp    118d <__libdw_get_uleb128+0x7d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1127 <__libdw_get_uleb128+0x17>
mov    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__libdw_get_uleb128>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x9,%esi
ja     1162 <__libdw_get_uleb128+0x52>
mov    %rdx,%r14
mov    %edi,%ebp
lea    -0xa(%rsi),%r15d
lea    0x0(,%rsi,8),%ebx
sub    %esi,%ebx
xchg   %ax,%ax
mov    %ebp,%eax
mov    (%r14),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,(%r14)
movzbl (%rcx),%edi
mov    %edi,%ebp
and    $0x7f,%ebp
mov    %ebx,%ecx
shl    %cl,%ebp
or     %eax,%ebp
shr    $0x7,%edi
xor    $0x1,%edi
call   1030 <likely@plt>
test   %rax,%rax
jne    116b <__libdw_get_uleb128+0x5b>
add    $0x7,%ebx
inc    %r15d
jne    1130 <__libdw_get_uleb128+0x20>
mov    0x2e6f(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@UINT64_MAX = global i32 0
define i32 @__libdw_get_uleb128(i32 %0, i32 %1, i8** nocapture %2) {
%4 = icmp ult i32 %1, 10
br i1 %4, label %8, label %23
5: ; preds = %8
%6 = add nuw nsw i32 %10, 1
%7 = icmp eq i32 %6, 10
br i1 %7, label %23, label %8
8: ; preds = %3, %5
%9 = phi i32 [ %18, %5 ], [ %0, %3 ]
%10 = phi i32 [ %6, %5 ], [ %1, %3 ]
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8* %12, i8** %2
%13 = load i8, i8* %11
%14 = zext i8 %13 to i32
%15 = and i32 %14, 127
%16 = mul nuw nsw i32 %10, 7
%17 = shl i32 %15, %16
%18 = or i32 %17, %9
%19 = lshr i32 %14, 7
%20 = xor i32 %19, 1
%21 = tail call i64 @likely(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %5, label %25
23: ; preds = %5, %3
%24 = load i32, i32* @UINT64_MAX
br label %25
25: ; preds = %8, %23
%26 = phi i32 [ %24, %23 ], [ %18, %8 ]
ret i32 %26
}