#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 uint8_t;
typedef scalar_t__ int8_t;
typedef int int64_t;
typedef int int32_t;
typedef int 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(unsigned char *, int *, int);
void zipSaveInteger(unsigned char *p, int64_t value, unsigned char encoding) {
  int16_t i16;
  int32_t i32;
  int64_t i64;
  if (encoding == 0xfe) {
    ((int8_t *)p)[0] = (int8_t)value;
  } else if (encoding == (0xc0 | 0 << 4)) {
    i16 = value;
    memcpy(p, &i16, sizeof(i16));
    ;
  } else if (encoding == (0xc0 | 3 << 4)) {
    i32 = value << 8;
    ;
    memcpy(p, ((uint8_t *)&i32) + 1, sizeof(i32) - sizeof(uint8_t));
  } else if (encoding == (0xc0 | 1 << 4)) {
    i32 = value;
    memcpy(p, &i32, sizeof(i32));
    ;
  } else if (encoding == (0xc0 | 2 << 4)) {
    i64 = value;
    memcpy(p, &i64, sizeof(i64));
    ;
  } else if (encoding >= 0xf1 && encoding <= 0xfd) {
  } else {
    assert(NULL);
  }
}


x86 assembly (clang, -O0):
<zipSaveInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%eax
cmp    $0xfe,%eax
jne    1153 <zipSaveInteger+0x33>
movslq -0xc(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    124c <zipSaveInteger+0x12c>
movzbl -0xd(%rbp),%eax
cmp    $0xc0,%eax
jne    117f <zipSaveInteger+0x5f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
jmp    1247 <zipSaveInteger+0x127>
movzbl -0xd(%rbp),%eax
cmp    $0xf0,%eax
jne    11af <zipSaveInteger+0x8f>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
add    $0x4,%rsi
xor    %edx,%edx
call   1040 <memcpy@plt>
jmp    1242 <zipSaveInteger+0x122>
movzbl -0xd(%rbp),%eax
cmp    $0xd0,%eax
jne    11db <zipSaveInteger+0xbb>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
jmp    123d <zipSaveInteger+0x11d>
movzbl -0xd(%rbp),%eax
cmp    $0xe0,%eax
jne    1207 <zipSaveInteger+0xe7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
jmp    1238 <zipSaveInteger+0x118>
movzbl -0xd(%rbp),%eax
cmp    $0xf1,%eax
jl     122a <zipSaveInteger+0x10a>
movzbl -0xd(%rbp),%eax
cmp    $0xfd,%eax
jg     122a <zipSaveInteger+0x10a>
jmp    1233 <zipSaveInteger+0x113>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <assert@plt>
jmp    1238 <zipSaveInteger+0x118>
jmp    123d <zipSaveInteger+0x11d>
jmp    1242 <zipSaveInteger+0x122>
jmp    1247 <zipSaveInteger+0x127>
jmp    124c <zipSaveInteger+0x12c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zipSaveInteger>:
sub    $0x18,%rsp
cmp    $0xdf,%dl
jle    1143 <zipSaveInteger+0x23>
cmp    $0xe0,%dl
je     1158 <zipSaveInteger+0x38>
cmp    $0xf0,%dl
je     1163 <zipSaveInteger+0x43>
cmp    $0xfe,%dl
jne    118b <zipSaveInteger+0x6b>
movslq %esi,%rax
mov    %rax,(%rdi)
add    $0x18,%rsp
ret
cmp    $0xc0,%dl
je     1173 <zipSaveInteger+0x53>
cmp    $0xd0,%dl
jne    118b <zipSaveInteger+0x6b>
mov    %esi,0xc(%rsp)
lea    0xc(%rsp),%rsi
jmp    117c <zipSaveInteger+0x5c>
mov    %esi,0x10(%rsp)
lea    0x10(%rsp),%rsi
jmp    117c <zipSaveInteger+0x5c>
shl    $0x8,%esi
mov    %esi,0xc(%rsp)
lea    0x10(%rsp),%rsi
xor    %edx,%edx
jmp    1181 <zipSaveInteger+0x61>
mov    %esi,0x14(%rsp)
lea    0x14(%rsp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
add    $0x18,%rsp
ret
add    $0xf,%dl
cmp    $0xd,%dl
jb     1186 <zipSaveInteger+0x66>
xor    %edi,%edi
add    $0x18,%rsp
jmp    1030 <assert@plt>

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

LLVM IR (-O2):
define void @zipSaveInteger(i8* %0, i32 %1, i8 zeroext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
switch i8 %2, label %23 [
i8 -2, label %10
i8 -64, label %13
i8 -16, label %15
i8 -48, label %19
i8 -32, label %21
]
10: ; preds = %3
%11 = sext i32 %1 to i64
%12 = bitcast i8* %0 to i64*
store i64 %11, i64* %12
br label %28
13: ; preds = %3
store i32 %1, i32* %4
%14 = call i32 @memcpy(i8* %0, i32* %4, i32 4)
br label %28
15: ; preds = %3
%16 = shl i32 %1, 8
store i32 %16, i32* %5
%17 = getelementptr inbounds i32, i32* %5, i64 1
%18 = call i32 @memcpy(i8* %0, i32* %17, i32 0)
br label %28
19: ; preds = %3
store i32 %1, i32* %5
%20 = call i32 @memcpy(i8* %0, i32* %5, i32 4)
br label %28
21: ; preds = %3
store i32 %1, i32* %6
%22 = call i32 @memcpy(i8* %0, i32* %6, i32 4)
br label %28
23: ; preds = %3
%24 = add i8 %2, 15
%25 = icmp ult i8 %24, 13
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 @assert(i32* null)
br label %28
28: ; preds = %13, %19, %26, %23, %21, %15, %10
ret void
}