// File: rishabh-battulwar[P]imageprocessing/./include/ImageProc.h
// Function: ImageProc::film_effect_filter(Image&, Image&)
void ImageProc::film_effect_filter(Image &img_orig, Image &img_modified)
{
	for(int i = 0; i < img_modified.rows; i++)
		for(int j = 0; j < img_modified.cols; j++)
			for(int k = 0; k < img_modified.channels; k++)
			{
				img_modified.setvalue(i,j,k,(255-img_orig.getvalue(i,(img_orig.cols-j),k)));
			}

	int gmax[3] = {255,205,180};
	int gmin[3] = { 80, 30, 20};
	float scaling_factor[3];
	for(int i = 0; i < 3; i++)
		scaling_factor[i] = (gmax[i]-gmin[i]) / 255.0;
	for(int i = 0; i < img_modified.rows; i++)
		for(int j = 0; j < img_modified.cols; j++)
			for(int k = 0; k < img_modified.channels; k++)
			{
				img_modified.setvalue(i,j,k,((img_modified.getvalue(i,j,k)
											  * scaling_factor[k])
											  + gmin[k]));
			}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0xd089
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd079
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0xd069
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edx
subl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
callq 0x83b0
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %esi
movl -0x58(%rbp), %edx
movl -0x54(%rbp), %ecx
movl $0xff, %r8d
subl %eax, %r8d
callq 0x83f0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd004
jmp 0xd06b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xcff1
jmp 0xd07b
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xcfda
movq 0xf520(%rip), %rax      # 0x1c5b0
movq %rax, -0x28(%rbp)
movl 0xf51e(%rip), %eax      # 0x1c5b8
movl %eax, -0x20(%rbp)
movq 0xf518(%rip), %rax      # 0x1c5bc
movq %rax, -0x34(%rbp)
movl 0xf516(%rip), %eax      # 0x1c5c4
movl %eax, -0x2c(%rbp)
movl $0x0, -0x44(%rbp)
cmpl $0x3, -0x44(%rbp)
jge 0xd0f7
movslq -0x44(%rbp), %rax
movl -0x28(%rbp,%rax,4), %eax
movslq -0x44(%rbp), %rcx
subl -0x34(%rbp,%rcx,4), %eax
cvtsi2sd %eax, %xmm0
movsd 0xf3ee(%rip), %xmm1     # 0x1c4c8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movslq -0x44(%rbp), %rax
movss %xmm0, -0x40(%rbp,%rax,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xd0b8
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0xd1c6
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0xd1b6
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0xd1a6
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x50(%rbp), %ecx
callq 0x83b0
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %esi
movl -0x70(%rbp), %edx
movl -0x6c(%rbp), %ecx
cvtsi2ss %eax, %xmm0
movslq -0x50(%rbp), %rax
movss -0x40(%rbp,%rax,4), %xmm2
movslq -0x50(%rbp), %rax
cvtsi2ssl -0x34(%rbp,%rax,4), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvttss2si %xmm0, %r8d
callq 0x83f0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xd12c
jmp 0xd1a8
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xd115
jmp 0xd1b8
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xd0fe
addq $0x80, %rsp
popq %rbp
retq
nop