// File: /workspace/github_cpp_makefile_star2_O3/kchan1[P]helloworld_test1/main2.cpp
// Function: subband_recomp(double**&, int, int)
void subband_recomp(double** &image_data, int height, int width){
	double low_pass_filter[7] = {.2,.6,.7,.2,-.3,0,.1};
	double high_pass_filter[7] = {-.1,0,.3,.2,-.7,.6,-.2};

	double** round1_low = new double*[height];
	double** round1_high = new double*[height];
	double** round2_low = new double*[height];
	double** round2_high = new double*[height];

	for (int i = 0; i<height; i++){
		round1_low[i] = new double[width];
		round1_high[i] = new double[width];
		round2_low[i] = new double[width];
		round2_high[i] = new double[width];
	}

	for (int i=0; i <height; i++){
		for(int j=0; j<width; j++){
			round1_low[i][j] = 0;
			round1_high[i][j] = 0;
			round2_low[i][j] = 0;
			round2_high[i][j] = 0;
		}		
	}

	//cout<<height/2<<" "<<width/2<<endl;

	for (int i=0; i<(int)(height/2); i++){
		for(int j=0; j<(int)(width/2);j++){
			round1_low[i*2][j*2]=(double)image_data[i][j];
			round2_low[i*2][j*2]=(double)image_data[i+height/2][j];
			round1_high[i*2][j*2]=(double)image_data[i+height/2][j+width/2];
			round2_high[i*2][j*2]=(double)image_data[i][j+width/2];
		}
	}

	/*for (int i = 0; i<height; i++){
		for(int j =0; j<width;j++){
			cout<<(int)round1_low[i][j]<<" ";
		}
		cout<<endl;
	}*/

	vertical_convolution(round1_low,height,width,low_pass_filter,7);
	vertical_convolution(round2_low,height,width,high_pass_filter,7);
	vertical_convolution(round1_high,height,width,high_pass_filter,7);
	vertical_convolution(round2_high,height,width,low_pass_filter,7);

	//COMBINATION SECTION GO!

	for (int i=0; i<height; i++){
		for(int j=0; j<width; j++){
			round1_low[i][j] = round1_low[i][j]+round2_low[i][j];
			//round1_low[i][j] = round2_low[i][j];
			round1_high[i][j] = round1_high[i][j]+round2_high[i][j];
			//round1_high[i][j] = round2_high[i][j];
		}
	}	

	for(int i=0; i<height; i++){
		horizontal_convolution(round1_low[i],width,low_pass_filter,7);
		horizontal_convolution(round1_high[i],width,high_pass_filter,7);
	}

	for (int i=0; i<height; i++){
		for(int j=0; j<width; j++){
			image_data[i][j] = round1_low[i][j]+round1_high[i][j];
			image_data[i][j]*=.80;
			//image_data[i][j];
		}
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps 0x1a9f(%rip), %xmm1     # 0x4010
movaps %xmm1, 0xb0(%rsp)
movapd 0x1a9f(%rip), %xmm1     # 0x4020
movapd %xmm1, 0xc0(%rsp)
movabsq $-0x402ccccccccccccd, %rax # imm = 0xBFD3333333333333
movq %rax, 0xd0(%rsp)
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0xe0(%rsp)
movaps %xmm0, 0x70(%rsp)
movabsq $-0x4046666666666666, %rax # imm = 0xBFB999999999999A
movq %rax, 0x70(%rsp)
movaps 0x1a67(%rip), %xmm0     # 0x4030
movaps %xmm0, 0x80(%rsp)
movapd 0x1a67(%rip), %xmm0     # 0x4040
movapd %xmm0, 0x90(%rsp)
movabsq $-0x4036666666666666, %rax # imm = 0xBFC999999999999A
movq %rax, 0xa0(%rsp)
movl %esi, %eax
movq %rax, 0x18(%rsp)
leaq (,%rax,8), %r15
testl %esi, %esi
movq $-0x1, %rax
cmovsq %rax, %r15
movq %r15, %rdi
callq 0x2030
movq %rax, %r13
movq %rax, 0x58(%rsp)
movq %r15, %rdi
callq 0x2030
movq %rax, %r12
movq %rax, 0x50(%rsp)
movq %r15, %rdi
callq 0x2030
movq %rax, 0x20(%rsp)
movq %rax, 0x48(%rsp)
movq %r15, %rdi
callq 0x2030
movq %rax, 0x40(%rsp)
testl %ebp, %ebp
jle 0x29a9
movl %ebp, 0x4(%rsp)
movq $-0x1, %rcx
movl %r14d, %ebx
leaq (,%rbx,8), %rbp
movl %r14d, 0x34(%rsp)
testl %r14d, %r14d
cmovsq %rcx, %rbp
movq %rax, 0x28(%rsp)
xorl %r15d, %r15d
movq %r12, 0x10(%rsp)
movq %r13, %r12
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %r14
movq %rbp, %rdi
callq 0x2030
movq %rax, (%r12,%r15,8)
movq %rbp, %rdi
callq 0x2030
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
movq %rbp, %rdi
callq 0x2030
movq %rax, (%r14,%r15,8)
movq %rbp, %rdi
callq 0x2030
movq 0x28(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x2693
movl 0x4(%rsp), %ebp
testl %ebp, %ebp
movq %r12, %r13
movq 0x10(%rsp), %r12
movl 0x34(%rsp), %r14d
movq 0x28(%rsp), %r15
jle 0x29a9
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r11
testl %r14d, %r14d
jle 0x2732
movq (%r13,%rcx,8), %rdx
movq (%r12,%rcx,8), %rsi
movq (%r11,%rcx,8), %rdi
movq (%r15,%rcx,8), %r8
xorl %r9d, %r9d
movq %rax, (%rdx,%r9,8)
movq %rax, (%rsi,%r9,8)
movq %rax, (%rdi,%r9,8)
movq %rax, (%r8,%r9,8)
incq %r9
cmpq %r9, %rbx
jne 0x271a
incq %rcx
cmpq %r10, %rcx
jne 0x2701
cmpl $0x1, %ebp
je 0x2807
movl 0x4(%rsp), %eax
movl %eax, %edx
shrl %edx
movl %r14d, %ecx
shrl $0x1f, %ecx
addl %r14d, %ecx
sarl %ecx
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rdx, 0x8(%rsp)
movq %rax, 0x68(%rsp)
leaq (%rax,%rdx,8), %rax
movq %rax, 0x60(%rsp)
shlq $0x3, %rcx
xorl %edi, %edi
movl %r14d, %eax
cmpl $0x2, %r14d
jl 0x27f6
movq 0x68(%rsp), %rdx
movq (%rdx,%rdi,8), %r8
movq %rdi, %rdx
shlq $0x4, %rdx
movq (%r13,%rdx), %r9
movq 0x60(%rsp), %rsi
movq (%rsi,%rdi,8), %r10
movq 0x20(%rsp), %rsi
movq (%rsi,%rdx), %r11
movq (%r12,%rdx), %r14
movq 0x28(%rsp), %rsi
movq (%rsi,%rdx), %r15
leaq (%r8,%rcx), %rbp
leaq (%r10,%rcx), %rsi
xorl %edx, %edx
movsd (%r8,%rdx), %xmm0
movsd %xmm0, (%r9,%rdx,2)
movsd (%r10,%rdx), %xmm0
movsd %xmm0, (%r11,%rdx,2)
movsd (%rsi,%rdx), %xmm0
movsd %xmm0, (%r14,%rdx,2)
movsd (%rbp,%rdx), %xmm0
movsd %xmm0, (%r15,%rdx,2)
addq $0x8, %rdx
cmpq %rdx, %rcx
jne 0x27be
incq %rdi
cmpq 0x8(%rsp), %rdi
movl %eax, %r14d
jne 0x2777
movq %r13, 0x8(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0xb0(%rsp), %r12
movl 0x4(%rsp), %ebp
movl %ebp, %esi
movl %r14d, %edx
movq %r12, %rcx
movl $0x7, %r8d
callq 0x23e5
leaq 0x48(%rsp), %rdi
leaq 0x70(%rsp), %r15
movl %ebp, %esi
movl %r14d, %edx
movq %r15, %rcx
movl $0x7, %r8d
callq 0x23e5
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
movq %r15, %rcx
movl $0x7, %r8d
callq 0x23e5
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
movq %r12, %rcx
movl $0x7, %r8d
callq 0x23e5
testl %ebp, %ebp
movq 0x18(%rsp), %r9
jle 0x2a1c
xorl %eax, %eax
movq 0x8(%rsp), %r10
movq 0x10(%rsp), %r11
movq 0x20(%rsp), %r15
testl %r14d, %r14d
jle 0x28e4
movq (%r10,%rax,8), %rcx
movq (%r15,%rax,8), %rdx
movq (%r11,%rax,8), %rsi
movq 0x28(%rsp), %rdi
movq (%rdi,%rax,8), %rdi
xorl %r8d, %r8d
movsd (%rcx,%r8,8), %xmm0
addsd (%rdx,%r8,8), %xmm0
movsd %xmm0, (%rcx,%r8,8)
movsd (%rsi,%r8,8), %xmm0
addsd (%rdi,%r8,8), %xmm0
movsd %xmm0, (%rsi,%r8,8)
incq %r8
cmpq %r8, %rbx
jne 0x28b8
incq %rax
cmpq %r9, %rax
jne 0x289b
testl %ebp, %ebp
jle 0x2a1c
leaq 0x70(%rsp), %r13
movl %r14d, %r12d
movq %r9, %r14
movq 0x8(%rsp), %rbp
movq 0x10(%rsp), %r15
movq %rbp, %rdi
movl %r12d, %esi
leaq 0xb0(%rsp), %rdx
movl $0x7, %ecx
callq 0x231c
movq %r15, %rdi
movl %r12d, %esi
movq %r13, %rdx
movl $0x7, %ecx
callq 0x231c
addq $0x8, %r15
addq $0x8, %rbp
decq %r14
jne 0x2909
cmpl $0x0, 0x4(%rsp)
movq 0x18(%rsp), %r9
jle 0x2a1c
movq 0x38(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
movsd 0x178d(%rip), %xmm0     # 0x40f0
testl %r12d, %r12d
jle 0x299f
movq 0x8(%rsp), %rdx
movq (%rdx,%rcx,8), %rdx
movq 0x10(%rsp), %rsi
movq (%rsi,%rcx,8), %rsi
movq (%rax,%rcx,8), %rdi
xorl %r8d, %r8d
movsd (%rdx,%r8,8), %xmm1
addsd (%rsi,%r8,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rbx
jne 0x2981
incq %rcx
cmpq %r9, %rcx
jne 0x2963
jmp 0x2a1c
leaq 0x58(%rsp), %rdi
movl %ebp, %r15d
movl %r14d, %ebp
leaq 0xb0(%rsp), %r14
movl %r15d, %esi
movl %ebp, %edx
movq %r14, %rcx
movl $0x7, %r8d
callq 0x23e5
leaq 0x48(%rsp), %rdi
leaq 0x70(%rsp), %rbx
movl %r15d, %esi
movl %ebp, %edx
movq %rbx, %rcx
movl $0x7, %r8d
callq 0x23e5
leaq 0x50(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
movq %rbx, %rcx
movl $0x7, %r8d
callq 0x23e5
leaq 0x40(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
movq %r14, %rcx
movl $0x7, %r8d
callq 0x23e5
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq