#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*/ acorr(double *, int const, double *, int const);
double *dgetmem(int const);
int /*<<< orphan*/ free(double *);
int levdur(double *, double *, int const, double const);
int lpc(double *x, const int flng, double *a, const int m, const double f) {
  int flag;
  static double *r = NULL;
  static int size;
  if (r == NULL) {
    r = dgetmem(m + 1);
    size = m;
  }
  if (m > size) {
    free(r);
    r = dgetmem(m + 1);
    size = m;
  }
  acorr(x, flng, r, m);
  flag = levdur(r, a, m, f);
  return (flag);
}


x86 assembly (clang, -O0):
<lpc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,0x2ee5(%rip)
jne    1184 <lpc+0x44>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   1050 <dgetmem@plt>
mov    %rax,0x2ecd(%rip)
mov    -0x1c(%rbp),%eax
mov    %eax,0x2ecc(%rip)
mov    -0x1c(%rbp),%eax
cmp    0x2ec3(%rip),%eax
jle    11ba <lpc+0x7a>
mov    0x2eae(%rip),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   1050 <dgetmem@plt>
mov    %rax,0x2e97(%rip)
mov    -0x1c(%rbp),%eax
mov    %eax,0x2e96(%rip)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e80(%rip),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <acorr@plt>
mov    0x2e71(%rip),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
call   1060 <levdur@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lpc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbp
mov    0x2eea(%rip),%rdx
test   %rdx,%rdx
je     1173 <lpc+0x33>
cmp    %ebx,0x2ee7(%rip)
jge    118b <lpc+0x4b>
mov    %rdx,%rdi
call   1030 <free@plt>
lea    0x1(%rbx),%edi
call   1050 <dgetmem@plt>
mov    %rax,%rdx
mov    %rax,0x2ec3(%rip)
mov    %ebx,0x2ec5(%rip)
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %ebx,%ecx
call   1040 <acorr@plt>
mov    0x2ea9(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <levdur@plt>

LLVM IR (-O0):
@lpc.r = internal global double* null
@lpc.size = internal global i32 0
define i32 @lpc(double* %0, i32 %1, double* %2, i32 %3, double %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store double %4, double* %10
%12 = load double*, double** @lpc.r
%13 = icmp eq double* %12, null
br i1 %13, label %14, label %19
14: ; preds = %5
%15 = load i32, i32* %9
%16 = add nsw i32 %15, 1
%17 = call double* @dgetmem(i32 %16)
store double* %17, double** @lpc.r
%18 = load i32, i32* %9
store i32 %18, i32* @lpc.size
br label %19
19: ; preds = %14, %5
%20 = load i32, i32* %9
%21 = load i32, i32* @lpc.size
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load double*, double** @lpc.r
%25 = call i32 @free(double* %24)
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
%28 = call double* @dgetmem(i32 %27)
store double* %28, double** @lpc.r
%29 = load i32, i32* %9
store i32 %29, i32* @lpc.size
br label %30
30: ; preds = %23, %19
%31 = load double*, double** %6
%32 = load i32, i32* %7
%33 = load double*, double** @lpc.r
%34 = load i32, i32* %9
%35 = call i32 @acorr(double* %31, i32 %32, double* %33, i32 %34)
%36 = load double*, double** @lpc.r
%37 = load double*, double** %8
%38 = load i32, i32* %9
%39 = load double, double* %10
%40 = call i32 @levdur(double* %36, double* %37, i32 %38, double %39)
store i32 %40, i32* %11
%41 = load i32, i32* %11
ret i32 %41
}

LLVM IR (-O2):
@lpc.r = internal unnamed_addr global double* null
@lpc.size = internal unnamed_addr global i32 0
define i32 @lpc(double* %0, i32 %1, double* %2, i32 %3, double %4) {
%6 = load double*, double** @lpc.r
%7 = icmp eq double* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = load i32, i32* @lpc.size
%10 = icmp slt i32 %9, %3
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = tail call i32 @free(double* %6)
br label %13
13: ; preds = %5, %11
%14 = add nsw i32 %3, 1
%15 = tail call double* @dgetmem(i32 %14)
store double* %15, double** @lpc.r
store i32 %3, i32* @lpc.size
br label %16
16: ; preds = %13, %8
%17 = phi double* [ %6, %8 ], [ %15, %13 ]
%18 = tail call i32 @acorr(double* %0, i32 %1, double* %17, i32 %3)
%19 = load double*, double** @lpc.r
%20 = tail call i32 @levdur(double* %19, double* %2, i32 %3, double %4)
ret i32 %20
}