// File: /workspace/github_cpp_makefile_star2_O1/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 0x1e95a(%rip), %rbx     # 0x36fd0
leaq 0x153c4(%rip), %rsi     # 0x2da41
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 0xe034
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xa97e
leaq 0xf0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xe6b6
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x18713
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3310
xorl %r14d, %r14d
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1afc0
addq $0x50, %r14
cmpq $0xf0, %r14
jne 0x18716
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 0x1db64
incq %rbx
addq $0x50, %r14
cmpq $0x3, %rbx
jne 0x1873d
movq %r12, 0x50(%rsp)
leaq 0x1ed77(%rip), %rax     # 0x374f1
cmpb $0x1, (%rax)
jne 0x18812
leaq 0x10(%rsp), %r15
xorl %ebx, %ebx
movq %rsp, %r14
leaq 0x152c9(%rip), %r12     # 0x2da5d
leaq 0x152c5(%rip), %r13     # 0x2da60
leaq 0x152b8(%rip), %rbp     # 0x2da5a
movq %r15, (%rsp)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0xa97e
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 0x1f6b0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x18805
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3310
addq $0x50, %rbx
cmpq $0xf0, %rbx
jne 0x187a2
leaq 0x160(%rsp), %r14
movq %r14, %rdi
callq 0x1c844
movl %eax, %ebp
movq 0x1e7a5(%rip), %rdi     # 0x36fd0
leaq 0x151d1(%rip), %rsi     # 0x2da03
movl $0x25, %edx
callq 0x3360
movq 0x1e78d(%rip), %rdi     # 0x36fd0
movl %ebp, %esi
callq 0x34e0
movq %rax, %r15
leaq 0x151d5(%rip), %rsi     # 0x2da29
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 0x1ecc1(%rip), %r15     # 0x37550
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
incl %ebp
movslq %ebp, %r12
cmpq %r12, %rax
je 0x188bc
xorl %ebx, %ebx
leaq (%rbx,%r15), %rdi
movq %r12, %rsi
callq 0xa084
addq $0x18, %rbx
cmpq $0x48, %rbx
jne 0x188a6
movq 0x1e70d(%rip), %rbx     # 0x36fd0
leaq 0x15167(%rip), %rsi     # 0x2da31
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 0x1e6db(%rip), %r12     # 0x36fd0
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31f0
xorl %r13d, %r13d
leaq 0x1515b(%rip), %rsi     # 0x2da6a
movl $0x8, %edx
cmpl $0x1, %r13d
je 0x18939
testl %r13d, %r13d
jne 0x1892d
movl $0x6, %edx
leaq 0x15138(%rip), %rsi     # 0x2da63
jmp 0x18939
movl $0x7, %edx
leaq 0x1513a(%rip), %rsi     # 0x2da73
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 0x15103(%rip), %rsi     # 0x2da7b
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 0x150a2(%rip), %rsi     # 0x2da84
callq 0x3360
leaq (%r15,%rbp,8), %rbx
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
cmpq $0x9, %rcx
jb 0x18a34
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 0x18a00
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 0x18908
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x32e0
movsbl %al, %esi
movq 0x1e548(%rip), %rdi     # 0x36fd0
callq 0x3040
movq %rax, %rdi
callq 0x31f0
xorl %ebx, %ebx
leaq 0xd8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x121b2
leaq (%rsp,%rbx), %rdi
addq $0x160, %rdi            # imm = 0x160
movq %r12, %rsi
callq 0x1eab2
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x18ada
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3310
addq $0x18, %r15
addq $0x50, %rbx
cmpq $0xf0, %rbx
jne 0x18a9f
leaq 0x1e9ff(%rip), %rax     # 0x374f1
cmpb $0x1, (%rax)
jne 0x18b8a
leaq 0x10(%rsp), %r12
xorl %ebx, %ebx
movq %rsp, %r15
leaq 0x14f8d(%rip), %rbp     # 0x2da99
leaq 0x14f7a(%rip), %r13     # 0x2da8d
movq %r12, (%rsp)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xa97e
cmpq $0x50, %rbx
movq %rbp, %rsi
leaq 0x14f53(%rip), %rax     # 0x2da93
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 0x1f6b0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x18b7d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3310
addq $0x50, %rbx
cmpq $0xf0, %rbx
jne 0x18b13
movl 0x118(%rsp), %esi
movl 0x11c(%rsp), %edx
movq %rsp, %rdi
callq 0xe27c
xorl %ebx, %ebx
movq 0x50(%rsp), %r15
movq 0x38(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x38(%rax), %rsi
movq %r14, %rdi
callq 0x1e5f8
incq %rbx
addq $0x50, %r14
cmpq $0x3, %rbx
jne 0x18ba7
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0xa97e
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0xcf04
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x18c19
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x14e11(%rip), %rsi     # 0x2da3d
leaq 0x14e0d(%rip), %rdx     # 0x2da40
leaq 0xb8(%rsp), %rdi
callq 0xaa0e
movq %rsp, %rdi
leaq 0xb8(%rsp), %rsi
callq 0xcf1e
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x18c6d
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 0xa97e
movq %rsp, %rdi
leaq 0x58(%rsp), %rsi
callq 0xcf1e
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x18cae
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3310
leaq 0x140(%rsp), %rdi
movq %rsp, %rsi
movl $0x1, %edx
callq 0xeb0a
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18ce4
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x3310
movq %rsp, %rdi
callq 0xe372
movl $0xa0, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1b33a
addq $-0x50, %rbx
cmpq $-0x50, %rbx
jne 0x18cf1
leaq 0xf0(%rsp), %rdi
callq 0xe372
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 0x18dcf
movq 0x68(%rsp), %rsi
jmp 0x18d71
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x18dcf
movq 0xc8(%rsp), %rsi
jmp 0x18d71
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x18dcf
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x18dcf
jmp 0x18e38
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x18e5b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x18e5b
movq %rax, %rbx
jmp 0x18e5b
jmp 0x18dcc
jmp 0x18e38
jmp 0x18e38
jmp 0x18e38
jmp 0x18e38
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
jne 0x18e04
jmp 0x18e3b
movq %rax, %rbx
movq %rsp, %rdi
callq 0xe372
jmp 0x18e3b
jmp 0x18e38
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x18e3b
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
jmp 0x18e0c
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x18e3b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3310
jmp 0x18e3b
jmp 0x18e38
movq %rax, %rbx
testq %r14, %r14
je 0x18e5b
leaq 0x110(%rsp), %r15
leaq (%r15,%r14), %rdi
callq 0x1b33a
addq $-0x50, %r14
jne 0x18e25
jmp 0x18e5b
jmp 0x18e38
movq %rax, %rbx
movl $0xa0, %r14d
leaq (%rsp,%r14), %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x1b33a
addq $-0x50, %r14
cmpq $-0x50, %r14
jne 0x18e41
leaq 0xf0(%rsp), %rdi
callq 0xe372
movq %rbx, %rdi
callq 0x3500