#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*/ iswt_conv_step(double *, double *, int, double *, int,
                                  double *, double *, int, int);
double *malloc(int);
int /*<<< orphan*/ matrix_tran(double *, int, int, double *, int, int);
int /*<<< orphan*/ verbatim_copy(double *, int, double *, int);
void iswt_input2(double *matrixApproxIn, double *matrixDetailIn, int rowLength,
                 int colLength, double *sigOut, int sigOutLength,
                 double *filterLow, double *filterHi, int filterLength) {
  int count, step;
  double *approxTemp, *approxOut;
  double *matrixApproxInTemp, *matrixDetailInTemp;
  step = rowLength;
  approxTemp = malloc(colLength * sizeof(double));
  approxOut = malloc(colLength * sizeof(double));
  matrixApproxInTemp = malloc(rowLength * colLength * sizeof(double));
  matrixDetailInTemp = malloc(rowLength * colLength * sizeof(double));
  matrix_tran(matrixApproxIn, colLength, rowLength, matrixApproxInTemp,
              colLength, rowLength);
  matrix_tran(matrixDetailIn, colLength, rowLength, matrixDetailInTemp,
              colLength, rowLength);
  verbatim_copy(matrixApproxInTemp + (step - 1) * colLength, colLength,
                approxTemp, colLength);
  for (count = 0; count < step; count++) {
    iswt_conv_step(approxTemp,
                   matrixDetailInTemp + (step - count - 1) * colLength,
                   colLength, approxOut, colLength, filterLow, filterHi,
                   filterLength, step - count);
    verbatim_copy(approxOut, colLength, approxTemp, colLength);
  }
  verbatim_copy(approxTemp, colLength, sigOut, colLength);
  free(approxTemp);
  free(approxOut);
  free(matrixApproxInTemp);
  free(matrixDetailInTemp);
  return;
}


x86 assembly (clang, -O0):
<iswt_input2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   1070 <matrix_tran@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   1070 <matrix_tran@plt>
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1060 <verbatim_copy@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12b2 <iswt_input2+0x162>
mov    -0x38(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x2c(%rbp),%eax
sub    -0x28(%rbp),%eax
sub    $0x1,%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    -0x18(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r11
mov    0x20(%rbp),%r10d
mov    -0x2c(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <iswt_conv_step@plt>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1060 <verbatim_copy@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1238 <iswt_input2+0xe8>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%ecx
call   1060 <verbatim_copy@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iswt_input2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,0x18(%rsp)
mov    %ecx,%ebx
mov    %edx,%r13d
mov    %rsi,0x8(%rsp)
mov    %rdi,0x10(%rsp)
mov    0x80(%rsp),%eax
mov    %rax,0x30(%rsp)
mov    0x78(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0x70(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x0(,%rbx,8),%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r13d,%ebp
imul   %ebx,%ebp
shl    $0x3,%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r14,%rcx
mov    %ebx,%r8d
mov    %r13d,%r9d
call   1070 <matrix_tran@plt>
mov    0x8(%rsp),%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %rbp,0x8(%rsp)
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    %r13d,%r9d
call   1070 <matrix_tran@plt>
lea    -0x1(%r13),%eax
imul   %ebx,%eax
cltq
mov    %r14,0x10(%rsp)
lea    (%r14,%rax,8),%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
test   %r13d,%r13d
jle    1282 <iswt_input2+0x132>
mov    %r13d,%r14d
movslq %ebx,%r13
lea    -0x1(%r14),%rax
imul   %r13,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rbp
shl    $0x3,%r13
neg    %r13
sub    $0x8,%rsp
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r12,%rcx
mov    %ebx,%r8d
mov    0x28(%rsp),%r9
push   %r14
push   0x40(%rsp)
push   0x40(%rsp)
call   1040 <iswt_conv_step@plt>
add    $0x20,%rsp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
add    %r13,%rbp
add    $0xffffffffffffffff,%r14
jne    1240 <iswt_input2+0xf0>
mov    %r15,%rdi
mov    %ebx,%esi
mov    0x18(%rsp),%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @iswt_input2(double* %0, double* %1, i32 %2, i32 %3, double* %4, i32 %5, double* %6, double* %7, i32 %8) {
%10 = shl i32 %3, 3
%11 = tail call double* @malloc(i32 %10)
%12 = tail call double* @malloc(i32 %10)
%13 = shl i32 %2, 3
%14 = mul i32 %13, %3
%15 = tail call double* @malloc(i32 %14)
%16 = tail call double* @malloc(i32 %14)
%17 = tail call i32 @matrix_tran(double* %0, i32 %3, i32 %2, double* %15, i32 %3, i32 %2)
%18 = tail call i32 @matrix_tran(double* %1, i32 %3, i32 %2, double* %16, i32 %3, i32 %2)
%19 = add nsw i32 %2, -1
%20 = mul nsw i32 %19, %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %15, i64 %21
%23 = tail call i32 @verbatim_copy(double* %22, i32 %3, double* %11, i32 %3)
%24 = icmp sgt i32 %2, 0
br i1 %24, label %25, label %40
25: ; preds = %9
%26 = zext i32 %2 to i64
%27 = sext i32 %3 to i64
%28 = zext i32 %2 to i64
br label %29
29: ; preds = %25, %29
%30 = phi i64 [ 0, %25 ], [ %38, %29 ]
%31 = sub nsw i64 %26, %30
%32 = add nsw i64 %31, -1
%33 = mul nsw i64 %32, %27
%34 = getelementptr inbounds double, double* %16, i64 %33
%35 = trunc i64 %31 to i32
%36 = tail call i32 @iswt_conv_step(double* %11, double* %34, i32 %3, double* %12, i32 %3, double* %6, double* %7, i32 %8, i32 %35)
%37 = tail call i32 @verbatim_copy(double* %12, i32 %3, double* %11, i32 %3)
%38 = add nuw nsw i64 %30, 1
%39 = icmp eq i64 %38, %28
br i1 %39, label %40, label %29
40: ; preds = %29, %9
%41 = tail call i32 @verbatim_copy(double* %11, i32 %3, double* %4, i32 %3)
%42 = tail call i32 @free(double* %11)
%43 = tail call i32 @free(double* %12)
%44 = tail call i32 @free(double* %15)
%45 = tail call i32 @free(double* %16)
ret void
}