#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*/ free(double *);
int /*<<< orphan*/ idwt_approx_neo(double *, int, double *, int, double *, int);
int /*<<< orphan*/ idwt_detail_neo(double *, int, double *, int, double *, int);
scalar_t__ malloc(int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ verbatim_copy(double *, int, double *, int);
int /*<<< orphan*/ wkeep_1D_center(double *, int, double *, int);
void upcoef(double *sigIn, int sigInLength, double *lowRe, double *hiRe,
            int filterLen, double *sigOut, int sigOutLength, int defaultLength,
            char *coefType, int step) {
  int count, sigInLengthTemp, leng;
  double *sigInTemp, *sigOutTemp;
  sigInLengthTemp = 2 * sigInLength + filterLen - 2;
  sigInTemp = (double *)malloc(defaultLength * sizeof(double));
  if (strcmp(coefType, "a") == 0) {
    idwt_approx_neo(sigIn, sigInLength, lowRe, filterLen, sigInTemp,
                    sigInLengthTemp);
  } else
    idwt_detail_neo(sigIn, sigInLength, hiRe, filterLen, sigInTemp,
                    sigInLengthTemp);
  if (step > 1) {
    sigOutTemp = (double *)malloc(defaultLength * sizeof(double));
    for (count = 0; count < defaultLength; count++)
      sigOutTemp[count] = 0;
    leng = sigInLengthTemp;
    for (count = 0; count < (step - 1); count++) {
      idwt_approx_neo(sigInTemp, leng, lowRe, filterLen, sigOutTemp,
                      leng * 2 + filterLen - 2);
      leng = leng * 2 + filterLen - 2;
      verbatim_copy(sigOutTemp, leng, sigInTemp, leng);
    }
    sigInLengthTemp = leng;
    free(sigOutTemp);
  }
  wkeep_1D_center(sigInTemp, sigInLengthTemp, sigOut, sigOutLength);
  free(sigInTemp);
  return;
}


x86 assembly (clang, -O0):
<upcoef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
add    -0x24(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x38(%rbp)
movslq 0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    0x20(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <upcoef+0x88>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x48(%rbp),%r8
mov    -0x38(%rbp),%r9d
call   1080 <idwt_approx_neo@plt>
jmp    1213 <upcoef+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x48(%rbp),%r8
mov    -0x38(%rbp),%r9d
call   1090 <idwt_detail_neo@plt>
cmpl   $0x1,0x28(%rbp)
jle    12e5 <upcoef+0x175>
movslq 0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1261 <upcoef+0xf1>
mov    -0x50(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1237 <upcoef+0xc7>
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12d6 <upcoef+0x166>
mov    -0x48(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x50(%rbp),%r8
mov    -0x3c(%rbp),%r9d
shl    $0x1,%r9d
add    -0x24(%rbp),%r9d
sub    $0x2,%r9d
call   1080 <idwt_approx_neo@plt>
mov    -0x3c(%rbp),%eax
shl    $0x1,%eax
add    -0x24(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
call   1070 <verbatim_copy@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126e <upcoef+0xfe>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    0x10(%rbp),%ecx
call   1040 <wkeep_1D_center@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upcoef>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9,0x20(%rsp)
mov    %r8d,%r12d
mov    %rcx,0x18(%rsp)
mov    %rdx,0x38(%rsp)
mov    %rdi,0x10(%rsp)
mov    0x98(%rsp),%r15d
mov    0x88(%rsp),%ecx
mov    0x80(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    0x90(%rsp),%r14
mov    %rsi,%r13
lea    -0x2(%r12,%rsi,2),%ebp
mov    %rcx,0x40(%rsp)
lea    0x0(,%rcx,8),%edi
mov    %edi,0x2c(%rsp)
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe12(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
mov    %r12,0x30(%rsp)
je     121d <upcoef+0x9d>
mov    0x10(%rsp),%rdi
mov    %r13d,%esi
mov    0x18(%rsp),%rdx
mov    %r12d,%ecx
mov    %rbx,%r8
mov    %ebp,%r9d
call   10a0 <idwt_detail_neo@plt>
jmp    1238 <upcoef+0xb8>
mov    0x10(%rsp),%rdi
mov    %r13d,%esi
mov    0x38(%rsp),%rdx
mov    %r12d,%ecx
mov    %rbx,%r8
mov    %ebp,%r9d
call   1090 <idwt_approx_neo@plt>
mov    0x20(%rsp),%rdx
cmp    $0x2,%r15d
jl     12de <upcoef+0x15e>
mov    %rbx,0x18(%rsp)
mov    0x30(%rsp),%rax
add    $0xfffffffe,%eax
mov    %rax,0x10(%rsp)
mov    0x2c(%rsp),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    0x40(%rsp),%rax
test   %eax,%eax
jle    127e <upcoef+0xfe>
mov    %eax,%edx
shl    $0x3,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
add    $0xffffffff,%r15d
mov    0x30(%rsp),%r13
mov    0x10(%rsp),%r12
mov    0x18(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%esi
lea    (%r12,%rsi,2),%ebp
mov    %rbx,%rdi
mov    0x38(%rsp),%rdx
mov    %r13d,%ecx
mov    %r14,%r8
mov    %ebp,%r9d
call   1090 <idwt_approx_neo@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1080 <verbatim_copy@plt>
add    $0xffffffff,%r15d
jne    12a0 <upcoef+0x120>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdx
mov    0xc(%rsp),%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <wkeep_1D_center@plt>
mov    %rbx,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
define void @upcoef(double* %0, i32 %1, double* %2, double* %3, i32 %4, double* %5, i32 %6, i32 %7, i8* %8, i32 %9) {
%11 = alloca double*
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double*
%25 = alloca double*
store double* %0, double** %11
store i32 %1, i32* %12
store double* %2, double** %13
store double* %3, double** %14
store i32 %4, i32* %15
store double* %5, double** %16
store i32 %6, i32* %17
store i32 %7, i32* %18
store i8* %8, i8** %19
store i32 %9, i32* %20
%26 = load i32, i32* %12
%27 = mul nsw i32 2, %26
%28 = load i32, i32* %15
%29 = add nsw i32 %27, %28
%30 = sub nsw i32 %29, 2
store i32 %30, i32* %22
%31 = load i32, i32* %18
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 8
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to double*
store double* %36, double** %24
%37 = load i8*, i8** %19
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %10
%41 = load double*, double** %11
%42 = load i32, i32* %12
%43 = load double*, double** %13
%44 = load i32, i32* %15
%45 = load double*, double** %24
%46 = load i32, i32* %22
%47 = call i32 @idwt_approx_neo(double* %41, i32 %42, double* %43, i32 %44, double* %45, i32 %46)
br label %56
48: ; preds = %10
%49 = load double*, double** %11
%50 = load i32, i32* %12
%51 = load double*, double** %14
%52 = load i32, i32* %15
%53 = load double*, double** %24
%54 = load i32, i32* %22
%55 = call i32 @idwt_detail_neo(double* %49, i32 %50, double* %51, i32 %52, double* %53, i32 %54)
br label %56
56: ; preds = %48, %40
%57 = load i32, i32* %20
%58 = icmp sgt i32 %57, 1
br i1 %58, label %59, label %114
59: ; preds = %56
%60 = load i32, i32* %18
%61 = sext i32 %60 to i64
%62 = mul i64 %61, 8
%63 = trunc i64 %62 to i32
%64 = call i64 @malloc(i32 %63)
%65 = inttoptr i64 %64 to double*
store double* %65, double** %25
store i32 0, i32* %21
br label %66
66: ; preds = %75, %59
%67 = load i32, i32* %21
%68 = load i32, i32* %18
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %78
70: ; preds = %66
%71 = load double*, double** %25
%72 = load i32, i32* %21
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
store double 0.000000e+00, double* %74
br label %75
75: ; preds = %70
%76 = load i32, i32* %21
%77 = add nsw i32 %76, 1
store i32 %77, i32* %21
br label %66
78: ; preds = %66
%79 = load i32, i32* %22
store i32 %79, i32* %23
store i32 0, i32* %21
br label %80
80: ; preds = %107, %78
%81 = load i32, i32* %21
%82 = load i32, i32* %20
%83 = sub nsw i32 %82, 1
%84 = icmp slt i32 %81, %83
br i1 %84, label %85, label %110
85: ; preds = %80
%86 = load double*, double** %24
%87 = load i32, i32* %23
%88 = load double*, double** %13
%89 = load i32, i32* %15
%90 = load double*, double** %25
%91 = load i32, i32* %23
%92 = mul nsw i32 %91, 2
%93 = load i32, i32* %15
%94 = add nsw i32 %92, %93
%95 = sub nsw i32 %94, 2
%96 = call i32 @idwt_approx_neo(double* %86, i32 %87, double* %88, i32 %89, double* %90, i32 %95)
%97 = load i32, i32* %23
%98 = mul nsw i32 %97, 2
%99 = load i32, i32* %15
%100 = add nsw i32 %98, %99
%101 = sub nsw i32 %100, 2
store i32 %101, i32* %23
%102 = load double*, double** %25
%103 = load i32, i32* %23
%104 = load double*, double** %24
%105 = load i32, i32* %23
%106 = call i32 @verbatim_copy(double* %102, i32 %103, double* %104, i32 %105)
br label %107
107: ; preds = %85
%108 = load i32, i32* %21
%109 = add nsw i32 %108, 1
store i32 %109, i32* %21
br label %80
110: ; preds = %80
%111 = load i32, i32* %23
store i32 %111, i32* %22
%112 = load double*, double** %25
%113 = call i32 @free(double* %112)
br label %114
114: ; preds = %110, %56
%115 = load double*, double** %24
%116 = load i32, i32* %22
%117 = load double*, double** %16
%118 = load i32, i32* %17
%119 = call i32 @wkeep_1D_center(double* %115, i32 %116, double* %117, i32 %118)
%120 = load double*, double** %24
%121 = call i32 @free(double* %120)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
define void @upcoef(double* %0, i32 %1, double* %2, double* %3, i32 %4, double* %5, i32 %6, i32 %7, i8* %8, i32 %9) {
%11 = shl nsw i32 %1, 1
%12 = add i32 %4, -2
%13 = add i32 %12, %11
%14 = shl i32 %7, 3
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
%17 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %10
%20 = tail call i32 @idwt_approx_neo(double* %0, i32 %1, double* %2, i32 %4, double* %16, i32 %13)
br label %23
21: ; preds = %10
%22 = tail call i32 @idwt_detail_neo(double* %0, i32 %1, double* %3, i32 %4, double* %16, i32 %13)
br label %23
23: ; preds = %21, %19
%24 = icmp sgt i32 %9, 1
br i1 %24, label %25, label %46
25: ; preds = %23
%26 = tail call i64 @malloc(i32 %14)
%27 = inttoptr i64 %26 to double*
%28 = icmp sgt i32 %7, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = inttoptr i64 %26 to i8*
%31 = zext i32 %7 to i64
%32 = shl nuw nsw i64 %31, 3
br label %33
33: ; preds = %25, %29
%34 = add nsw i32 %9, -1
br label %35
35: ; preds = %33, %35
%36 = phi i32 [ 0, %33 ], [ %42, %35 ]
%37 = phi i32 [ %13, %33 ], [ %39, %35 ]
%38 = shl nsw i32 %37, 1
%39 = add i32 %12, %38
%40 = tail call i32 @idwt_approx_neo(double* %16, i32 %37, double* %2, i32 %4, double* %27, i32 %39)
%41 = tail call i32 @verbatim_copy(double* %27, i32 %39, double* %16, i32 %39)
%42 = add nuw nsw i32 %36, 1
%43 = icmp eq i32 %42, %34
br i1 %43, label %44, label %35
44: ; preds = %35
%45 = tail call i32 @free(double* %27)
br label %46
46: ; preds = %44, %23
%47 = phi i32 [ %39, %44 ], [ %13, %23 ]
%48 = tail call i32 @wkeep_1D_center(double* %16, i32 %47, double* %5, i32 %6)
%49 = tail call i32 @free(double* %16)
ret void
}