int next_token(char **current) {
  int result = 0;
  int i = 0;
  do {
    result = (result << 8) | **current;
  } while ((i++ < 3) && ((*(*current)++ & 0x80) != 0));
  return result;
}


x86 assembly (clang, -O0):
<next_token>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x11(%rbp)
jge    1166 <next_token+0x66>
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movsbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1116 <next_token+0x16>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_token>:
mov    (%rdi),%rcx
movsbl (%rcx),%eax
lea    0x1(%rcx),%rdx
mov    %rdx,(%rdi)
cmpb   $0x0,(%rcx)
js     1113 <next_token+0x13>
ret
mov    %eax,%edx
shl    $0x8,%edx
movsbl 0x1(%rcx),%eax
or     %edx,%eax
lea    0x2(%rcx),%rdx
mov    %rdx,(%rdi)
cmpb   $0x0,0x1(%rcx)
jns    1112 <next_token+0x12>
mov    %eax,%edx
shl    $0x8,%edx
movsbl 0x2(%rcx),%eax
or     %edx,%eax
lea    0x3(%rcx),%rdx
mov    %rdx,(%rdi)
cmpb   $0x0,0x2(%rcx)
jns    1112 <next_token+0x12>
shl    $0x8,%eax
movsbl (%rdx),%ecx
or     %ecx,%eax
ret

LLVM IR (-O0):
define i32 @next_token(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i32
store i8** %0, i8*** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %25, %1
%6 = load i32, i32* %3
%7 = shl i32 %6, 8
%8 = load i8**, i8*** %2
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = or i32 %7, %11
store i32 %12, i32* %3
br label %13
13: ; preds = %5
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
%16 = icmp slt i32 %14, 3
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i8**, i8*** %2
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %18
%21 = load i8, i8* %19
%22 = sext i8 %21 to i32
%23 = and i32 %22, 128
%24 = icmp ne i32 %23, 0
br label %25
25: ; preds = %17, %13
%26 = phi i1 [ false, %13 ], [ %24, %17 ]
br i1 %26, label %5, label %27
27: ; preds = %25
%28 = load i32, i32* %3
ret i32 %28
}

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