// File: /workspace/github_cpp_makefile_star2_O2/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 $0xc8, %rsp
movl %edx, 0x8(%rsp)
movq %rdi, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps 0x1ade(%rip), %xmm1     # 0x4010
movaps %xmm1, 0x90(%rsp)
movapd 0x1ade(%rip), %xmm1     # 0x4020
movapd %xmm1, 0xa0(%rsp)
movabsq $-0x402ccccccccccccd, %rax # imm = 0xBFD3333333333333
movq %rax, 0xb0(%rsp)
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0xc0(%rsp)
movaps %xmm0, 0x50(%rsp)
movabsq $-0x4046666666666666, %rax # imm = 0xBFB999999999999A
movq %rax, 0x50(%rsp)
movaps 0x1aa6(%rip), %xmm0     # 0x4030
movaps %xmm0, 0x60(%rsp)
movapd 0x1aa9(%rip), %xmm0     # 0x4040
movapd %xmm0, 0x70(%rsp)
movabsq $-0x4036666666666666, %rax # imm = 0xBFC999999999999A
movq %rax, 0x80(%rsp)
movl %esi, %ebx
shlq $0x3, %rbx
xorl %ebp, %ebp
testl %esi, %esi
pushq $-0x1
popq %rax
cmovsq %rax, %rbx
movl $0x0, %eax
movl %esi, 0xc(%rsp)
cmovgl %esi, %eax
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x2030
movq %rax, %r14
movq %rax, 0x48(%rsp)
movq %rbx, %rdi
callq 0x2030
movq %rax, %r15
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x2030
movq %rax, %r13
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
callq 0x2030
movq %rax, %r12
movq %rax, 0x30(%rsp)
movl 0x8(%rsp), %eax
movl %eax, %ebx
shlq $0x3, %rbx
testl %eax, %eax
pushq $-0x1
popq %rax
cmovsq %rax, %rbx
movq 0x10(%rsp), %rsi
cmpq %rbp, %rsi
je 0x2664
movq %rbx, %rdi
callq 0x2030
movq %rax, (%r14,%rbp,8)
movq %rbx, %rdi
callq 0x2030
movq %rax, (%r15,%rbp,8)
movq %rbx, %rdi
callq 0x2030
movq %rax, (%r13,%rbp,8)
movq %rbx, %rdi
callq 0x2030
movq %rax, (%r12,%rbp,8)
incq %rbp
jmp 0x2624
xorl %eax, %eax
movl 0x8(%rsp), %ecx
testl %ecx, %ecx
movl $0x0, %edi
cmovgl %ecx, %edi
cmpq %rsi, %rax
je 0x26af
xorl %ecx, %ecx
cmpq %rcx, %rdi
je 0x26aa
movq (%r14,%rax,8), %rdx
andq $0x0, (%rdx,%rcx,8)
movq (%r15,%rax,8), %rdx
andq $0x0, (%rdx,%rcx,8)
movq (%r13,%rax,8), %rdx
andq $0x0, (%rdx,%rcx,8)
movq (%r12,%rax,8), %rdx
andq $0x0, (%rdx,%rcx,8)
incq %rcx
jmp 0x267b
incq %rax
jmp 0x2674
movq %rdi, 0x18(%rsp)
pushq $0x2
popq %rsi
movl 0xc(%rsp), %eax
cltd
idivl %esi
movl %eax, %ecx
movl 0x8(%rsp), %eax
cltd
idivl %esi
cltq
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
movslq %ecx, %rcx
testl %ecx, %ecx
movl $0x0, %edi
cmovgl %ecx, %edi
movq %rdi, 0x28(%rsp)
shlq $0x3, %rsi
shlq $0x3, %rax
cmpq 0x28(%rsp), %rdx
je 0x2767
movq 0x20(%rsp), %rdi
movq (%rdi), %r8
leaq (%rdx,%rdx), %r9
leaq (%r8,%rdx,8), %r10
xorl %r11d, %r11d
cmpq %r11, %rsi
je 0x2762
movq (%r8,%rdx,8), %rbx
movsd (%rbx,%r11), %xmm0
addq %r11, %rbx
movq (%r14,%r9,8), %rdi
movsd %xmm0, (%rdi,%r11,2)
movq (%r10,%rcx,8), %rdi
movsd (%rdi,%r11), %xmm0
addq %r11, %rdi
movq (%r13,%r9,8), %rbp
movsd %xmm0, (%rbp,%r11,2)
movsd (%rax,%rdi), %xmm0
movq (%r15,%r9,8), %rdi
movsd %xmm0, (%rdi,%r11,2)
movsd (%rax,%rbx), %xmm0
movq (%r12,%r9,8), %rdi
movsd %xmm0, (%rdi,%r11,2)
addq $0x8, %r11
jmp 0x2709
incq %rdx
jmp 0x26ef
leaq 0x48(%rsp), %rdi
leaq 0x90(%rsp), %rcx
pushq $0x7
popq %r8
movl 0xc(%rsp), %ebx
movl %ebx, %esi
movl 0x8(%rsp), %ebp
movl %ebp, %edx
callq 0x23be
leaq 0x38(%rsp), %rdi
leaq 0x50(%rsp), %rcx
movl %ebx, %esi
movl %ebp, %edx
pushq $0x7
popq %r8
callq 0x23be
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movl %ebp, %edx
leaq 0x50(%rsp), %rcx
pushq $0x7
popq %r8
callq 0x23be
leaq 0x30(%rsp), %rdi
movl %ebx, %esi
movl %ebp, %edx
leaq 0x90(%rsp), %rcx
pushq $0x7
popq %r8
callq 0x23be
xorl %eax, %eax
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r8
cmpq %rdi, %rax
je 0x2822
xorl %ecx, %ecx
cmpq %rcx, %r8
je 0x281d
movq (%r14,%rax,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movq (%r13,%rax,8), %rsi
addsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
movq (%r15,%rax,8), %rdx
movsd (%rdx,%rcx,8), %xmm0
movq (%r12,%rax,8), %rsi
addsd (%rsi,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0x27e4
incq %rax
jmp 0x27dd
movq %r14, %r13
movq %r15, %rbx
movq %rdi, %r12
movl 0x8(%rsp), %ebp
subq $0x1, %r12
jb 0x2870
movq %r13, %rdi
movl %ebp, %esi
leaq 0x90(%rsp), %rdx
pushq $0x7
popq %rcx
callq 0x22fc
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x50(%rsp), %rdx
pushq $0x7
popq %rcx
callq 0x22fc
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rdi
addq $0x8, %rbx
addq $0x8, %r13
jmp 0x282f
xorl %eax, %eax
movsd 0x17d6(%rip), %xmm0     # 0x4050
cmpq %rdi, %rax
je 0x28b7
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
xorl %edx, %edx
cmpq %rdx, %r8
je 0x28b2
movq (%r14,%rax,8), %rsi
movsd (%rsi,%rdx,8), %xmm1
movq (%r15,%rax,8), %rsi
addsd (%rsi,%rdx,8), %xmm1
movq (%rcx,%rax,8), %rsi
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsi,%rdx,8)
incq %rdx
jmp 0x2889
incq %rax
jmp 0x287a
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq