// File: rishabh-battulwar[P]imageprocessing/./include/ImageProc.h
// Function: ImageProc::color_to_bw(char const*, char const*, int, int)
void ImageProc::color_to_bw(const char *infile, const char *outfile, int width, int height)
{
	Image img_color("color", width, height);	//object for input color image
	Image img_bw("bw", width, height);			//object for output b-&-w image

	img_color.read_image(infile, img_color.cols, img_color.rows);	//reading input image from file

	for(int i = 0; i < img_bw.rows; i++)
		for(int j = 0; j < img_bw.cols; j++)
			for(int k = 0; k < img_bw.channels; k++)
				img_bw.setvalue(i,j,k,((img_color.getvalue(i,j,0)*0.21)\
									  +(img_color.getvalue(i,j,1)*0.72)\
									  +(img_color.getvalue(i,j,2)*0.07))); //using Luminosity formula: grayscale_value = 0.21*R + 0.72*G + 0.07*B

	img_bw.write_image(outfile, img_bw.cols, img_bw.rows);	//writing image to output file
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x10ba2(%rip), %rsi     # 0x1c5e8
leaq -0x38(%rbp), %rdi
callq 0x7eb0
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x11b78(%rip), %rsi     # 0x1d5d4
leaq -0x58(%rbp), %rdi
callq 0x7eb0
jmp 0xba67
movq -0x8(%rbp), %rsi
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
leaq -0x38(%rbp), %rdi
callq 0x7f70
jmp 0xba7c
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0xbbc2
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0xbbb2
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0xbba2
movl -0x68(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x68(%rbp), %esi
movl -0x6c(%rbp), %edx
leaq -0x38(%rbp), %rdi
xorl %ecx, %ecx
callq 0x83b0
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x68(%rbp), %esi
movl -0x6c(%rbp), %edx
leaq -0x38(%rbp), %rdi
movl $0x1, %ecx
callq 0x83b0
movsd -0x90(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
movsd 0x109b4(%rip), %xmm2    # 0x1c4c0
mulsd %xmm2, %xmm1
movsd 0x109a0(%rip), %xmm2    # 0x1c4b8
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x68(%rbp), %esi
movl -0x6c(%rbp), %edx
leaq -0x38(%rbp), %rdi
movl $0x2, %ecx
callq 0x83b0
movsd -0x88(%rbp), %xmm1
movl -0x7c(%rbp), %esi
movl -0x78(%rbp), %edx
movl -0x74(%rbp), %ecx
cvtsi2sd %eax, %xmm0
movsd 0x10957(%rip), %xmm2    # 0x1c4b0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r8d
leaq -0x58(%rbp), %rdi
callq 0x83f0
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0xbaa9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xbbf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x1b2c0
jmp 0xbbf2
jmp 0xbba4
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0xba96
jmp 0xbbb4
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xba83
movq -0x10(%rbp), %rsi
movl -0x50(%rbp), %edx
movl -0x4c(%rbp), %ecx
leaq -0x58(%rbp), %rdi
callq 0x8150
jmp 0xbbd7
leaq -0x58(%rbp), %rdi
callq 0x1b2c0
leaq -0x38(%rbp), %rdi
callq 0x1b2c0
addq $0x90, %rsp
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x1b2c0
movq -0x60(%rbp), %rdi
callq 0x2360
nopw %cs:(%rax,%rax)