#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 */
int zipRawEntryLength(unsigned char *);
unsigned char *ziplistNext(unsigned char *zl, unsigned char *p) {
  ((void)zl);
  if (p[0] == 255) {
    return NULL;
  } else {
    p = p + zipRawEntryLength(p);
    return (p[0] == 255) ? NULL : p;
  }
}


x86 assembly (clang, -O0):
<ziplistNext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    113f <ziplistNext+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    118d <ziplistNext+0x7d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <zipRawEntryLength@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
jne    117d <ziplistNext+0x6d>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1185 <ziplistNext+0x75>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ziplistNext>:
push   %rbx
cmpb   $0xff,(%rsi)
je     1134 <ziplistNext+0x24>
mov    %rsi,%rbx
mov    %rsi,%rdi
call   1030 <zipRawEntryLength@plt>
movslq %eax,%rcx
lea    (%rbx,%rcx,1),%rdx
xor    %eax,%eax
cmpb   $0xff,(%rbx,%rcx,1)
cmovne %rdx,%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @ziplistNext(i8* nocapture readnone %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, -1
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = tail call i32 @zipRawEntryLength(i8* %1)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, -1
%11 = select i1 %10, i8* null, i8* %8
br label %12
12: ; preds = %2, %5
%13 = phi i8* [ %11, %5 ], [ null, %2 ]
ret i8* %13
}