#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 zipmapDecodeLength(unsigned char *);
int /*<<< orphan*/ zipmapRawKeyLength(unsigned char *);
int /*<<< orphan*/ zipmapRawValueLength(unsigned char *);
unsigned char *zipmapNext(unsigned char *zm, unsigned char **key,
                          unsigned int *klen, unsigned char **value,
                          unsigned int *vlen) {
  if (zm[0] == 255)
    return NULL;
  if (key) {
    *key = zm;
    *klen = zipmapDecodeLength(zm);
    *key += (((*klen) < 254) ? 1 : sizeof(unsigned int) + 1);
  }
  zm += zipmapRawKeyLength(zm);
  if (value) {
    *value = zm + 1;
    *vlen = zipmapDecodeLength(zm);
    *value += (((*vlen) < 254) ? 1 : sizeof(unsigned int) + 1);
  }
  zm += zipmapRawValueLength(zm);
  return zm;
}


x86 assembly (clang, -O0):
<zipmapNext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    116b <zipmapNext+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    123f <zipmapNext+0x10f>
cmpq   $0x0,-0x18(%rbp)
je     11b6 <zipmapNext+0x86>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <zipmapDecodeLength@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
mov    $0x5,%ecx
mov    $0x1,%eax
cmp    $0xfe,%edx
cmovb  %rax,%rcx
mov    -0x18(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <zipmapRawKeyLength@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     121e <zipmapNext+0xee>
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <zipmapDecodeLength@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    $0x5,%ecx
mov    $0x1,%eax
cmp    $0xfe,%edx
cmovb  %rax,%rcx
mov    -0x28(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <zipmapRawValueLength@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zipmapNext>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmpb   $0xff,(%rdi)
je     11cd <zipmapNext+0x9d>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
test   %rsi,%rsi
je     1180 <zipmapNext+0x50>
mov    %rdx,%r13
mov    %rbx,(%r12)
mov    %rbx,%rdi
call   1050 <zipmapDecodeLength@plt>
mov    %eax,0x0(%r13)
xor    %ecx,%ecx
cmp    $0xfe,%eax
setae  %cl
mov    (%r12),%rax
lea    (%rax,%rcx,4),%rax
add    $0x1,%rax
mov    %rax,(%r12)
mov    %rbx,%rdi
call   1040 <zipmapRawKeyLength@plt>
movslq %eax,%r12
add    %rbx,%r12
test   %r15,%r15
je     11be <zipmapNext+0x8e>
lea    0x1(%r12),%rax
mov    %rax,(%r15)
mov    %r12,%rdi
call   1050 <zipmapDecodeLength@plt>
mov    %eax,(%r14)
xor    %ecx,%ecx
cmp    $0xfe,%eax
setae  %cl
mov    (%r15),%rax
lea    (%rax,%rcx,4),%rax
add    $0x1,%rax
mov    %rax,(%r15)
mov    %r12,%rdi
call   1030 <zipmapRawValueLength@plt>
cltq
add    %r12,%rax
jmp    11cf <zipmapNext+0x9f>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @zipmapNext(i8* %0, i8** %1, i32* %2, i8** %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8**
%11 = alloca i32*
store i8* %0, i8** %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i8** %3, i8*** %10
store i32* %4, i32** %11
%12 = load i8*, i8** %7
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 255
br i1 %16, label %17, label %18
17: ; preds = %5
store i8* null, i8** %6
br label %65
18: ; preds = %5
%19 = load i8**, i8*** %8
%20 = icmp ne i8** %19, null
br i1 %20, label %21, label %35
21: ; preds = %18
%22 = load i8*, i8** %7
%23 = load i8**, i8*** %8
store i8* %22, i8** %23
%24 = load i8*, i8** %7
%25 = call i32 @zipmapDecodeLength(i8* %24)
%26 = load i32*, i32** %9
store i32 %25, i32* %26
%27 = load i32*, i32** %9
%28 = load i32, i32* %27
%29 = icmp ult i32 %28, 254
%30 = zext i1 %29 to i64
%31 = select i1 %29, i64 1, i64 5
%32 = load i8**, i8*** %8
%33 = load i8*, i8** %32
%34 = getelementptr inbounds i8, i8* %33, i64 %31
store i8* %34, i8** %32
br label %35
35: ; preds = %21, %18
%36 = load i8*, i8** %7
%37 = call i32 @zipmapRawKeyLength(i8* %36)
%38 = load i8*, i8** %7
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i8, i8* %38, i64 %39
store i8* %40, i8** %7
%41 = load i8**, i8*** %10
%42 = icmp ne i8** %41, null
br i1 %42, label %43, label %58
43: ; preds = %35
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8**, i8*** %10
store i8* %45, i8** %46
%47 = load i8*, i8** %7
%48 = call i32 @zipmapDecodeLength(i8* %47)
%49 = load i32*, i32** %11
store i32 %48, i32* %49
%50 = load i32*, i32** %11
%51 = load i32, i32* %50
%52 = icmp ult i32 %51, 254
%53 = zext i1 %52 to i64
%54 = select i1 %52, i64 1, i64 5
%55 = load i8**, i8*** %10
%56 = load i8*, i8** %55
%57 = getelementptr inbounds i8, i8* %56, i64 %54
store i8* %57, i8** %55
br label %58
58: ; preds = %43, %35
%59 = load i8*, i8** %7
%60 = call i32 @zipmapRawValueLength(i8* %59)
%61 = load i8*, i8** %7
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i8, i8* %61, i64 %62
store i8* %63, i8** %7
%64 = load i8*, i8** %7
store i8* %64, i8** %6
br label %65
65: ; preds = %58, %17
%66 = load i8*, i8** %6
ret i8* %66
}

LLVM IR (-O2):
define i8* @zipmapNext(i8* %0, i8** %1, i32* nocapture writeonly %2, i8** %3, i32* nocapture writeonly %4) {
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, -1
br i1 %7, label %32, label %8
8: ; preds = %5
%9 = icmp eq i8** %1, null
br i1 %9, label %16, label %10
10: ; preds = %8
store i8* %0, i8** %1
%11 = tail call i32 @zipmapDecodeLength(i8* %0)
store i32 %11, i32* %2
%12 = icmp ult i32 %11, 254
%13 = select i1 %12, i64 1, i64 5
%14 = load i8*, i8** %1
%15 = getelementptr inbounds i8, i8* %14, i64 %13
store i8* %15, i8** %1
br label %16
16: ; preds = %10, %8
%17 = tail call i32 @zipmapRawKeyLength(i8* %0)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = icmp eq i8** %3, null
br i1 %20, label %28, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %22, i8** %3
%23 = tail call i32 @zipmapDecodeLength(i8* %19)
store i32 %23, i32* %4
%24 = icmp ult i32 %23, 254
%25 = select i1 %24, i64 1, i64 5
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 %25
store i8* %27, i8** %3
br label %28
28: ; preds = %21, %16
%29 = tail call i32 @zipmapRawValueLength(i8* %19)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %19, i64 %30
br label %32
32: ; preds = %5, %28
%33 = phi i8* [ %31, %28 ], [ null, %5 ]
ret i8* %33
}