#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*/ iswt2(double *, double *, double *, double *, int, int,
                         double *, int, int, double *, double *, int, int);
double *malloc(int);
int /*<<< orphan*/ verbatim_copy(double *, int, double *, int);
void iswt2_input4_step(double *matrixInApprox, double *matrixInColDetail,
                       double *matrixInRowDetail, double *matrixInDetail,
                       int matrixInRow, int matrixInCol, double *matrixOut,
                       int matrixOutRow, int matrixOutCol, double *filterLow,
                       double *filterHi, int filterLength, int step) {
  int count;
  double *matrixApproxTemp, *matrixApproxOut;
  matrixApproxTemp = malloc(matrixInRow * matrixInCol * sizeof(double));
  matrixApproxOut = malloc(matrixInRow * matrixInCol * sizeof(double));
  verbatim_copy(matrixInApprox + (step - 1) * matrixInRow * matrixInCol,
                matrixInRow * matrixInCol, matrixApproxTemp,
                matrixInRow * matrixInCol);
  for (count = 0; count < step; count++) {
    iswt2(matrixApproxTemp,
          matrixInColDetail + (step - count - 1) * matrixInRow * matrixInCol,
          matrixInRowDetail + (step - count - 1) * matrixInRow * matrixInCol,
          matrixInDetail + (step - count - 1) * matrixInRow * matrixInCol,
          matrixInRow, matrixInCol, matrixApproxOut, matrixOutRow, matrixOutCol,
          filterLow, filterHi, filterLength, step - count);
    if (count != (step - 1)) {
      verbatim_copy(matrixApproxOut, matrixInRow * matrixInCol,
                    matrixApproxTemp, matrixInRow * matrixInCol);
    }
  }
  free(matrixApproxTemp);
  verbatim_copy(matrixApproxOut, matrixInRow * matrixInCol, matrixOut,
                matrixInRow * matrixInCol);
  free(matrixApproxOut);
  return;
}


x86 assembly (clang, -O0):
<iswt2_input4_step>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
mov    %r8d,-0x44(%rbp)
mov    %r9d,-0x48(%rbp)
mov    -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x40(%rbp),%eax
sub    $0x1,%eax
imul   -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x44(%rbp),%esi
imul   -0x48(%rbp),%esi
mov    -0x58(%rbp),%rdx
mov    -0x44(%rbp),%ecx
imul   -0x48(%rbp),%ecx
call   1060 <verbatim_copy@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    0x40(%rbp),%eax
jge    12e0 <iswt2_input4_step+0x1a0>
mov    -0x58(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x40(%rbp),%eax
sub    -0x4c(%rbp),%eax
sub    $0x1,%eax
imul   -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x38(%rbp),%rdx
mov    0x40(%rbp),%eax
sub    -0x4c(%rbp),%eax
sub    $0x1,%eax
imul   -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x40(%rbp),%rcx
mov    0x40(%rbp),%eax
sub    -0x4c(%rbp),%eax
sub    $0x1,%eax
imul   -0x44(%rbp),%eax
imul   -0x48(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    -0x44(%rbp),%r8d
mov    -0x48(%rbp),%r9d
mov    -0x60(%rbp),%r12
mov    0x18(%rbp),%r15d
mov    0x20(%rbp),%r14d
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10d
mov    0x40(%rbp),%eax
sub    -0x4c(%rbp),%eax
mov    %r12,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %eax,0x30(%rsp)
call   1040 <iswt2@plt>
mov    -0x4c(%rbp),%eax
mov    0x40(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     12cd <iswt2_input4_step+0x18d>
mov    -0x60(%rbp),%rdi
mov    -0x44(%rbp),%esi
imul   -0x48(%rbp),%esi
mov    -0x58(%rbp),%rdx
mov    -0x44(%rbp),%ecx
imul   -0x48(%rbp),%ecx
call   1060 <verbatim_copy@plt>
jmp    12d2 <iswt2_input4_step+0x192>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11eb <iswt2_input4_step+0xab>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
mov    -0x44(%rbp),%esi
imul   -0x48(%rbp),%esi
mov    0x10(%rbp),%rdx
mov    -0x44(%rbp),%ecx
imul   -0x48(%rbp),%ecx
call   1060 <verbatim_copy@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<iswt2_input4_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,0x50(%rsp)
mov    %rdx,0x48(%rsp)
mov    %rsi,0x40(%rsp)
mov    %rdi,0x8(%rsp)
mov    0xc0(%rsp),%r12d
mov    0xb8(%rsp),%eax
mov    %rax,0x38(%rsp)
mov    0xb0(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0xa8(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0xa0(%rsp),%eax
mov    %rax,0x20(%rsp)
mov    0x98(%rsp),%eax
mov    %rax,0x18(%rsp)
mov    0x90(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    %r9d,0x4(%rsp)
mov    %r9d,%ebx
mov    %r8d,(%rsp)
imul   %r8d,%ebx
lea    0x0(,%rbx,8),%r14d
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    -0x1(%r12),%ebp
mov    %ebx,%r13d
imul   %ebp,%r13d
movslq %r13d,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
test   %r12d,%r12d
jle    1290 <iswt2_input4_step+0x150>
mov    %r12d,%r12d
mov    %ebp,%ebp
jmp    1229 <iswt2_input4_step+0xe9>
nopw   0x0(%rax,%rax,1)
sub    %ebx,%r13d
add    $0xffffffffffffffff,%r12
je     1290 <iswt2_input4_step+0x150>
movslq %r13d,%rax
mov    0x40(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
mov    0x48(%rsp),%rcx
lea    (%rcx,%rax,8),%rdx
mov    0x50(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
sub    $0x8,%rsp
mov    %r15,%rdi
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%r9d
push   %r12
push   0x48(%rsp)
push   0x48(%rsp)
push   0x48(%rsp)
push   0x48(%rsp)
push   0x48(%rsp)
push   %r14
call   1040 <iswt2@plt>
add    $0x40,%rsp
sub    $0x1,%rbp
jb     1220 <iswt2_input4_step+0xe0>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
jmp    1220 <iswt2_input4_step+0xe0>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    0x10(%rsp),%rdx
mov    %ebx,%ecx
call   1060 <verbatim_copy@plt>
mov    %r14,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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