#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*/ conv(double *, int, double *, int, double *, int);
int /*<<< orphan*/ dyadup_1D_feed_odd(double *, int, double *, int);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ wkeep_1D_index(double *, int, double *, int, int);
void idwt_detail(double *detail, int sigInLength, double *hiRe, int filterLen,
                 double *sigOut, int sigOutLength) {
  int sigInLengthTemp, sigOutLengthTemp, ind;
  double *detailTemp, *detailPre;
  sigInLengthTemp = 2 * sigInLength - 1;
  detailTemp = malloc(sigInLengthTemp * sizeof(double));
  dyadup_1D_feed_odd(detail, sigInLength, detailTemp, sigInLengthTemp);
  sigOutLengthTemp = sigInLengthTemp + filterLen - 1;
  detailPre = malloc(sigOutLengthTemp * sizeof(double));
  conv(detailTemp, sigInLengthTemp, detailPre, sigOutLengthTemp, hiRe,
       filterLen);
  free(detailTemp);
  ind = (int)(2 + (sigOutLengthTemp - sigOutLength) / 2.0);
  wkeep_1D_index(detailPre, sigOutLengthTemp, sigOut, sigOutLength, ind);
  free(detailPre);
  return;
}


x86 assembly (clang, -O0):
<idwt_detail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    -0x30(%rbp),%ecx
call   1060 <dyadup_1D_feed_odd@plt>
mov    -0x30(%rbp),%eax
add    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x48(%rbp),%rdx
mov    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
call   1050 <conv@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
sub    -0x2c(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe0b(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdff(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x38(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x38(%rbp),%r8d
call   1040 <wkeep_1D_index@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idwt_detail>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0x4(%rsp)
mov    %r8,0x10(%rsp)
mov    %ecx,%r12d
mov    %rdx,0x8(%rsp)
mov    %esi,%ebp
mov    %rdi,%r13
lea    0x0(%rbp,%rbp,1),%eax
lea    -0x1(%rbp,%rbp,1),%r14d
lea    -0x8(,%rax,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %r13,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
mov    %r14d,%ecx
call   1060 <dyadup_1D_feed_odd@plt>
lea    (%r12,%rbp,2),%eax
add    $0xffffffff,%eax
lea    (%r12,%rbp,2),%ebp
add    $0xfffffffe,%ebp
lea    -0x8(,%rax,8),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rax,%rdx
mov    %ebp,%ecx
mov    0x8(%rsp),%r8
mov    %r12d,%r9d
call   1050 <conv@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
mov    0x4(%rsp),%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe12(%rip),%xmm0
addsd  0xe12(%rip),%xmm0
cvttsd2si %xmm0,%r8d
mov    %rbx,%rdi
mov    %ebp,%esi
mov    0x10(%rsp),%rdx
call   1040 <wkeep_1D_index@plt>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @idwt_detail(double* %0, i32 %1, double* %2, i32 %3, double* %4, i32 %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca double*
store double* %0, double** %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32 %3, i32* %10
store double* %4, double** %11
store i32 %5, i32* %12
%18 = load i32, i32* %8
%19 = mul nsw i32 2, %18
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %13
%21 = load i32, i32* %13
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 8
%24 = trunc i64 %23 to i32
%25 = call double* @malloc(i32 %24)
store double* %25, double** %16
%26 = load double*, double** %7
%27 = load i32, i32* %8
%28 = load double*, double** %16
%29 = load i32, i32* %13
%30 = call i32 @dyadup_1D_feed_odd(double* %26, i32 %27, double* %28, i32 %29)
%31 = load i32, i32* %13
%32 = load i32, i32* %10
%33 = add nsw i32 %31, %32
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %14
%35 = load i32, i32* %14
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 8
%38 = trunc i64 %37 to i32
%39 = call double* @malloc(i32 %38)
store double* %39, double** %17
%40 = load double*, double** %16
%41 = load i32, i32* %13
%42 = load double*, double** %17
%43 = load i32, i32* %14
%44 = load double*, double** %9
%45 = load i32, i32* %10
%46 = call i32 @conv(double* %40, i32 %41, double* %42, i32 %43, double* %44, i32 %45)
%47 = load double*, double** %16
%48 = call i32 @free(double* %47)
%49 = load i32, i32* %14
%50 = load i32, i32* %12
%51 = sub nsw i32 %49, %50
%52 = sitofp i32 %51 to double
%53 = fdiv double %52, 2.000000e+00
%54 = fadd double 2.000000e+00, %53
%55 = fptosi double %54 to i32
store i32 %55, i32* %15
%56 = load double*, double** %17
%57 = load i32, i32* %14
%58 = load double*, double** %11
%59 = load i32, i32* %12
%60 = load i32, i32* %15
%61 = call i32 @wkeep_1D_index(double* %56, i32 %57, double* %58, i32 %59, i32 %60)
%62 = load double*, double** %17
%63 = call i32 @free(double* %62)
ret void
}

LLVM IR (-O2):
define void @idwt_detail(double* %0, i32 %1, double* %2, i32 %3, double* %4, i32 %5) {
%7 = shl nsw i32 %1, 1
%8 = add nsw i32 %7, -1
%9 = shl i32 %8, 3
%10 = tail call double* @malloc(i32 %9)
%11 = tail call i32 @dyadup_1D_feed_odd(double* %0, i32 %1, double* %10, i32 %8)
%12 = add i32 %3, -1
%13 = add i32 %12, %8
%14 = shl i32 %13, 3
%15 = tail call double* @malloc(i32 %14)
%16 = tail call i32 @conv(double* %10, i32 %8, double* %15, i32 %13, double* %2, i32 %3)
%17 = tail call i32 @free(double* %10)
%18 = sub nsw i32 %13, %5
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 5.000000e-01
%21 = fadd double %20, 2.000000e+00
%22 = fptosi double %21 to i32
%23 = tail call i32 @wkeep_1D_index(double* %15, i32 %13, double* %4, i32 %5, i32 %22)
%24 = tail call i32 @free(double* %15)
ret void
}