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

/* Variables and functions */
int /*<<< orphan*/ SKP_Silk_resample_1_3(short *, int *, short *, int);
int /*<<< orphan*/ SKP_Silk_resample_2_1_coarse(short const *, int *, short *,
                                                int *, int);
int SKP_min_int(int, int);
void SKP_Silk_resample_2_3(short *out, int *S, const short *in,
                           const int inLen) {
  int outLen, LSubFrameIn, LSubFrameOut;
  short outH[3 * 80];
  int scratch[(9 * 80) / 2];
  ;
  outLen = ((int)((((inLen) << (1))) / (3)));
  while (outLen > 0) {
    LSubFrameOut = SKP_min_int(80, outLen);
    LSubFrameIn =
        ((((98304) >> 16) * (int)((short)(LSubFrameOut))) +
         ((((98304) & 0x0000FFFF) * (int)((short)(LSubFrameOut))) >> 16));
    SKP_Silk_resample_2_1_coarse(in, &S[0], outH, scratch, LSubFrameIn);
    SKP_Silk_resample_1_3(out, &S[4], outH, ((LSubFrameIn) << (1)));
    in += LSubFrameIn;
    out += LSubFrameOut;
    outLen -= LSubFrameOut;
  }
}


x86 assembly (clang, -O0):
<SKP_Silk_resample_2_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1204 <SKP_Silk_resample_2_3+0xd4>
mov    -0x20(%rbp),%esi
mov    $0x50,%edi
call   1030 <SKP_min_int@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cwtl
shl    $0x0,%eax
mov    -0x28(%rbp),%ecx
movswl %cx,%ecx
shl    $0xf,%ecx
sar    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0x7b0(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1050 <SKP_Silk_resample_2_1_coarse@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
lea    -0x210(%rbp),%rdx
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
call   1040 <SKP_Silk_resample_1_3@plt>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
shl    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <SKP_Silk_resample_2_3+0x2b>
add    $0x7b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SKP_Silk_resample_2_3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x798,%rsp
mov    %rsi,(%rsp)
add    %ecx,%ecx
cmp    $0x3,%ecx
jl     11dd <SKP_Silk_resample_2_3+0xad>
mov    %rdx,%r15
mov    %rdi,%r12
mov    %ecx,%eax
mov    $0xaaaaaaab,%ebx
imul   %rax,%rbx
shr    $0x21,%rbx
mov    (%rsp),%rax
add    $0x10,%rax
mov    %rax,0x8(%rsp)
lea    0x10(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    $0x50,%edi
mov    %ebx,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,%r14d
movswl %r14w,%eax
mov    %eax,%r13d
sar    %r13d
add    %eax,%r13d
mov    %r15,%rdi
mov    (%rsp),%rsi
mov    %rbp,%rdx
lea    0x1f0(%rsp),%rcx
mov    %r13d,%r8d
call   1050 <SKP_Silk_resample_2_1_coarse@plt>
lea    0x0(%r13,%r13,1),%ecx
mov    %r12,%rdi
mov    0x8(%rsp),%rsi
mov    %rbp,%rdx
call   1040 <SKP_Silk_resample_1_3@plt>
movslq %r13d,%rax
lea    (%r15,%rax,2),%r15
movslq %r14d,%rax
lea    (%r12,%rax,2),%r12
sub    %eax,%ebx
jg     1180 <SKP_Silk_resample_2_3+0x50>
add    $0x798,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @SKP_Silk_resample_2_3(i16* %0, i32* %1, i16* %2, i32 %3) {
%5 = alloca i16*
%6 = alloca i32*
%7 = alloca i16*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [240 x i16]
%13 = alloca [360 x i32]
store i16* %0, i16** %5
store i32* %1, i32** %6
store i16* %2, i16** %7
store i32 %3, i32* %8
%14 = load i32, i32* %8
%15 = shl i32 %14, 1
%16 = sdiv i32 %15, 3
store i32 %16, i32* %9
br label %17
17: ; preds = %20, %4
%18 = load i32, i32* %9
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %58
20: ; preds = %17
%21 = load i32, i32* %9
%22 = call i32 @SKP_min_int(i32 80, i32 %21)
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = trunc i32 %23 to i16
%25 = sext i16 %24 to i32
%26 = mul nsw i32 1, %25
%27 = load i32, i32* %11
%28 = trunc i32 %27 to i16
%29 = sext i16 %28 to i32
%30 = mul nsw i32 32768, %29
%31 = ashr i32 %30, 16
%32 = add nsw i32 %26, %31
store i32 %32, i32* %10
%33 = load i16*, i16** %7
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 0
%36 = getelementptr inbounds [240 x i16], [240 x i16]* %12, i64 0, i64 0
%37 = getelementptr inbounds [360 x i32], [360 x i32]* %13, i64 0, i64 0
%38 = load i32, i32* %10
%39 = call i32 @SKP_Silk_resample_2_1_coarse(i16* %33, i32* %35, i16* %36, i32* %37, i32 %38)
%40 = load i16*, i16** %5
%41 = load i32*, i32** %6
%42 = getelementptr inbounds i32, i32* %41, i64 4
%43 = getelementptr inbounds [240 x i16], [240 x i16]* %12, i64 0, i64 0
%44 = load i32, i32* %10
%45 = shl i32 %44, 1
%46 = call i32 @SKP_Silk_resample_1_3(i16* %40, i32* %42, i16* %43, i32 %45)
%47 = load i32, i32* %10
%48 = load i16*, i16** %7
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds i16, i16* %48, i64 %49
store i16* %50, i16** %7
%51 = load i32, i32* %11
%52 = load i16*, i16** %5
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds i16, i16* %52, i64 %53
store i16* %54, i16** %5
%55 = load i32, i32* %11
%56 = load i32, i32* %9
%57 = sub nsw i32 %56, %55
store i32 %57, i32* %9
br label %17
58: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @SKP_Silk_resample_2_3(i16* %0, i32* %1, i16* %2, i32 %3) {
%5 = alloca [240 x i16]
%6 = alloca [360 x i32]
%7 = bitcast [240 x i16]* %5 to i8*
%8 = bitcast [360 x i32]* %6 to i8*
%9 = shl i32 %3, 1
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %34
11: ; preds = %4
%12 = udiv i32 %9, 3
%13 = getelementptr inbounds [240 x i16], [240 x i16]* %5, i64 0, i64 0
%14 = getelementptr inbounds [360 x i32], [360 x i32]* %6, i64 0, i64 0
%15 = getelementptr inbounds i32, i32* %1, i64 4
br label %16
16: ; preds = %11, %16
%17 = phi i16* [ %0, %11 ], [ %31, %16 ]
%18 = phi i16* [ %2, %11 ], [ %29, %16 ]
%19 = phi i32 [ %12, %11 ], [ %32, %16 ]
%20 = call i32 @SKP_min_int(i32 80, i32 %19)
%21 = shl i32 %20, 16
%22 = ashr exact i32 %21, 16
%23 = ashr i32 %21, 17
%24 = add nsw i32 %22, %23
%25 = call i32 @SKP_Silk_resample_2_1_coarse(i16* %18, i32* %1, i16* %13, i32* %14, i32 %24)
%26 = shl nsw i32 %24, 1
%27 = call i32 @SKP_Silk_resample_1_3(i16* %17, i32* %15, i16* %13, i32 %26)
%28 = sext i32 %24 to i64
%29 = getelementptr inbounds i16, i16* %18, i64 %28
%30 = sext i32 %20 to i64
%31 = getelementptr inbounds i16, i16* %17, i64 %30
%32 = sub nsw i32 %19, %20
%33 = icmp sgt i32 %32, 0
br i1 %33, label %16, label %34
34: ; preds = %16, %4
ret void
}