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


x86 assembly (clang, -O0):
<zipSaveInteger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0xc0,%eax
jne    1163 <zipSaveInteger+0x43>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
jmp    11d2 <zipSaveInteger+0xb2>
movzbl -0x11(%rbp),%eax
cmp    $0xd0,%eax
jne    1191 <zipSaveInteger+0x71>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
jmp    11cd <zipSaveInteger+0xad>
movzbl -0x11(%rbp),%eax
cmp    $0xe0,%eax
jne    11bf <zipSaveInteger+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
jmp    11c8 <zipSaveInteger+0xa8>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <assert@plt>
jmp    11cd <zipSaveInteger+0xad>
jmp    11d2 <zipSaveInteger+0xb2>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zipSaveInteger>:
push   %rax
cmp    $0xe0,%dl
je     1130 <zipSaveInteger+0x10>
cmp    $0xd0,%dl
je     1130 <zipSaveInteger+0x10>
cmp    $0xc0,%dl
jne    1143 <zipSaveInteger+0x23>
mov    %rsi,(%rsp)
mov    %rsp,%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
pop    %rax
ret
xor    %edi,%edi
pop    %rax
jmp    1030 <assert@plt>

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

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