#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ test_pack_unpack(int *, int, int);
int test_packing_unpacking() {
  uint16_t a[3] = {0x1, 0x2, 0x3};
  uint16_t b[4] = {0xFF01, 0xFF02, 0xFF03, 0xFF04};
  uint16_t c[5] = {0x0160, 0x0270, 0x0380, 0x0490, 0x05A0};
  if (!test_pack_unpack(a, 3, 8) || !test_pack_unpack(b, 4, 4) ||
      !test_pack_unpack(c, 5, 9)) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<test_packing_unpacking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xefd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xefa(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
mov    $0x8,%edx
call   1030 <test_pack_unpack@plt>
cmp    $0x0,%eax
je     11b2 <test_packing_unpacking+0xa2>
lea    -0x20(%rbp),%rdi
mov    $0x4,%edx
mov    %edx,%esi
call   1030 <test_pack_unpack@plt>
cmp    $0x0,%eax
je     11b2 <test_packing_unpacking+0xa2>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
mov    $0x9,%edx
call   1030 <test_pack_unpack@plt>
cmp    $0x0,%eax
jne    11be <test_packing_unpacking+0xae>
movl   $0x0,-0x4(%rbp)
jmp    11c5 <test_packing_unpacking+0xb5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_packing_unpacking>:
push   %rbx
sub    $0x40,%rsp
mov    0xeed(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeda(%rip),%rax
mov    %rax,(%rsp)
movaps 0xeff(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xee4(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
mov    $0x8,%edx
call   1030 <test_pack_unpack@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1197 <test_packing_unpacking+0x87>
lea    0x30(%rsp),%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1030 <test_pack_unpack@plt>
test   %eax,%eax
je     1197 <test_packing_unpacking+0x87>
lea    0x10(%rsp),%rdi
mov    $0x5,%esi
mov    $0x9,%edx
call   1030 <test_pack_unpack@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_packing_unpacking.a = [3 x i32] [i32 1, i32 2, i32 3]
@__const.test_packing_unpacking.b = [4 x i32] [i32 65281, i32 65282, i32 65283, i32 65284]
@__const.test_packing_unpacking.c = [5 x i32] [i32 352, i32 624, i32 896, i32 1168, i32 1440]
define i32 @test_packing_unpacking() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca [4 x i32]
%4 = alloca [5 x i32]
%5 = bitcast [3 x i32]* %2 to i8*
%6 = bitcast [4 x i32]* %3 to i8*
%7 = bitcast [5 x i32]* %4 to i8*
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%9 = call i32 @test_pack_unpack(i32* %8, i32 3, i32 8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %0
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%13 = call i32 @test_pack_unpack(i32* %12, i32 4, i32 4)
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%17 = call i32 @test_pack_unpack(i32* %16, i32 5, i32 9)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15, %11, %0
store i32 0, i32* %1
br label %21
20: ; preds = %15
store i32 1, i32* %1
br label %21
21: ; preds = %20, %19
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@__const.test_packing_unpacking.a = [3 x i32] [i32 1, i32 2, i32 3]
@__const.test_packing_unpacking.b = [4 x i32] [i32 65281, i32 65282, i32 65283, i32 65284]
@__const.test_packing_unpacking.c = [5 x i32] [i32 352, i32 624, i32 896, i32 1168, i32 1440]
define i32 @test_packing_unpacking() {
%1 = alloca [3 x i32]
%2 = alloca [4 x i32]
%3 = alloca [5 x i32]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast [4 x i32]* %2 to i8*
%6 = bitcast [5 x i32]* %3 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%8 = call i32 @test_pack_unpack(i32* %7, i32 3, i32 8)
%9 = icmp eq i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %0
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%12 = call i32 @test_pack_unpack(i32* %11, i32 4, i32 4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%16 = call i32 @test_pack_unpack(i32* %15, i32 5, i32 9)
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %14, %0, %10
%20 = phi i32 [ 0, %10 ], [ 0, %0 ], [ %18, %14 ]
ret i32 %20
}