#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_input1(double *matrixIn, int rowLength, int colLength, double *sigOut,
                 int sigOutLength, double *filterLow, double *filterHi,
                 int filterLength) {
  int step, count;
  double *approxTemp, *approxOut, *matrixInTemp;
  matrixInTemp = malloc(rowLength * colLength * sizeof(double));
  matrix_tran(matrixIn, colLength, rowLength, matrixInTemp, colLength,
              rowLength);
  step = rowLength - 1;
  approxTemp = malloc(colLength * sizeof(double));
  approxOut = malloc(colLength * sizeof(double));
  verbatim_copy(matrixInTemp + step * colLength, colLength, approxTemp,
                colLength);
  for (count = 0; count < step; count++) {
    iswt_conv_step(approxTemp, matrixInTemp + (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(matrixInTemp);
  free(approxTemp);
  free(approxOut);
  return;
}


x86 assembly (clang, -O0):
<iswt_input1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x48(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0xc(%rbp),%r9d
call   1070 <matrix_tran@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <verbatim_copy@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    127b <iswt_input1+0x12b>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
sub    $0x1,%eax
imul   -0x10(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10d
mov    -0x2c(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <iswt_conv_step@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <verbatim_copy@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1201 <iswt_input1+0xb1>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%ecx
call   1060 <verbatim_copy@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iswt_input1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x20(%rsp)
mov    %rcx,0x8(%rsp)
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x68(%rsp),%eax
mov    %rax,0x18(%rsp)
mov    0x60(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    %esi,%edi
imul   %edx,%edi
shl    $0x3,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rbp,%r14
mov    %r14d,%edx
mov    %rax,%rcx
mov    %ebx,%r8d
mov    %r14d,%r9d
call   1070 <matrix_tran@plt>
lea    -0x1(%rbp),%r12d
lea    0x0(,%rbx,8),%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
mov    %r12d,%ebp
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%eax
imul   %ebx,%eax
cltq
mov    %r15,(%rsp)
lea    (%r15,%rax,8),%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
cmp    $0x2,%r14d
jl     1252 <iswt_input1+0x102>
mov    %ebp,%r14d
movslq %ebx,%r15
lea    -0x1(%r14),%rax
imul   %r15,%rax
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rbp
shl    $0x3,%r15
neg    %r15
nopl   0x0(%rax,%rax,1)
sub    $0x8,%rsp
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r12,%rcx
mov    %ebx,%r8d
mov    0x28(%rsp),%r9
push   %r14
push   0x28(%rsp)
push   0x28(%rsp)
call   1040 <iswt_conv_step@plt>
add    $0x20,%rsp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
add    %r15,%rbp
add    $0xffffffffffffffff,%r14
jne    1210 <iswt_input1+0xc0>
mov    %r13,%rdi
mov    %ebx,%esi
mov    0x8(%rsp),%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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