#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 */
long GetMultibyteLength(char const);
void NextPos(const unsigned char **pos, const char **key,
             const char **multibyte_start) {
  ++*pos;
  if (*multibyte_start) {
    ++*key;
    if (*key - *multibyte_start == GetMultibyteLength(**multibyte_start))
      *multibyte_start = 0;
  } else {
    if (GetMultibyteLength(**key)) {
      *multibyte_start = *key;
    } else {
      ++*key;
    }
  }
}


x86 assembly (clang, -O0):
<NextPos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1192 <NextPos+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <GetMultibyteLength@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    118d <NextPos+0x7d>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    11d1 <NextPos+0xc1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1030 <GetMultibyteLength@plt>
cmp    $0x0,%rax
je     11be <NextPos+0xae>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11cc <NextPos+0xbc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11d1 <NextPos+0xc1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NextPos>:
push   %r15
push   %r14
push   %rbx
addq   $0x1,(%rdi)
mov    %rdx,%r14
mov    %rsi,%r15
cmpq   $0x0,(%rdx)
mov    (%rsi),%rbx
je     114b <NextPos+0x3b>
add    $0x1,%rbx
mov    %rbx,(%r15)
mov    (%r14),%rax
sub    %rax,%rbx
movsbl (%rax),%edi
call   1030 <GetMultibyteLength@plt>
cmp    %rax,%rbx
jne    1167 <NextPos+0x57>
movq   $0x0,(%r14)
jmp    1167 <NextPos+0x57>
movsbl (%rbx),%edi
call   1030 <GetMultibyteLength@plt>
mov    (%r15),%rcx
test   %rax,%rax
je     1160 <NextPos+0x50>
mov    %rcx,(%r14)
jmp    1167 <NextPos+0x57>
add    $0x1,%rcx
mov    %rcx,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @NextPos(i8** nocapture %0, i8** nocapture %1, i8** nocapture %2) {
%4 = load i8*, i8** %0
%5 = getelementptr inbounds i8, i8* %4, i64 1
store i8* %5, i8** %0
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
%8 = load i8*, i8** %1
br i1 %7, label %19, label %9
9: ; preds = %3
%10 = getelementptr inbounds i8, i8* %8, i64 1
store i8* %10, i8** %1
%11 = load i8*, i8** %2
%12 = ptrtoint i8* %10 to i64
%13 = ptrtoint i8* %11 to i64
%14 = sub i64 %12, %13
%15 = load i8, i8* %11
%16 = tail call i64 @GetMultibyteLength(i8 signext %15)
%17 = icmp eq i64 %14, %16
br i1 %17, label %18, label %27
18: ; preds = %9
store i8* null, i8** %2
br label %27
19: ; preds = %3
%20 = load i8, i8* %8
%21 = tail call i64 @GetMultibyteLength(i8 signext %20)
%22 = icmp eq i64 %21, 0
%23 = load i8*, i8** %1
br i1 %22, label %25, label %24
24: ; preds = %19
store i8* %23, i8** %2
br label %27
25: ; preds = %19
%26 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %26, i8** %1
br label %27
27: ; preds = %24, %25, %9, %18
ret void
}