#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 int /*<<< orphan*/ len;

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned int *, unsigned char *, int);
unsigned int zipPrevDecodeLength(unsigned char *p, unsigned int *lensize) {
  unsigned int len = *p;
  if (len < 254) {
    if (lensize)
      *lensize = 1;
  } else {
    if (lensize)
      *lensize = 1 + sizeof(len);
    memcpy(&len, p + 1, sizeof(len));
    ;
  }
  return len;
}


x86 assembly (clang, -O0):
<zipPrevDecodeLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xfe,-0x14(%rbp)
jae    1151 <zipPrevDecodeLength+0x41>
cmpq   $0x0,-0x10(%rbp)
je     114c <zipPrevDecodeLength+0x3c>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    117c <zipPrevDecodeLength+0x6c>
cmpq   $0x0,-0x10(%rbp)
je     1166 <zipPrevDecodeLength+0x56>
mov    -0x10(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
lea    -0x14(%rbp),%rdi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zipPrevDecodeLength>:
push   %rax
movzbl (%rdi),%eax
mov    %eax,0x4(%rsp)
cmp    $0xfd,%eax
ja     112c <zipPrevDecodeLength+0x1c>
test   %rsi,%rsi
je     1154 <zipPrevDecodeLength+0x44>
movl   $0x1,(%rsi)
pop    %rcx
ret
mov    %rdi,%rcx
test   %rsi,%rsi
je     113a <zipPrevDecodeLength+0x2a>
movl   $0x5,(%rsi)
add    $0x1,%rcx
lea    0x4(%rsp),%rdi
mov    %rcx,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @zipPrevDecodeLength(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ult i32 %9, 254
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load i32*, i32** %4
store i32 1, i32* %15
br label %16
16: ; preds = %14, %11
br label %26
17: ; preds = %2
%18 = load i32*, i32** %4
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = load i32*, i32** %4
store i32 5, i32* %21
br label %22
22: ; preds = %20, %17
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i32 @memcpy(i32* %5, i8* %24, i32 4)
br label %26
26: ; preds = %22, %16
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
define i32 @zipPrevDecodeLength(i8* %0, i32* writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i8, i8* %0
%6 = zext i8 %5 to i32
store i32 %6, i32* %3
%7 = icmp ult i8 %5, -2
%8 = icmp eq i32* %1, null
br i1 %7, label %9, label %11
9: ; preds = %2
br i1 %8, label %17, label %10
10: ; preds = %9
store i32 1, i32* %1
br label %17
11: ; preds = %2
br i1 %8, label %13, label %12
12: ; preds = %11
store i32 5, i32* %1
br label %13
13: ; preds = %12, %11
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = call i32 @memcpy(i32* %3, i8* %14, i32 4)
%16 = load i32, i32* %3
br label %17
17: ; preds = %9, %10, %13
%18 = phi i32 [ %6, %9 ], [ %6, %10 ], [ %16, %13 ]
ret i32 %18
}