#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_output1_step(double *matrixIn, 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));
  matrix_tran(matrixIn, matrixInCol, matrixInRow, matrixApproxTemp, matrixInRow,
              matrixInCol);
  for (count = 0; count < step; count++) {
    swt2_output4(matrixApproxTemp, matrixInRow, matrixInCol, matrixApproxOut,
                 matrixOut + count * matrixInRow * matrixInCol,
                 matrixOut + step * matrixInRow * matrixInCol +
                     count * matrixInRow * matrixInCol,
                 matrixOut + 2 * step * matrixInRow * matrixInCol +
                     count * matrixInRow * matrixInCol,
                 matrixInRow, matrixOutCol, filterLow, filterHi, filterLength,
                 count);
    matrix_tran(matrixApproxOut, matrixInCol, matrixInRow, matrixApproxTemp,
                matrixInRow, matrixInCol);
  }
  verbatim_copy(matrixApproxOut, matrixInRow * matrixInCol,
                matrixOut + 3 * step * matrixInRow * matrixInCol,
                matrixInRow * matrixInCol);
  free(matrixApproxOut);
  free(matrixApproxTemp);
  return;
}


x86 assembly (clang, -O0):
<swt2_output1_step>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8d,-0x3c(%rbp)
mov    %r9d,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x50(%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    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1070 <matrix_tran@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    0x28(%rbp),%eax
jge    12c8 <swt2_output1_step+0x178>
mov    -0x50(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x58(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x44(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    -0x38(%rbp),%r9
mov    0x28(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r9
mov    -0x44(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r9
mov    -0x38(%rbp),%r12
mov    0x28(%rbp),%eax
shl    $0x1,%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r12
mov    -0x44(%rbp),%eax
imul   -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r12
mov    -0x2c(%rbp),%r15d
mov    -0x40(%rbp),%r14d
mov    0x10(%rbp),%rbx
mov    0x18(%rbp),%r11
mov    0x20(%rbp),%r10d
mov    -0x44(%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    -0x58(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
call   1070 <matrix_tran@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d5 <swt2_output1_step+0x85>
mov    -0x58(%rbp),%rdi
mov    -0x2c(%rbp),%esi
imul   -0x30(%rbp),%esi
mov    -0x38(%rbp),%rdx
imul   $0x3,0x28(%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    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<swt2_output1_step>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x50(%rsp)
mov    %rcx,0x10(%rsp)
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
mov    0xa8(%rsp),%r14d
mov    0xa0(%rsp),%eax
mov    %rax,0x48(%rsp)
mov    0x98(%rsp),%rax
mov    %rax,0x40(%rsp)
mov    0x90(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    %edx,%eax
imul   %esi,%eax
mov    %rax,0x8(%rsp)
lea    0x0(,%rax,8),%r12d
mov    %r12d,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r13,%rcx
mov    %ebx,%r8d
mov    %ebp,%r9d
call   1070 <matrix_tran@plt>
mov    %r14,0x18(%rsp)
test   %r14d,%r14d
jle    128e <swt2_output1_step+0x13e>
mov    0x8(%rsp),%rax
mov    0x18(%rsp),%rdx
imul   %edx,%eax
cltq
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
mov    %rsi,0x30(%rsp)
add    %eax,%eax
cltq
lea    (%rcx,%rax,8),%rax
mov    %rax,0x28(%rsp)
mov    %edx,%eax
mov    %rax,0x20(%rsp)
xor    %r15d,%r15d
xor    %r14d,%r14d
nop
movslq %r15d,%r15
mov    0x10(%rsp),%rax
lea    (%rax,%r15,8),%r8
mov    0x30(%rsp),%rax
lea    (%rax,%r15,8),%r9
mov    0x28(%rsp),%rax
lea    (%rax,%r15,8),%rax
sub    $0x8,%rsp
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r12,%rcx
push   %r14
push   0x58(%rsp)
push   0x58(%rsp)
push   0x58(%rsp)
push   0x78(%rsp)
push   %rbx
push   %rax
call   1050 <swt2_output4@plt>
add    $0x40,%rsp
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r13,%rcx
mov    %ebx,%r8d
mov    %ebp,%r9d
call   1070 <matrix_tran@plt>
add    $0x1,%r14
add    0x8(%rsp),%r15d
cmp    %r14,0x20(%rsp)
jne    1220 <swt2_output1_step+0xd0>
mov    0x8(%rsp),%rsi
mov    0x18(%rsp),%rax
imul   %esi,%eax
lea    (%rax,%rax,2),%eax
cltq
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rdx
mov    %r12,%rdi
mov    %esi,%ecx
call   1060 <verbatim_copy@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%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 @swt2_output1_step(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %6, double* %7, i32 %8, i32 %9) {
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca double*
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca double*
%23 = alloca double*
store double* %0, double** %11
store i32 %1, i32* %12
store i32 %2, i32* %13
store double* %3, double** %14
store i32 %4, i32* %15
store i32 %5, i32* %16
store double* %6, double** %17
store double* %7, double** %18
store i32 %8, i32* %19
store i32 %9, i32* %20
%24 = load i32, i32* %12
%25 = load i32, i32* %13
%26 = mul nsw i32 %24, %25
%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** %22
%31 = load i32, i32* %12
%32 = load i32, i32* %13
%33 = mul nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 8
%36 = trunc i64 %35 to i32
%37 = call double* @malloc(i32 %36)
store double* %37, double** %23
%38 = load double*, double** %11
%39 = load i32, i32* %13
%40 = load i32, i32* %12
%41 = load double*, double** %22
%42 = load i32, i32* %12
%43 = load i32, i32* %13
%44 = call i32 @matrix_tran(double* %38, i32 %39, i32 %40, double* %41, i32 %42, i32 %43)
store i32 0, i32* %21
br label %45
45: ; preds = %107, %10
%46 = load i32, i32* %21
%47 = load i32, i32* %20
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %110
49: ; preds = %45
%50 = load double*, double** %22
%51 = load i32, i32* %12
%52 = load i32, i32* %13
%53 = load double*, double** %23
%54 = load double*, double** %14
%55 = load i32, i32* %21
%56 = load i32, i32* %12
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %13
%59 = mul nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %54, i64 %60
%62 = load double*, double** %14
%63 = load i32, i32* %20
%64 = load i32, i32* %12
%65 = mul nsw i32 %63, %64
%66 = load i32, i32* %13
%67 = mul nsw i32 %65, %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %62, i64 %68
%70 = load i32, i32* %21
%71 = load i32, i32* %12
%72 = mul nsw i32 %70, %71
%73 = load i32, i32* %13
%74 = mul nsw i32 %72, %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %69, i64 %75
%77 = load double*, double** %14
%78 = load i32, i32* %20
%79 = mul nsw i32 2, %78
%80 = load i32, i32* %12
%81 = mul nsw i32 %79, %80
%82 = load i32, i32* %13
%83 = mul nsw i32 %81, %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %77, i64 %84
%86 = load i32, i32* %21
%87 = load i32, i32* %12
%88 = mul nsw i32 %86, %87
%89 = load i32, i32* %13
%90 = mul nsw i32 %88, %89
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %85, i64 %91
%93 = load i32, i32* %12
%94 = load i32, i32* %16
%95 = load double*, double** %17
%96 = load double*, double** %18
%97 = load i32, i32* %19
%98 = load i32, i32* %21
%99 = call i32 @swt2_output4(double* %50, i32 %51, i32 %52, double* %53, double* %61, double* %76, double* %92, i32 %93, i32 %94, double* %95, double* %96, i32 %97, i32 %98)
%100 = load double*, double** %23
%101 = load i32, i32* %13
%102 = load i32, i32* %12
%103 = load double*, double** %22
%104 = load i32, i32* %12
%105 = load i32, i32* %13
%106 = call i32 @matrix_tran(double* %100, i32 %101, i32 %102, double* %103, i32 %104, i32 %105)
br label %107
107: ; preds = %49
%108 = load i32, i32* %21
%109 = add nsw i32 %108, 1
store i32 %109, i32* %21
br label %45
110: ; preds = %45
%111 = load double*, double** %23
%112 = load i32, i32* %12
%113 = load i32, i32* %13
%114 = mul nsw i32 %112, %113
%115 = load double*, double** %14
%116 = load i32, i32* %20
%117 = mul nsw i32 3, %116
%118 = load i32, i32* %12
%119 = mul nsw i32 %117, %118
%120 = load i32, i32* %13
%121 = mul nsw i32 %119, %120
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds double, double* %115, i64 %122
%124 = load i32, i32* %12
%125 = load i32, i32* %13
%126 = mul nsw i32 %124, %125
%127 = call i32 @verbatim_copy(double* %111, i32 %114, double* %123, i32 %126)
%128 = load double*, double** %23
%129 = call i32 @free(double* %128)
%130 = load double*, double** %22
%131 = call i32 @free(double* %130)
ret void
}

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