#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*/ int64_t;

/* Variables and functions */
scalar_t__ minipack_is_int16(void *);
scalar_t__ minipack_is_int32(void *);
scalar_t__ minipack_is_int64(void *);
scalar_t__ minipack_is_int8(void *);
scalar_t__ minipack_is_neg_fixnum(void *);
scalar_t__ minipack_is_pos_fixnum(void *);
scalar_t__ minipack_is_uint16(void *);
scalar_t__ minipack_is_uint32(void *);
scalar_t__ minipack_is_uint64(void *);
scalar_t__ minipack_is_uint8(void *);
int /*<<< orphan*/ minipack_unpack_int16(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_int32(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_int64(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_int8(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_neg_fixnum(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_pos_fixnum(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_uint16(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_uint32(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_uint64(void *, size_t *);
int /*<<< orphan*/ minipack_unpack_uint8(void *, size_t *);
int64_t minipack_unpack_int(void *ptr, size_t *sz) {
  if (minipack_is_pos_fixnum(ptr)) {
    return (int64_t)minipack_unpack_pos_fixnum(ptr, sz);
  }
  if (minipack_is_neg_fixnum(ptr)) {
    return (int64_t)minipack_unpack_neg_fixnum(ptr, sz);
  } else if (minipack_is_int8(ptr)) {
    return (int64_t)minipack_unpack_int8(ptr, sz);
  } else if (minipack_is_int16(ptr)) {
    return (int64_t)minipack_unpack_int16(ptr, sz);
  } else if (minipack_is_int32(ptr)) {
    return (int64_t)minipack_unpack_int32(ptr, sz);
  } else if (minipack_is_int64(ptr)) {
    return minipack_unpack_int64(ptr, sz);
  } else if (minipack_is_uint8(ptr)) {
    return (int64_t)minipack_unpack_uint8(ptr, sz);
  } else if (minipack_is_uint16(ptr)) {
    return (int64_t)minipack_unpack_uint16(ptr, sz);
  } else if (minipack_is_uint32(ptr)) {
    return (int64_t)minipack_unpack_uint32(ptr, sz);
  } else if (minipack_is_uint64(ptr)) {
    return minipack_unpack_uint64(ptr, sz);
  } else {
    *sz = 0;
    return 0;
  }
}


x86 assembly (clang, -O0):
<minipack_unpack_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10b0 <minipack_is_pos_fixnum@plt>
cmp    $0x0,%rax
je     1278 <minipack_unpack_int+0x38>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1120 <minipack_unpack_pos_fixnum@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1140 <minipack_is_neg_fixnum@plt>
cmp    $0x0,%rax
je     12a0 <minipack_unpack_int+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1160 <minipack_unpack_neg_fixnum@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1100 <minipack_is_int8@plt>
cmp    $0x0,%rax
je     12c8 <minipack_unpack_int+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <minipack_unpack_int8@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1130 <minipack_is_int16@plt>
cmp    $0x0,%rax
je     12f0 <minipack_unpack_int+0xb0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <minipack_unpack_int16@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1030 <minipack_is_int32@plt>
cmp    $0x0,%rax
je     1318 <minipack_unpack_int+0xd8>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10e0 <minipack_unpack_int32@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1110 <minipack_is_int64@plt>
cmp    $0x0,%rax
je     1340 <minipack_unpack_int+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <minipack_unpack_int64@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1050 <minipack_is_uint8@plt>
cmp    $0x0,%rax
je     1368 <minipack_unpack_int+0x128>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <minipack_unpack_uint8@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   10c0 <minipack_is_uint16@plt>
cmp    $0x0,%rax
je     1390 <minipack_unpack_int+0x150>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10f0 <minipack_unpack_uint16@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1070 <minipack_is_uint32@plt>
cmp    $0x0,%rax
je     13b8 <minipack_unpack_int+0x178>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1150 <minipack_unpack_uint32@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x10(%rbp),%rdi
call   1040 <minipack_is_uint64@plt>
cmp    $0x0,%rax
je     13e0 <minipack_unpack_int+0x1a0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10d0 <minipack_unpack_uint64@plt>
mov    %eax,-0x4(%rbp)
jmp    13f2 <minipack_unpack_int+0x1b2>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minipack_unpack_int>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   10b0 <minipack_is_pos_fixnum@plt>
test   %rax,%rax
je     1266 <minipack_unpack_int+0x26>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1120 <minipack_unpack_pos_fixnum@plt>
mov    %rbx,%rdi
call   1140 <minipack_is_neg_fixnum@plt>
test   %rax,%rax
je     1285 <minipack_unpack_int+0x45>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1160 <minipack_unpack_neg_fixnum@plt>
mov    %rbx,%rdi
call   1100 <minipack_is_int8@plt>
test   %rax,%rax
je     12a4 <minipack_unpack_int+0x64>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <minipack_unpack_int8@plt>
mov    %rbx,%rdi
call   1130 <minipack_is_int16@plt>
test   %rax,%rax
je     12c3 <minipack_unpack_int+0x83>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1090 <minipack_unpack_int16@plt>
mov    %rbx,%rdi
call   1030 <minipack_is_int32@plt>
test   %rax,%rax
je     12e2 <minipack_unpack_int+0xa2>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    10e0 <minipack_unpack_int32@plt>
mov    %rbx,%rdi
call   1110 <minipack_is_int64@plt>
test   %rax,%rax
je     1301 <minipack_unpack_int+0xc1>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    10a0 <minipack_unpack_int64@plt>
mov    %rbx,%rdi
call   1050 <minipack_is_uint8@plt>
test   %rax,%rax
je     1320 <minipack_unpack_int+0xe0>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <minipack_unpack_uint8@plt>
mov    %rbx,%rdi
call   10c0 <minipack_is_uint16@plt>
test   %rax,%rax
je     133f <minipack_unpack_int+0xff>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    10f0 <minipack_unpack_uint16@plt>
mov    %rbx,%rdi
call   1070 <minipack_is_uint32@plt>
test   %rax,%rax
je     135e <minipack_unpack_int+0x11e>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1150 <minipack_unpack_uint32@plt>
mov    %rbx,%rdi
call   1040 <minipack_is_uint64@plt>
test   %rax,%rax
je     137d <minipack_unpack_int+0x13d>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    10d0 <minipack_unpack_uint64@plt>
movq   $0x0,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @minipack_unpack_int(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
store i8* %0, i8** %4
store i64* %1, i64** %5
%6 = load i8*, i8** %4
%7 = call i64 @minipack_is_pos_fixnum(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = load i64*, i64** %5
%12 = call i32 @minipack_unpack_pos_fixnum(i8* %10, i64* %11)
store i32 %12, i32* %3
br label %87
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @minipack_is_neg_fixnum(i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = load i64*, i64** %5
%20 = call i32 @minipack_unpack_neg_fixnum(i8* %18, i64* %19)
store i32 %20, i32* %3
br label %87
21: ; preds = %13
%22 = load i8*, i8** %4
%23 = call i64 @minipack_is_int8(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8*, i8** %4
%27 = load i64*, i64** %5
%28 = call i32 @minipack_unpack_int8(i8* %26, i64* %27)
store i32 %28, i32* %3
br label %87
29: ; preds = %21
%30 = load i8*, i8** %4
%31 = call i64 @minipack_is_int16(i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i8*, i8** %4
%35 = load i64*, i64** %5
%36 = call i32 @minipack_unpack_int16(i8* %34, i64* %35)
store i32 %36, i32* %3
br label %87
37: ; preds = %29
%38 = load i8*, i8** %4
%39 = call i64 @minipack_is_int32(i8* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i8*, i8** %4
%43 = load i64*, i64** %5
%44 = call i32 @minipack_unpack_int32(i8* %42, i64* %43)
store i32 %44, i32* %3
br label %87
45: ; preds = %37
%46 = load i8*, i8** %4
%47 = call i64 @minipack_is_int64(i8* %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i8*, i8** %4
%51 = load i64*, i64** %5
%52 = call i32 @minipack_unpack_int64(i8* %50, i64* %51)
store i32 %52, i32* %3
br label %87
53: ; preds = %45
%54 = load i8*, i8** %4
%55 = call i64 @minipack_is_uint8(i8* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i8*, i8** %4
%59 = load i64*, i64** %5
%60 = call i32 @minipack_unpack_uint8(i8* %58, i64* %59)
store i32 %60, i32* %3
br label %87
61: ; preds = %53
%62 = load i8*, i8** %4
%63 = call i64 @minipack_is_uint16(i8* %62)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i8*, i8** %4
%67 = load i64*, i64** %5
%68 = call i32 @minipack_unpack_uint16(i8* %66, i64* %67)
store i32 %68, i32* %3
br label %87
69: ; preds = %61
%70 = load i8*, i8** %4
%71 = call i64 @minipack_is_uint32(i8* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load i8*, i8** %4
%75 = load i64*, i64** %5
%76 = call i32 @minipack_unpack_uint32(i8* %74, i64* %75)
store i32 %76, i32* %3
br label %87
77: ; preds = %69
%78 = load i8*, i8** %4
%79 = call i64 @minipack_is_uint64(i8* %78)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %77
%82 = load i8*, i8** %4
%83 = load i64*, i64** %5
%84 = call i32 @minipack_unpack_uint64(i8* %82, i64* %83)
store i32 %84, i32* %3
br label %87
85: ; preds = %77
%86 = load i64*, i64** %5
store i64 0, i64* %86
store i32 0, i32* %3
br label %87
87: ; preds = %85, %81, %73, %65, %57, %49, %41, %33, %25, %17, %9
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
define i32 @minipack_unpack_int(i8* %0, i64* %1) {
%3 = tail call i64 @minipack_is_pos_fixnum(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @minipack_unpack_pos_fixnum(i8* %0, i64* %1)
br label %53
7: ; preds = %2
%8 = tail call i64 @minipack_is_neg_fixnum(i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @minipack_unpack_neg_fixnum(i8* %0, i64* %1)
br label %53
12: ; preds = %7
%13 = tail call i64 @minipack_is_int8(i8* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @minipack_unpack_int8(i8* %0, i64* %1)
br label %53
17: ; preds = %12
%18 = tail call i64 @minipack_is_int16(i8* %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @minipack_unpack_int16(i8* %0, i64* %1)
br label %53
22: ; preds = %17
%23 = tail call i64 @minipack_is_int32(i8* %0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @minipack_unpack_int32(i8* %0, i64* %1)
br label %53
27: ; preds = %22
%28 = tail call i64 @minipack_is_int64(i8* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @minipack_unpack_int64(i8* %0, i64* %1)
br label %53
32: ; preds = %27
%33 = tail call i64 @minipack_is_uint8(i8* %0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @minipack_unpack_uint8(i8* %0, i64* %1)
br label %53
37: ; preds = %32
%38 = tail call i64 @minipack_is_uint16(i8* %0)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call i32 @minipack_unpack_uint16(i8* %0, i64* %1)
br label %53
42: ; preds = %37
%43 = tail call i64 @minipack_is_uint32(i8* %0)
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call i32 @minipack_unpack_uint32(i8* %0, i64* %1)
br label %53
47: ; preds = %42
%48 = tail call i64 @minipack_is_uint64(i8* %0)
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = tail call i32 @minipack_unpack_uint64(i8* %0, i64* %1)
br label %53
52: ; preds = %47
store i64 0, i64* %1
br label %53
53: ; preds = %52, %50, %45, %40, %35, %30, %25, %20, %15, %10, %5
%54 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ %21, %20 ], [ %26, %25 ], [ %31, %30 ], [ %36, %35 ], [ %41, %40 ], [ %46, %45 ], [ %51, %50 ], [ 0, %52 ]
ret i32 %54
}