#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 SKP_max_int(int const, int);
scalar_t__ SKP_min_int(int, int);
void SKP_Silk_NLSF_VQ_weights_laroia(int *pNLSFW_Q6, const int *pNLSF_Q15,
                                     const int D) {
  int k;
  int tmp1_int, tmp2_int;
  ;
  ;
  tmp1_int = SKP_max_int(pNLSF_Q15[0], 1);
  tmp1_int = ((int)((1 << (15 + 6)) / (tmp1_int)));
  tmp2_int = SKP_max_int(pNLSF_Q15[1] - pNLSF_Q15[0], 1);
  tmp2_int = ((int)((1 << (15 + 6)) / (tmp2_int)));
  pNLSFW_Q6[0] = (int)SKP_min_int(tmp1_int + tmp2_int, 0x7FFF);
  ;
  for (k = 1; k < D - 1; k += 2) {
    tmp1_int = SKP_max_int(pNLSF_Q15[k + 1] - pNLSF_Q15[k], 1);
    tmp1_int = ((int)((1 << (15 + 6)) / (tmp1_int)));
    pNLSFW_Q6[k] = (int)SKP_min_int(tmp1_int + tmp2_int, 0x7FFF);
    ;
    tmp2_int = SKP_max_int(pNLSF_Q15[k + 2] - pNLSF_Q15[k + 1], 1);
    tmp2_int = ((int)((1 << (15 + 6)) / (tmp2_int)));
    pNLSFW_Q6[k + 1] = (int)SKP_min_int(tmp1_int + tmp2_int, 0x7FFF);
    ;
  }
  tmp1_int = SKP_max_int((1 << 15) - pNLSF_Q15[D - 1], 1);
  tmp1_int = ((int)((1 << (15 + 6)) / (tmp1_int)));
  pNLSFW_Q6[D - 1] = (int)SKP_min_int(tmp1_int + tmp2_int, 0x7FFF);
  ;
}


x86 assembly (clang, -O0):
<SKP_Silk_NLSF_VQ_weights_laroia>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x200000,%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x10(%rbp),%rax
sub    (%rax),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,-0x20(%rbp)
mov    $0x200000,%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1262 <SKP_Silk_NLSF_VQ_weights_laroia+0x142>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
sub    (%rax,%rcx,4),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x200000,%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
sub    (%rax,%rcx,4),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,-0x20(%rbp)
mov    $0x200000,%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    1197 <SKP_Silk_NLSF_VQ_weights_laroia+0x77>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    $0x8000,%edi
sub    (%rax,%rcx,4),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x200000,%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SKP_Silk_NLSF_VQ_weights_laroia>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rsi),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,%ecx
mov    $0x200000,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%r12d
mov    0x4(%r14),%edi
sub    (%r14),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,%ecx
mov    $0x200000,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%ebp
add    %eax,%r12d
mov    %r12d,%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,(%rbx)
lea    -0x1(%r15),%eax
cmp    $0x2,%r15d
jle    1234 <SKP_Silk_NLSF_VQ_weights_laroia+0x114>
mov    %eax,%r15d
mov    %rbx,0x8(%rsp)
mov    $0x1,%ebx
mov    %r15,0x10(%rsp)
mov    0x8(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    0x4(%r14,%rbx,4),%edi
sub    (%r14,%rbx,4),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,%ecx
mov    $0x200000,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%r12d
add    %eax,%ebp
mov    %ebp,%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,0x0(%r13,%rbx,4)
lea    0x2(%rbx),%r15
mov    0x8(%r14,%rbx,4),%edi
sub    0x4(%r14,%rbx,4),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,%ecx
mov    $0x200000,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%ebp
add    %eax,%r12d
mov    %r12d,%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,0x4(%r13,%rbx,4)
mov    %r15,%rbx
cmp    0x10(%rsp),%r15
mov    0x10(%rsp),%r15
jb     11b0 <SKP_Silk_NLSF_VQ_weights_laroia+0x90>
mov    0x8(%rsp),%rbx
jmp    1237 <SKP_Silk_NLSF_VQ_weights_laroia+0x117>
movslq %eax,%r15
mov    $0x8000,%edi
sub    (%r14,%r15,4),%edi
mov    $0x1,%esi
call   1040 <SKP_max_int@plt>
mov    %eax,%ecx
mov    $0x200000,%eax
xor    %edx,%edx
idiv   %ecx
add    %eax,%ebp
mov    %ebp,%edi
mov    $0x7fff,%esi
call   1030 <SKP_min_int@plt>
mov    %eax,(%rbx,%r15,4)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @SKP_Silk_NLSF_VQ_weights_laroia(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = call i32 @SKP_max_int(i32 %12, i32 1)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = sdiv i32 2097152, %14
store i32 %15, i32* %8
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 1
%18 = load i32, i32* %17
%19 = load i32*, i32** %5
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = sub nsw i32 %18, %21
%23 = call i32 @SKP_max_int(i32 %22, i32 1)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = sdiv i32 2097152, %24
store i32 %25, i32* %9
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = add nsw i32 %26, %27
%29 = call i64 @SKP_min_int(i32 %28, i32 32767)
%30 = trunc i64 %29 to i32
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 0
store i32 %30, i32* %32
store i32 1, i32* %7
br label %33
33: ; preds = %89, %3
%34 = load i32, i32* %7
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = icmp slt i32 %34, %36
br i1 %37, label %38, label %92
38: ; preds = %33
%39 = load i32*, i32** %5
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %39, i64 %42
%44 = load i32, i32* %43
%45 = load i32*, i32** %5
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = sub nsw i32 %44, %49
%51 = call i32 @SKP_max_int(i32 %50, i32 1)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = sdiv i32 2097152, %52
store i32 %53, i32* %8
%54 = load i32, i32* %8
%55 = load i32, i32* %9
%56 = add nsw i32 %54, %55
%57 = call i64 @SKP_min_int(i32 %56, i32 32767)
%58 = trunc i64 %57 to i32
%59 = load i32*, i32** %4
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
store i32 %58, i32* %62
%63 = load i32*, i32** %5
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 2
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %63, i64 %66
%68 = load i32, i32* %67
%69 = load i32*, i32** %5
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %69, i64 %72
%74 = load i32, i32* %73
%75 = sub nsw i32 %68, %74
%76 = call i32 @SKP_max_int(i32 %75, i32 1)
store i32 %76, i32* %9
%77 = load i32, i32* %9
%78 = sdiv i32 2097152, %77
store i32 %78, i32* %9
%79 = load i32, i32* %8
%80 = load i32, i32* %9
%81 = add nsw i32 %79, %80
%82 = call i64 @SKP_min_int(i32 %81, i32 32767)
%83 = trunc i64 %82 to i32
%84 = load i32*, i32** %4
%85 = load i32, i32* %7
%86 = add nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %84, i64 %87
store i32 %83, i32* %88
br label %89
89: ; preds = %38
%90 = load i32, i32* %7
%91 = add nsw i32 %90, 2
store i32 %91, i32* %7
br label %33
92: ; preds = %33
%93 = load i32*, i32** %5
%94 = load i32, i32* %6
%95 = sub nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %93, i64 %96
%98 = load i32, i32* %97
%99 = sub nsw i32 32768, %98
%100 = call i32 @SKP_max_int(i32 %99, i32 1)
store i32 %100, i32* %8
%101 = load i32, i32* %8
%102 = sdiv i32 2097152, %101
store i32 %102, i32* %8
%103 = load i32, i32* %8
%104 = load i32, i32* %9
%105 = add nsw i32 %103, %104
%106 = call i64 @SKP_min_int(i32 %105, i32 32767)
%107 = trunc i64 %106 to i32
%108 = load i32*, i32** %4
%109 = load i32, i32* %6
%110 = sub nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i32, i32* %108, i64 %111
store i32 %107, i32* %112
ret void
}

LLVM IR (-O2):
define void @SKP_Silk_NLSF_VQ_weights_laroia(i32* nocapture writeonly %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = tail call i32 @SKP_max_int(i32 %4, i32 1)
%6 = sdiv i32 2097152, %5
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = load i32, i32* %7
%9 = load i32, i32* %1
%10 = sub nsw i32 %8, %9
%11 = tail call i32 @SKP_max_int(i32 %10, i32 1)
%12 = sdiv i32 2097152, %11
%13 = add nsw i32 %12, %6
%14 = tail call i64 @SKP_min_int(i32 %13, i32 32767)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %0
%16 = add nsw i32 %2, -1
%17 = icmp sgt i32 %2, 2
br i1 %17, label %20, label %18
18: ; preds = %3
%19 = sext i32 %16 to i64
br label %49
20: ; preds = %3
%21 = zext i32 %16 to i64
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ 1, %20 ], [ %37, %22 ]
%24 = phi i32 [ %12, %20 ], [ %43, %22 ]
%25 = add nuw nsw i64 %23, 1
%26 = getelementptr inbounds i32, i32* %1, i64 %25
%27 = load i32, i32* %26
%28 = getelementptr inbounds i32, i32* %1, i64 %23
%29 = load i32, i32* %28
%30 = sub nsw i32 %27, %29
%31 = tail call i32 @SKP_max_int(i32 %30, i32 1)
%32 = sdiv i32 2097152, %31
%33 = add nsw i32 %32, %24
%34 = tail call i64 @SKP_min_int(i32 %33, i32 32767)
%35 = trunc i64 %34 to i32
%36 = getelementptr inbounds i32, i32* %0, i64 %23
store i32 %35, i32* %36
%37 = add nuw nsw i64 %23, 2
%38 = getelementptr inbounds i32, i32* %1, i64 %37
%39 = load i32, i32* %38
%40 = load i32, i32* %26
%41 = sub nsw i32 %39, %40
%42 = tail call i32 @SKP_max_int(i32 %41, i32 1)
%43 = sdiv i32 2097152, %42
%44 = add nsw i32 %43, %32
%45 = tail call i64 @SKP_min_int(i32 %44, i32 32767)
%46 = trunc i64 %45 to i32
%47 = getelementptr inbounds i32, i32* %0, i64 %25
store i32 %46, i32* %47
%48 = icmp ult i64 %37, %21
br i1 %48, label %22, label %49
49: ; preds = %22, %18
%50 = phi i64 [ %19, %18 ], [ %21, %22 ]
%51 = phi i32 [ %12, %18 ], [ %43, %22 ]
%52 = getelementptr inbounds i32, i32* %1, i64 %50
%53 = load i32, i32* %52
%54 = sub nsw i32 32768, %53
%55 = tail call i32 @SKP_max_int(i32 %54, i32 1)
%56 = sdiv i32 2097152, %55
%57 = add nsw i32 %56, %51
%58 = tail call i64 @SKP_min_int(i32 %57, i32 32767)
%59 = trunc i64 %58 to i32
%60 = getelementptr inbounds i32, i32* %0, i64 %50
store i32 %59, i32* %60
ret void
}