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

/* Variables and functions */
void *store_big_endian_signed_samples(void *, int /*<<< orphan*/ *, int, int);
void *store_big_endian_unsigned_samples(void *, int /*<<< orphan*/ *, int, int);
void *store_little_endian_signed_samples(void *, int /*<<< orphan*/ *, int,
                                         int);
void *store_little_endian_unsigned_samples(void *, int /*<<< orphan*/ *, int,
                                           int);
void *store_samples(void *dst, int32_t *src, int qmode, int bps, int count) {
  if (qmode & 0x1) {
    if ((qmode & 0x4) || (bps == 1 && !(qmode & 0x2)))
      return store_big_endian_unsigned_samples(dst, src, bps, count);
    else
      return store_big_endian_signed_samples(dst, src, bps, count);
  } else if ((qmode & 0x4) || (bps == 1 && !(qmode & (0x2 | (0x10 | 0x20)))))
    return store_little_endian_unsigned_samples(dst, src, bps, count);
  else
    return store_little_endian_signed_samples(dst, src, bps, count);
}


x86 assembly (clang, -O0):
<store_samples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11c9 <store_samples+0x89>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    1191 <store_samples+0x51>
cmpl   $0x1,-0x20(%rbp)
jne    11ad <store_samples+0x6d>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    11ad <store_samples+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1060 <store_big_endian_unsigned_samples@plt>
mov    %rax,-0x8(%rbp)
jmp    1224 <store_samples+0xe4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1030 <store_big_endian_signed_samples@plt>
mov    %rax,-0x8(%rbp)
jmp    1224 <store_samples+0xe4>
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
jne    11f1 <store_samples+0xb1>
cmpl   $0x1,-0x20(%rbp)
jne    120d <store_samples+0xcd>
mov    -0x1c(%rbp),%eax
and    $0x32,%eax
cmp    $0x0,%eax
jne    120d <store_samples+0xcd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1040 <store_little_endian_unsigned_samples@plt>
mov    %rax,-0x8(%rbp)
jmp    1224 <store_samples+0xe4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1050 <store_little_endian_signed_samples@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_samples>:
test   $0x1,%dl
jne    115e <store_samples+0x1e>
test   $0x4,%dl
jne    1154 <store_samples+0x14>
cmp    $0x1,%ecx
jne    1177 <store_samples+0x37>
and    $0x32,%edx
jne    1177 <store_samples+0x37>
mov    %ecx,%edx
mov    %r8d,%ecx
jmp    1040 <store_little_endian_unsigned_samples@plt>
test   $0x4,%dl
jne    116d <store_samples+0x2d>
cmp    $0x1,%ecx
jne    1181 <store_samples+0x41>
and    $0x2,%edx
jne    1181 <store_samples+0x41>
mov    %ecx,%edx
mov    %r8d,%ecx
jmp    1060 <store_big_endian_unsigned_samples@plt>
mov    %ecx,%edx
mov    %r8d,%ecx
jmp    1050 <store_little_endian_signed_samples@plt>
mov    %ecx,%edx
mov    %r8d,%ecx
jmp    1030 <store_big_endian_signed_samples@plt>

LLVM IR (-O0):
define i8* @store_samples(i8* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%12 = load i32, i32* %9
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %38
15: ; preds = %5
%16 = load i32, i32* %9
%17 = and i32 %16, 4
%18 = icmp ne i32 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %15
%20 = load i32, i32* %10
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i32, i32* %9
%24 = and i32 %23, 2
%25 = icmp ne i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %22, %15
%27 = load i8*, i8** %7
%28 = load i32*, i32** %8
%29 = load i32, i32* %10
%30 = load i32, i32* %11
%31 = call i8* @store_big_endian_unsigned_samples(i8* %27, i32* %28, i32 %29, i32 %30)
store i8* %31, i8** %6
br label %61
32: ; preds = %22, %19
%33 = load i8*, i8** %7
%34 = load i32*, i32** %8
%35 = load i32, i32* %10
%36 = load i32, i32* %11
%37 = call i8* @store_big_endian_signed_samples(i8* %33, i32* %34, i32 %35, i32 %36)
store i8* %37, i8** %6
br label %61
38: ; preds = %5
%39 = load i32, i32* %9
%40 = and i32 %39, 4
%41 = icmp ne i32 %40, 0
br i1 %41, label %49, label %42
42: ; preds = %38
%43 = load i32, i32* %10
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %55
45: ; preds = %42
%46 = load i32, i32* %9
%47 = and i32 %46, 50
%48 = icmp ne i32 %47, 0
br i1 %48, label %55, label %49
49: ; preds = %45, %38
%50 = load i8*, i8** %7
%51 = load i32*, i32** %8
%52 = load i32, i32* %10
%53 = load i32, i32* %11
%54 = call i8* @store_little_endian_unsigned_samples(i8* %50, i32* %51, i32 %52, i32 %53)
store i8* %54, i8** %6
br label %61
55: ; preds = %45, %42
%56 = load i8*, i8** %7
%57 = load i32*, i32** %8
%58 = load i32, i32* %10
%59 = load i32, i32* %11
%60 = call i8* @store_little_endian_signed_samples(i8* %56, i32* %57, i32 %58, i32 %59)
store i8* %60, i8** %6
br label %61
61: ; preds = %55, %49, %32, %26
%62 = load i8*, i8** %6
ret i8* %62
}

LLVM IR (-O2):
define i8* @store_samples(i8* %0, i32* %1, i32 %2, i32 %3, i32 %4) {
%6 = and i32 %2, 1
%7 = icmp eq i32 %6, 0
%8 = and i32 %2, 4
%9 = icmp eq i32 %8, 0
br i1 %7, label %20, label %10
10: ; preds = %5
br i1 %9, label %11, label %16
11: ; preds = %10
%12 = icmp eq i32 %3, 1
%13 = and i32 %2, 2
%14 = icmp eq i32 %13, 0
%15 = and i1 %12, %14
br i1 %15, label %16, label %18
16: ; preds = %11, %10
%17 = tail call i8* @store_big_endian_unsigned_samples(i8* %0, i32* %1, i32 %3, i32 %4)
br label %30
18: ; preds = %11
%19 = tail call i8* @store_big_endian_signed_samples(i8* %0, i32* %1, i32 %3, i32 %4)
br label %30
20: ; preds = %5
br i1 %9, label %21, label %26
21: ; preds = %20
%22 = icmp eq i32 %3, 1
%23 = and i32 %2, 50
%24 = icmp eq i32 %23, 0
%25 = and i1 %22, %24
br i1 %25, label %26, label %28
26: ; preds = %21, %20
%27 = tail call i8* @store_little_endian_unsigned_samples(i8* %0, i32* %1, i32 %3, i32 %4)
br label %30
28: ; preds = %21
%29 = tail call i8* @store_little_endian_signed_samples(i8* %0, i32* %1, i32 %3, i32 %4)
br label %30
30: ; preds = %28, %26, %18, %16
%31 = phi i8* [ %17, %16 ], [ %19, %18 ], [ %27, %26 ], [ %29, %28 ]
ret i8* %31
}