#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 scalar_t__ int64_t;
typedef scalar_t__ int32_t;
typedef scalar_t__ int16_t;
typedef int /*<<< orphan*/ i64;
typedef int /*<<< orphan*/ i32;
typedef int /*<<< orphan*/ i16;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(scalar_t__ *, unsigned char *, int);
int64_t zipLoadInteger(unsigned char *p, unsigned char encoding) {
  int16_t i16;
  int32_t i32;
  int64_t i64, ret = 0;
  if (encoding == (0xc0 | 0 << 4)) {
    memcpy(&i16, p, sizeof(i16));
    ;
    ret = i16;
  } else if (encoding == (0xc0 | 1 << 4)) {
    memcpy(&i32, p, sizeof(i32));
    ;
    ret = i32;
  } else if (encoding == (0xc0 | 2 << 4)) {
    memcpy(&i64, p, sizeof(i64));
    ;
    ret = i64;
  } else {
    assert(NULL);
    ret = 0;
  }
  return ret;
}


x86 assembly (clang, -O0):
<zipLoadInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movq   $0x0,-0x30(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0xc0,%eax
jne    1168 <zipLoadInteger+0x48>
mov    -0x8(%rbp),%rsi
lea    -0x18(%rbp),%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11df <zipLoadInteger+0xbf>
movzbl -0x9(%rbp),%eax
cmp    $0xd0,%eax
jne    1196 <zipLoadInteger+0x76>
mov    -0x8(%rbp),%rsi
lea    -0x20(%rbp),%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11da <zipLoadInteger+0xba>
movzbl -0x9(%rbp),%eax
cmp    $0xe0,%eax
jne    11c4 <zipLoadInteger+0xa4>
mov    -0x8(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11d5 <zipLoadInteger+0xb5>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <assert@plt>
movq   $0x0,-0x30(%rbp)
jmp    11da <zipLoadInteger+0xba>
jmp    11df <zipLoadInteger+0xbf>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zipLoadInteger>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rax
cmp    $0xe0,%sil
je     113a <zipLoadInteger+0x1a>
cmp    $0xd0,%sil
je     113a <zipLoadInteger+0x1a>
cmp    $0xc0,%sil
jne    1153 <zipLoadInteger+0x33>
lea    0x8(%rsp),%rdi
mov    %rax,%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rbx
jmp    115c <zipLoadInteger+0x3c>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <assert@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i64 @zipLoadInteger(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %3
store i8 %1, i8* %4
store i64 0, i64* %8
%9 = load i8, i8* %4
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 192
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @memcpy(i64* %5, i8* %13, i32 8)
%15 = load i64, i64* %5
store i64 %15, i64* %8
br label %36
16: ; preds = %2
%17 = load i8, i8* %4
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 208
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = call i32 @memcpy(i64* %6, i8* %21, i32 8)
%23 = load i64, i64* %6
store i64 %23, i64* %8
br label %35
24: ; preds = %16
%25 = load i8, i8* %4
%26 = zext i8 %25 to i32
%27 = icmp eq i32 %26, 224
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = call i32 @memcpy(i64* %7, i8* %29, i32 8)
%31 = load i64, i64* %7
store i64 %31, i64* %8
br label %34
32: ; preds = %24
%33 = call i32 @assert(i32* null)
store i64 0, i64* %8
br label %34
34: ; preds = %32, %28
br label %35
35: ; preds = %34, %20
br label %36
36: ; preds = %35, %12
%37 = load i64, i64* %8
ret i64 %37
}

LLVM IR (-O2):
define i64 @zipLoadInteger(i8* %0, i8 zeroext %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = bitcast i64* %5 to i8*
switch i8 %1, label %18 [
i8 -64, label %9
i8 -48, label %12
i8 -32, label %15
]
9: ; preds = %2
%10 = call i32 @memcpy(i64* %3, i8* %0, i32 8)
%11 = load i64, i64* %3
br label %20
12: ; preds = %2
%13 = call i32 @memcpy(i64* %4, i8* %0, i32 8)
%14 = load i64, i64* %4
br label %20
15: ; preds = %2
%16 = call i32 @memcpy(i64* %5, i8* %0, i32 8)
%17 = load i64, i64* %5
br label %20
18: ; preds = %2
%19 = tail call i32 @assert(i32* null)
br label %20
20: ; preds = %12, %18, %15, %9
%21 = phi i64 [ %11, %9 ], [ %14, %12 ], [ %17, %15 ], [ 0, %18 ]
ret i64 %21
}