#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_4_3(short *out, int *S, const short *in,
                           const int inLen) {
  int outLen, LSubFrameIn, LSubFrameOut;
  short outH[3 * 80];
  short outHH[6 * 80];
  int scratch[9 * 80 / 2];
  ;
  outLen = ((int)((((inLen) << (2))) / (3)));
  while (outLen > 0) {
    LSubFrameOut = SKP_min_int(80, outLen);
    LSubFrameIn =
        ((((49152) >> 16) * (int)((short)(LSubFrameOut))) +
         ((((49152) & 0x0000FFFF) * (int)((short)(LSubFrameOut))) >> 16));
    SKP_Silk_resample_2_1_coarse(in, &S[0], outH, scratch, LSubFrameIn);
    SKP_Silk_resample_2_1_coarse(outH, &S[4], outHH, scratch,
                                 ((LSubFrameIn) << (1)));
    SKP_Silk_resample_1_3(out, &S[8], outHH, ((LSubFrameIn) << (2)));
    in += LSubFrameIn;
    out += LSubFrameOut;
    outLen -= LSubFrameOut;
  }
}


x86 assembly (clang, -O0):
<SKP_Silk_resample_4_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1231 <SKP_Silk_resample_4_3+0x101>
mov    -0x20(%rbp),%esi
mov    $0x50,%edi
call   1030 <SKP_min_int@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cwtl
imul   $0x0,%eax,%eax
mov    -0x28(%rbp),%ecx
movswl %cx,%ecx
imul   $0xc000,%ecx,%ecx
sar    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x210(%rbp),%rdx
lea    -0xb70(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1050 <SKP_Silk_resample_2_1_coarse@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
lea    -0x5d0(%rbp),%rdx
lea    -0xb70(%rbp),%rcx
mov    -0x24(%rbp),%r8d
shl    $0x1,%r8d
call   1050 <SKP_Silk_resample_2_1_coarse@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x20,%rsi
lea    -0x5d0(%rbp),%rdx
mov    -0x24(%rbp),%ecx
shl    $0x2,%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_4_3+0x2b>
add    $0xb70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SKP_Silk_resample_4_3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb68,%rsp
mov    %rsi,0x8(%rsp)
shl    $0x2,%ecx
cmp    $0x3,%ecx
jl     1211 <SKP_Silk_resample_4_3+0xe1>
mov    %rdx,%r15
mov    %rdi,%r12
mov    %ecx,%eax
mov    $0xaaaaaaab,%ebx
imul   %rax,%rbx
shr    $0x21,%rbx
mov    0x8(%rsp),%rax
lea    0x10(%rax),%rcx
mov    %rcx,0x18(%rsp)
add    $0x20,%rax
mov    %rax,0x10(%rsp)
xchg   %ax,%ax
mov    $0x50,%edi
mov    %ebx,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,%r14d
movswl %r14w,%eax
shl    $0xe,%eax
lea    (%rax,%rax,2),%r13d
sar    $0x10,%r13d
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdx
lea    0x200(%rsp),%rcx
mov    %r13d,%r8d
call   1050 <SKP_Silk_resample_2_1_coarse@plt>
lea    0x0(%r13,%r13,1),%r8d
mov    %rbp,%rdi
mov    0x18(%rsp),%rsi
lea    0x7a0(%rsp),%rbp
mov    %rbp,%rdx
lea    0x200(%rsp),%rcx
call   1050 <SKP_Silk_resample_2_1_coarse@plt>
lea    0x0(,%r13,4),%ecx
mov    %r12,%rdi
mov    0x10(%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_4_3+0x50>
add    $0xb68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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