// File: rishabh-battulwar[P]imageprocessing/./include/ImageProc.h
// Function: ImageProc::halftoning(char const*, int, int)
void ImageProc::halftoning(const char *infile, int width, int height)
{
	Image img_orig("bw", width, height);
	Image img_halftone_fixed_thresh("bw", width, height);
	Image img_halftone_random_thresh("bw", width, height);
	Image img_halftone_dither_matrix_2("bw", width, height);
	Image img_halftone_dither_matrix_4("bw", width, height);
	Image img_halftone_error_diffusion("bw", width, height);
	img_orig.read_image(infile, img_orig.cols, img_orig.rows);

	halftone_fixed_thresh(img_orig, img_halftone_fixed_thresh);
	halftone_random_thresh(img_orig, img_halftone_random_thresh);
	halftone_dither_matrix(img_orig, img_halftone_dither_matrix_2, 2);
	halftone_dither_matrix(img_orig, img_halftone_dither_matrix_4, 4);
	error_diffusion(img_orig, img_halftone_error_diffusion);

	img_halftone_fixed_thresh.write_image("../output_images/halftone_fixed_thresh.raw", img_halftone_fixed_thresh.cols, img_halftone_fixed_thresh.rows);
	img_halftone_random_thresh.write_image("../output_images/halftone_random_thresh.raw", img_halftone_random_thresh.cols, img_halftone_random_thresh.rows);
	img_halftone_dither_matrix_2.write_image("../output_images/halftone_dither_matrix_2x2.raw", img_halftone_dither_matrix_2.cols, img_halftone_dither_matrix_2.rows);
	img_halftone_dither_matrix_4.write_image("../output_images/halftone_dither_matrix_4x4.raw", img_halftone_dither_matrix_4.cols, img_halftone_dither_matrix_4.rows);
	img_halftone_error_diffusion.write_image("../output_images/halftone_error_diffusion.raw", img_halftone_error_diffusion.cols, img_halftone_error_diffusion.rows);
	//img_modified.write_image(outfile, img_modified.cols, img_modified.rows);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xa412(%rip), %rsi      # 0x1d5d4
movq %rsi, -0xe8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7eb0
movq -0xe8(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq -0x50(%rbp), %rdi
callq 0x7eb0
jmp 0x131ea
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xa3dd(%rip), %rsi      # 0x1d5d4
leaq -0x80(%rbp), %rdi
callq 0x7eb0
jmp 0x13202
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xa3c5(%rip), %rsi      # 0x1d5d4
leaq -0xa0(%rbp), %rdi
callq 0x7eb0
jmp 0x1321d
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xa3aa(%rip), %rsi      # 0x1d5d4
leaq -0xc0(%rbp), %rdi
callq 0x7eb0
jmp 0x13238
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq 0xa38f(%rip), %rsi      # 0x1d5d4
leaq -0xe0(%rbp), %rdi
callq 0x7eb0
jmp 0x13253
movq -0x8(%rbp), %rsi
movl -0x28(%rbp), %edx
movl -0x24(%rbp), %ecx
leaq -0x30(%rbp), %rdi
callq 0x7f70
jmp 0x13268
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x13440
jmp 0x13277
leaq -0x30(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x13510
jmp 0x13286
leaq -0x30(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x2, %edx
callq 0x13600
jmp 0x1329d
leaq -0x30(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
movl $0x4, %edx
callq 0x13600
jmp 0x132b4
leaq -0x30(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x13950
jmp 0x132c6
movl -0x48(%rbp), %edx
movl -0x44(%rbp), %ecx
leaq 0x98ef(%rip), %rsi      # 0x1cbc2
leaq -0x50(%rbp), %rdi
callq 0x8150
jmp 0x132de
movl -0x78(%rbp), %edx
movl -0x74(%rbp), %ecx
leaq 0x9902(%rip), %rsi      # 0x1cbed
leaq -0x80(%rbp), %rdi
callq 0x8150
jmp 0x132f6
movl -0x98(%rbp), %edx
movl -0x94(%rbp), %ecx
leaq 0x9910(%rip), %rsi      # 0x1cc19
leaq -0xa0(%rbp), %rdi
callq 0x8150
jmp 0x13317
movl -0xb8(%rbp), %edx
movl -0xb4(%rbp), %ecx
leaq 0x991f(%rip), %rsi      # 0x1cc49
leaq -0xc0(%rbp), %rdi
callq 0x8150
jmp 0x13338
movl -0xd8(%rbp), %edx
movl -0xd4(%rbp), %ecx
leaq 0x992e(%rip), %rsi      # 0x1cc79
leaq -0xe0(%rbp), %rdi
callq 0x8150
jmp 0x13359
leaq -0xe0(%rbp), %rdi
callq 0x1b2c0
leaq -0xc0(%rbp), %rdi
callq 0x1b2c0
leaq -0xa0(%rbp), %rdi
callq 0x1b2c0
leaq -0x80(%rbp), %rdi
callq 0x1b2c0
leaq -0x50(%rbp), %rdi
callq 0x1b2c0
leaq -0x30(%rbp), %rdi
callq 0x1b2c0
addq $0xf0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x13429
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x13420
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x13417
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1340b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x133ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1b2c0
leaq -0xc0(%rbp), %rdi
callq 0x1b2c0
leaq -0xa0(%rbp), %rdi
callq 0x1b2c0
leaq -0x80(%rbp), %rdi
callq 0x1b2c0
leaq -0x50(%rbp), %rdi
callq 0x1b2c0
leaq -0x30(%rbp), %rdi
callq 0x1b2c0
movq -0x58(%rbp), %rdi
callq 0x2360
nopl (%rax,%rax)