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

/* Variables and functions */
void *adpcm_predict_sample(int, int, int, unsigned int);
void adpcm_predict_frame(int16_t *dst, const uint8_t *src,
                         const uint8_t *nibbles, unsigned int rshift) {
  unsigned int i;
  *(dst++) = (src[0] << 8) | src[1];
  *(dst++) = (src[2] << 8) | src[3];
  for (i = 1; i < 16; ++i) {
    uint8_t byte = nibbles[i];
    *(dst++) = adpcm_predict_sample(byte, 0xf0, 8, rshift);
    *(dst++) = adpcm_predict_sample(byte, 0x0f, 12, rshift);
  }
}


x86 assembly (clang, -O0):
<adpcm_predict_frame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
or     0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
or     0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
movl   $0x1,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jae    11e6 <adpcm_predict_frame+0xd6>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x1c(%rbp),%ecx
mov    $0xf0,%esi
mov    $0x8,%edx
call   1030 <adpcm_predict_sample@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x1c(%rbp),%ecx
mov    $0xf,%esi
mov    $0xc,%edx
call   1030 <adpcm_predict_sample@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1171 <adpcm_predict_frame+0x61>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adpcm_predict_frame>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%eax
shl    $0x8,%eax
or     0x4(%rsi),%eax
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rdi,%r12
mov    %eax,(%rdi)
mov    0x8(%rsi),%eax
shl    $0x8,%eax
or     0xc(%rsi),%eax
mov    %eax,0x4(%rdi)
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x4(%r14,%rbx,4),%ebp
mov    %ebp,%edi
mov    $0xf0,%esi
mov    $0x8,%edx
mov    %r15d,%ecx
call   1030 <adpcm_predict_sample@plt>
mov    %eax,0x8(%r12,%rbx,8)
mov    %ebp,%edi
mov    $0xf,%esi
mov    $0xc,%edx
mov    %r15d,%ecx
call   1030 <adpcm_predict_sample@plt>
mov    %eax,0xc(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0xf,%rbx
jne    1140 <adpcm_predict_frame+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @adpcm_predict_frame(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%11 = load i32*, i32** %6
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = shl i32 %13, 8
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = load i32, i32* %16
%18 = or i32 %14, %17
%19 = load i32*, i32** %5
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %5
store i32 %18, i32* %19
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i64 2
%23 = load i32, i32* %22
%24 = shl i32 %23, 8
%25 = load i32*, i32** %6
%26 = getelementptr inbounds i32, i32* %25, i64 3
%27 = load i32, i32* %26
%28 = or i32 %24, %27
%29 = load i32*, i32** %5
%30 = getelementptr inbounds i32, i32* %29, i32 1
store i32* %30, i32** %5
store i32 %28, i32* %29
store i32 1, i32* %9
br label %31
31: ; preds = %52, %4
%32 = load i32, i32* %9
%33 = icmp ult i32 %32, 16
br i1 %33, label %34, label %55
34: ; preds = %31
%35 = load i32*, i32** %7
%36 = load i32, i32* %9
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
store i32 %39, i32* %10
%40 = load i32, i32* %10
%41 = load i32, i32* %8
%42 = call i8* @adpcm_predict_sample(i32 %40, i32 240, i32 8, i32 %41)
%43 = ptrtoint i8* %42 to i32
%44 = load i32*, i32** %5
%45 = getelementptr inbounds i32, i32* %44, i32 1
store i32* %45, i32** %5
store i32 %43, i32* %44
%46 = load i32, i32* %10
%47 = load i32, i32* %8
%48 = call i8* @adpcm_predict_sample(i32 %46, i32 15, i32 12, i32 %47)
%49 = ptrtoint i8* %48 to i32
%50 = load i32*, i32** %5
%51 = getelementptr inbounds i32, i32* %50, i32 1
store i32* %51, i32** %5
store i32 %49, i32* %50
br label %52
52: ; preds = %34
%53 = load i32, i32* %9
%54 = add i32 %53, 1
store i32 %54, i32* %9
br label %31
55: ; preds = %31
ret void
}

LLVM IR (-O2):
define void @adpcm_predict_frame(i32* nocapture writeonly %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = load i32, i32* %1
%6 = shl i32 %5, 8
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = load i32, i32* %7
%9 = or i32 %6, %8
%10 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %9, i32* %0
%11 = getelementptr inbounds i32, i32* %1, i64 2
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = getelementptr inbounds i32, i32* %1, i64 3
%15 = load i32, i32* %14
%16 = or i32 %13, %15
store i32 %16, i32* %10
br label %17
17: ; preds = %4, %17
%18 = phi i64 [ 1, %4 ], [ %30, %17 ]
%19 = phi i32* [ %0, %4 ], [ %20, %17 ]
%20 = getelementptr inbounds i32, i32* %19, i64 2
%21 = getelementptr inbounds i32, i32* %2, i64 %18
%22 = load i32, i32* %21
%23 = tail call i8* @adpcm_predict_sample(i32 %22, i32 240, i32 8, i32 %3)
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds i32, i32* %19, i64 3
store i32 %25, i32* %20
%27 = tail call i8* @adpcm_predict_sample(i32 %22, i32 15, i32 12, i32 %3)
%28 = ptrtoint i8* %27 to i64
%29 = trunc i64 %28 to i32
store i32 %29, i32* %26
%30 = add nuw nsw i64 %18, 1
%31 = icmp eq i64 %30, 16
br i1 %31, label %32, label %17
32: ; preds = %17
ret void
}