// File: /workspace/github_cpp_makefile_star2_O3/kebwi[P]Trifid/src/ImageProcs.cpp
// Function: denoiseRGBImage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void denoiseRGBImage(string filename, string manualShrinkageThresholdStr)
{
	cout << "Denoising color image..." << endl;
	
	//Open the image
	Image3ChnlReal rgbImage;
	rgbImage.readFile(filename);
	
	//Construct a steerable pyramid of the image
	SteerablePyramid steerPyr[3];
	for (int c = 0; c < 3; c++)
		steerPyr[c].DoFullWaveletAnalysis(rgbImage[c]->img(), rgbImage[c]->width(), rgbImage[c]->height(), true);
	
	if (gGenerateIntermediateImages)
	{
		for (int c = 0; c < 3; c++)
		{
			string s = rgbImage.filename();
			if (c == 0)
				s += "_R";
			else if (c == 1)
				s += "_G";
			else s += "_B";
			steerPyr[c].GeneratePGMimages(s.c_str());
		}
	}
	
	int numLevels = steerPyr[0].NumLevels();
	cout << "Steerable pyramid will be built with " << numLevels << " levels" << endl;
	if (gManualShrinkageThresholds[0].size() != numLevels + 1)
		for (int c = 0; c < 3; c++)
			gManualShrinkageThresholds[c].resize(numLevels + 1);
	cout << "Thresholds:" << endl;
	for (int c = 0; c < 3; c++)
	{
		if (c == 0)
			cout << "  Red:" << endl;
		else if (c == 1)
			cout << "  Green:" << endl;
		else cout << "  Blue:" << endl;
		
		cout << "    H:  " << setw(10) << gManualShrinkageThresholds[c][0] << endl;
		cout << "    B:  ";
		for (int i = 1; i < gManualShrinkageThresholds[c].size(); i++)
			cout << setw(10) << gManualShrinkageThresholds[c][i];
		cout << endl;
	}
	cout << endl;
	
	//Shrink the coefficients
	for (int c = 0; c < 3; c++)
		steerPyr[c].SoftThreshold(gManualShrinkageThresholds[c]);
	
	if (gGenerateIntermediateImages)
	{
		for (int c = 0; c < 3; c++)
		{
			string s = rgbImage.filename();
			if (c == 0)
				s += "_R_sk";
			else if (c == 1)
				s += "_G_sk";
			else s += "_B_sk";
			steerPyr[c].GeneratePGMimages(s.c_str());
		}
	}
	
	//Synthesize the steerable pyramid
	Image3ChnlReal rgbImageShrunk(rgbImage.width(), rgbImage.height());
	for (int c = 0; c < 3; c++)
		steerPyr[c].DoFullWaveletSynthesis(rgbImageShrunk[c]->img());
	/*
	stringstream denoiseParamSS;
	denoiseParamSS << "_";
	for (int c = 0; c < 3; c++)
	{
		if (c == 0)
			denoiseParamSS << "R";
		else if (c == 1)
			denoiseParamSS << "G";
		else denoiseParamSS << "B";
		
		denoiseParamSS << gManualShrinkageThresholds[c][0];
		for (int i = 1; i < gManualShrinkageThresholds[c].size(); i++)
			denoiseParamSS << "," << gManualShrinkageThresholds[c][i];
	}
	*/
	rgbImageShrunk.setFilename(rgbImage.filename());
	rgbImageShrunk.appendFilename("_dn");
	rgbImageShrunk.appendFilename(manualShrinkageThresholdStr);
	rgbImageShrunk.writeFile(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %r12
movq %rdi, %r14
movq 0x1ee81(%rip), %rbx     # 0x36fd0
leaq 0x148f3(%rip), %rsi     # 0x2ca49
movl $0x18, %edx
movq %rbx, %rdi
callq 0x3360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0xf0(%rsp), %rdi
callq 0xdf68
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xa92c
leaq 0xf0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xe5f4
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x181ec
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3310
xorl %r14d, %r14d
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1ab34
addq $0x50, %r14
cmpq $0xf0, %r14
jne 0x181ef
leaq 0x160(%rsp), %r14
xorl %ebx, %ebx
movq 0x128(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x38(%rax), %rsi
movl 0x28(%rax), %edx
movl 0x2c(%rax), %ecx
movq %r14, %rdi
movl $0x1, %r8d
callq 0x1d788
incq %rbx
addq $0x50, %r14
cmpq $0x3, %rbx
jne 0x18216
movq %r12, 0x50(%rsp)
leaq 0x1f29e(%rip), %rax     # 0x374f1
cmpb $0x1, (%rax)
jne 0x182eb
leaq 0x10(%rsp), %r15
xorl %ebx, %ebx
movq %rsp, %r14
leaq 0x147f8(%rip), %r12     # 0x2ca65
leaq 0x147f4(%rip), %r13     # 0x2ca68
leaq 0x147e7(%rip), %rbp     # 0x2ca62
movq %r15, (%rsp)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0xa92c
cmpq $0x50, %rbx
movq %r13, %rsi
cmoveq %r12, %rsi
testq %rbx, %rbx
cmoveq %rbp, %rsi
movq %r14, %rdi
callq 0x3540
leaq (%rsp,%rbx), %rdi
addq $0x160, %rdi            # imm = 0x160
movq (%rsp), %rsi
callq 0x1f43c
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x182de
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3310
addq $0x50, %rbx
cmpq $0xf0, %rbx
jne 0x1827b
leaq 0x160(%rsp), %r14
movq %r14, %rdi
callq 0x1c346
movl %eax, %ebp
movq 0x1eccc(%rip), %rdi     # 0x36fd0
leaq 0x14700(%rip), %rsi     # 0x2ca0b
movl $0x25, %edx
callq 0x3360
movq 0x1ecb4(%rip), %rdi     # 0x36fd0
movl %ebp, %esi
callq 0x34e0
movq %rax, %r15
leaq 0x14704(%rip), %rsi     # 0x2ca31
movl $0x7, %edx
movq %rax, %rdi
callq 0x3360
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
leaq 0x1f1e8(%rip), %r15     # 0x37550
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
incl %ebp
movslq %ebp, %r12
cmpq %r12, %rax
je 0x18395
xorl %ebx, %ebx
leaq (%rbx,%r15), %rdi
movq %r12, %rsi
callq 0xa036
addq $0x18, %rbx
cmpq $0x48, %rbx
jne 0x1837f
movq 0x1ec34(%rip), %rbx     # 0x36fd0
leaq 0x14696(%rip), %rsi     # 0x2ca39
movl $0xb, %edx
movq %rbx, %rdi
callq 0x3360
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x1ec02(%rip), %r12     # 0x36fd0
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
xorl %r13d, %r13d
leaq 0x1468a(%rip), %rsi     # 0x2ca72
movl $0x8, %edx
cmpl $0x1, %r13d
je 0x18412
testl %r13d, %r13d
jne 0x18406
movl $0x6, %edx
leaq 0x14667(%rip), %rsi     # 0x2ca6b
jmp 0x18412
movl $0x7, %edx
leaq 0x14669(%rip), %rsi     # 0x2ca7b
movq %r12, %rdi
callq 0x3360
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movl $0x8, %edx
movq %r12, %rdi
leaq 0x14632(%rip), %rsi     # 0x2ca83
callq 0x3360
movq (%r12), %rax
movq -0x18(%rax), %rax
movq $0xa, 0x10(%r12,%rax)
leaq (,%r13,2), %rbp
addq %r13, %rbp
movq (%r15,%rbp,8), %rax
movsd (%rax), %xmm0
movq %r12, %rdi
callq 0x3480
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
movl $0x8, %edx
movq %r12, %rdi
leaq 0x145d1(%rip), %rsi     # 0x2ca8c
callq 0x3360
leaq (%r15,%rbp,8), %rbx
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
cmpq $0x9, %rcx
jb 0x1850d
movl $0x1, %ebp
movq (%r12), %rcx
movq -0x18(%rcx), %rcx
movq $0xa, 0x10(%r12,%rcx)
movsd (%rax,%rbp,8), %xmm0
movq %r12, %rdi
callq 0x3480
incq %rbp
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
ja 0x184d9
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
incq %r13
cmpq $0x3, %r13
jne 0x183e1
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x1ea6f(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
xorl %ebx, %ebx
leaq 0xd8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1214e
leaq (%rsp,%rbx), %rdi
addq $0x160, %rdi            # imm = 0x160
movq %r12, %rsi
callq 0x1e822
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x185b3
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3310
addq $0x18, %r15
addq $0x50, %rbx
cmpq $0xf0, %rbx
jne 0x18578
leaq 0x1ef26(%rip), %rax     # 0x374f1
cmpb $0x1, (%rax)
jne 0x18663
leaq 0x10(%rsp), %r12
xorl %ebx, %ebx
movq %rsp, %r15
leaq 0x144bc(%rip), %rbp     # 0x2caa1
leaq 0x144a9(%rip), %r13     # 0x2ca95
movq %r12, (%rsp)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xa92c
cmpq $0x50, %rbx
movq %rbp, %rsi
leaq 0x14482(%rip), %rax     # 0x2ca9b
cmoveq %rax, %rsi
testq %rbx, %rbx
cmoveq %r13, %rsi
movq %r15, %rdi
callq 0x3540
leaq (%rsp,%rbx), %rdi
addq $0x160, %rdi            # imm = 0x160
movq (%rsp), %rsi
callq 0x1f43c
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x18656
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3310
addq $0x50, %rbx
cmpq $0xf0, %rbx
jne 0x185ec
movl 0x118(%rsp), %esi
movl 0x11c(%rsp), %edx
movq %rsp, %rdi
callq 0xe1b0
xorl %ebx, %ebx
movq 0x50(%rsp), %r15
movq 0x38(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x38(%rax), %rsi
movq %r14, %rdi
callq 0x1e372
incq %rbx
addq $0x50, %r14
cmpq $0x3, %rbx
jne 0x18680
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xa92c
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0xce40
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x186f2
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x14340(%rip), %rsi     # 0x2ca45
leaq 0x1433c(%rip), %rdx     # 0x2ca48
leaq 0xb8(%rsp), %rdi
callq 0xa9c2
movq %rsp, %rdi
leaq 0xb8(%rsp), %rsi
callq 0xce5a
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x18746
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0xa92c
movq %rsp, %rdi
leaq 0x58(%rsp), %rsi
callq 0xce5a
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x18787
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x140(%rsp), %rdi
movq %rsp, %rsi
movl $0x1, %edx
callq 0xea48
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x187bd
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rsp, %rdi
callq 0xe2a6
movl $0xa0, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1aeae
addq $-0x50, %rbx
cmpq $-0x50, %rbx
jne 0x187ca
leaq 0xf0(%rsp), %rdi
callq 0xe2a6
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x188a8
movq 0x68(%rsp), %rsi
jmp 0x1884a
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x188a8
movq 0xc8(%rsp), %rsi
jmp 0x1884a
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x188a8
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x188a8
jmp 0x18911
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x18934
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x18934
movq %rax, %rbx
jmp 0x18934
jmp 0x188a5
jmp 0x18911
jmp 0x18911
jmp 0x18911
jmp 0x18911
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
jne 0x188dd
jmp 0x18914
movq %rax, %rbx
movq %rsp, %rdi
callq 0xe2a6
jmp 0x18914
jmp 0x18911
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x18914
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
jmp 0x188e5
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x18914
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x18914
jmp 0x18911
movq %rax, %rbx
testq %r14, %r14
je 0x18934
leaq 0x110(%rsp), %r15
leaq (%r15,%r14), %rdi
callq 0x1aeae
addq $-0x50, %r14
jne 0x188fe
jmp 0x18934
jmp 0x18911
movq %rax, %rbx
movl $0xa0, %r14d
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1aeae
addq $-0x50, %r14
cmpq $-0x50, %r14
jne 0x1891a
leaq 0xf0(%rsp), %rdi
callq 0xe2a6
movq %rbx, %rdi
callq 0x3500