#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 *);
double *malloc(int);
int /*<<< orphan*/ matrix_tran(double *, int, int, double *, int, int);
int /*<<< orphan*/ swt2_output4(double *, int, int, double *, double *,
                                double *, double *, int, int, double *,
                                double *, int, int);
int /*<<< orphan*/ verbatim_copy(double *, int, double *, int);
void swt2_output4_step(double *matrixIn, int matrixInRow, int matrixInCol,
                       double *matrixOutApprox, double *matrixOutColDetail,
                       double *matrixOutRowDetail, double *matrixOutDetail,
                       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));
  matrix_tran(matrixIn, matrixInCol, matrixInRow, matrixApproxTemp, matrixInRow,
              matrixInCol);
  for (count = 0; count < step; count++) {
    swt2_output4(matrixApproxTemp, matrixInRow, matrixInCol, matrixApproxOut,
                 matrixOutColDetail + count * matrixInRow * matrixInCol,
                 matrixOutRowDetail + count * matrixInRow * matrixInCol,
                 matrixOutDetail + count * matrixInRow * matrixInCol,
                 matrixOutRow, matrixOutCol, filterLow, filterHi, filterLength,
                 count);
    verbatim_copy(matrixApproxOut, matrixInRow * matrixInCol,
                  matrixOutApprox + count * matrixInRow * matrixInCol,
                  matrixInRow * matrixInCol);
    matrix_tran(matrixApproxOut, matrixInCol, matrixInRow, matrixApproxTemp,
                matrixInRow, matrixInCol);
  }
  free(matrixApproxOut);
  free(matrixApproxTemp);
  return;
}


x86 assembly (clang, -O0):
<swt2_output4_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    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x58(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1070 <matrix_tran@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    0x40(%rbp),%eax
jge    12d9 <swt2_output4_step+0x189>
mov    -0x58(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x60(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x4c(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    -0x48(%rbp),%r9
mov    -0x4c(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r9
mov    0x10(%rbp),%r12
mov    -0x4c(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r12
mov    0x18(%rbp),%r15d
mov    0x20(%rbp),%r14d
mov    0x28(%rbp),%rbx
mov    0x30(%rbp),%r11
mov    0x38(%rbp),%r10d
mov    -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   1050 <swt2_output4@plt>
mov    -0x60(%rbp),%rdi
mov    -0x2c(%rbp),%esi
imul   -0x30(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x4c(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x2c(%rbp),%ecx
imul   -0x30(%rbp),%ecx
call   1060 <verbatim_copy@plt>
mov    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x58(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1070 <matrix_tran@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11e2 <swt2_output4_step+0x92>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<swt2_output4_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x60(%rsp)
mov    %r8,0x58(%rsp)
mov    %rcx,0x50(%rsp)
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,0x8(%rsp)
mov    0xd0(%rsp),%r14d
mov    0xc8(%rsp),%eax
mov    %rax,0x48(%rsp)
mov    0xc0(%rsp),%rax
mov    %rax,0x40(%rsp)
mov    0xb8(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0xb0(%rsp),%eax
mov    %rax,0x30(%rsp)
mov    0xa8(%rsp),%eax
mov    %rax,0x28(%rsp)
mov    0xa0(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    %edx,%r13d
imul   %esi,%r13d
lea    0x0(,%r13,8),%r15d
mov    %r15d,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %r15d,%edi
call   1040 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r12,0x8(%rsp)
mov    %r12,%rcx
mov    %ebp,%r8d
mov    %ebx,%r9d
call   1070 <matrix_tran@plt>
test   %r14d,%r14d
jle    12c9 <swt2_output4_step+0x179>
mov    %r14d,%eax
mov    %rax,0x18(%rsp)
xor    %r12d,%r12d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %r12d,%r12
mov    0x58(%rsp),%rax
lea    (%rax,%r12,8),%r8
mov    0x60(%rsp),%rax
lea    (%rax,%r12,8),%r9
mov    0x20(%rsp),%rax
lea    (%rax,%r12,8),%rax
sub    $0x8,%rsp
mov    %r13,%r15
mov    0x10(%rsp),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    0x18(%rsp),%r13
mov    %r13,%rcx
push   %r14
push   0x58(%rsp)
push   0x58(%rsp)
push   0x58(%rsp)
push   0x58(%rsp)
push   0x58(%rsp)
push   %rax
call   1050 <swt2_output4@plt>
add    $0x40,%rsp
mov    0x50(%rsp),%rax
lea    (%rax,%r12,8),%rdx
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r15d,%ecx
call   1060 <verbatim_copy@plt>
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    0x8(%rsp),%rcx
mov    %r15,%r13
mov    %ebp,%r8d
mov    %ebx,%r9d
call   1070 <matrix_tran@plt>
add    $0x1,%r14
add    %r13d,%r12d
cmp    %r14,0x18(%rsp)
jne    1230 <swt2_output4_step+0xe0>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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