#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*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ minipack_pack_array16(void *, int /*<<< orphan*/, size_t *);
int /*<<< orphan*/ minipack_pack_array32(void *, int, size_t *);
int /*<<< orphan*/ minipack_pack_fixarray(void *, int /*<<< orphan*/, size_t *);
void minipack_pack_array(void *ptr, uint32_t count, size_t *sz) {
  if (count <= 15) {
    minipack_pack_fixarray(ptr, (uint8_t)count, sz);
    return;
  } else if (count <= 65535) {
    minipack_pack_array16(ptr, (uint16_t)count, sz);
    return;
  }
  minipack_pack_array32(ptr, count, sz);
}


x86 assembly (clang, -O0):
<minipack_pack_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0xf,-0xc(%rbp)
jg     1162 <minipack_pack_array+0x32>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <minipack_pack_fixarray@plt>
jmp    1199 <minipack_pack_array+0x69>
cmpl   $0xffff,-0xc(%rbp)
jg     1184 <minipack_pack_array+0x54>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <minipack_pack_array16@plt>
jmp    1199 <minipack_pack_array+0x69>
jmp    1189 <minipack_pack_array+0x59>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1040 <minipack_pack_array32@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minipack_pack_array>:
cmp    $0xf,%esi
jg     113a <minipack_pack_array+0xa>
jmp    1050 <minipack_pack_fixarray@plt>
cmp    $0xffff,%esi
ja     1147 <minipack_pack_array+0x17>
jmp    1030 <minipack_pack_array16@plt>
jmp    1040 <minipack_pack_array32@plt>

LLVM IR (-O0):
define void @minipack_pack_array(i8* %0, i32 %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i64* %2, i64** %6
%7 = load i32, i32* %5
%8 = icmp sle i32 %7, 15
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = load i64*, i64** %6
%13 = call i32 @minipack_pack_fixarray(i8* %10, i32 %11, i64* %12)
br label %28
14: ; preds = %3
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 65535
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = load i64*, i64** %6
%21 = call i32 @minipack_pack_array16(i8* %18, i32 %19, i64* %20)
br label %28
22: ; preds = %14
br label %23
23: ; preds = %22
%24 = load i8*, i8** %4
%25 = load i32, i32* %5
%26 = load i64*, i64** %6
%27 = call i32 @minipack_pack_array32(i8* %24, i32 %25, i64* %26)
br label %28
28: ; preds = %23, %17, %9
ret void
}

LLVM IR (-O2):
define void @minipack_pack_array(i8* %0, i32 %1, i64* %2) {
%4 = icmp slt i32 %1, 16
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @minipack_pack_fixarray(i8* %0, i32 %1, i64* %2)
br label %13
7: ; preds = %3
%8 = icmp ult i32 %1, 65536
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @minipack_pack_array16(i8* %0, i32 %1, i64* %2)
br label %13
11: ; preds = %7
%12 = tail call i32 @minipack_pack_array32(i8* %0, i32 %1, i64* %2)
br label %13
13: ; preds = %11, %9, %5
ret void
}