
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
#include "Image.cuh"

using namespace std;

int readImage(char*, Image&);
int writeImage(char*, Image&);
int readImageHeader(char fname[], int& N, int& M, int& Q, bool& type);

int main(int argc, char* args[]) {
	int scale = 1;
	if (argc < 3) {
		std::cerr << "USAGE: " << args[0] << " INPUT_FILE OUTPUT_FILE [ENLARGE_SIZE]" << std::endl;
		return 1;
	}

	if (argc > 3) {
		scale = atoi(args[3]);
	}

	int N, M, Q;
	bool type;

	readImageHeader(args[1], N, M, Q, type);

	Image img(N, M, Q);
	cout << "Reading: " << args[1] << endl;
	readImage(args[1], img);


	if (scale > 1) {
		cout << "Scaling by a factor of:" << scale << endl;
		img.enlargeImage(scale, img);
	}

	cout << "Negating image" << endl;

	img.negateImage(img);

	cout << "Reflecting image" << endl;

	img.reflectImage(false, img);

	cout << "Writing: " << args[2] << endl;
	writeImage(args[2], img);

	return 0;
}

int readImageHeader(char fname[], int& N, int& M, int& Q, bool& type)
{
	int i, j;
	unsigned char *charImage;
	char header[100], *ptr;
	ifstream ifp;

	ifp.open(fname, ios::in | ios::binary);

	if (!ifp)
	{
		cout << "Can't read image: " << fname << endl;
		exit(1);
	}

	// read header

	type = false; // PGM

	ifp.getline(header, 100, '\n');
	if ((header[0] == 80) && (header[1] == 53))
	{
		type = false;
	}
	else if ((header[0] == 80) && (header[1] == 54))
	{
		type = true;
	}
	else
	{
		cout << "Image " << fname << " is not PGM or PPM" << endl;
		exit(1);
	}

	ifp.getline(header, 100, '\n');
	while (header[0] == '#')
		ifp.getline(header, 100, '\n');

	M = strtol(header, &ptr, 0);
	N = atoi(ptr);

	ifp.getline(header, 100, '\n');

	Q = strtol(header, &ptr, 0);

	ifp.close();

	return(1);
}

int readImage(char fname[], Image& image)
{
	int i, j;
	int N, M, Q;
	unsigned char *charImage;
	int* intImage;
	char header[100], *ptr;
	ifstream ifp;

	ifp.open(fname, ios::in | ios::binary);

	if (!ifp)
	{
		cout << "Can't read image: " << fname << endl;
		exit(1);
	}

	// read header

	ifp.getline(header, 100, '\n');
	if ((header[0] != 80) || (header[1] != 53))
	{
		cout << "Image " << fname << " is not PGM" << endl;
		exit(1);
	}

	ifp.getline(header, 100, '\n');
	while (header[0] == '#')
		ifp.getline(header, 100, '\n');

	M = strtol(header, &ptr, 0);
	N = atoi(ptr);

	ifp.getline(header, 100, '\n');
	Q = strtol(header, &ptr, 0);

	charImage = (unsigned char *) new unsigned char[M*N];
	intImage = new int[M * N];

	ifp.read(reinterpret_cast<char *>(charImage), (M*N) * sizeof(unsigned char));

	if (ifp.fail())
	{
		cout << "Image " << fname << " has wrong size" << endl;
		exit(1);
	}

	ifp.close();

	//
	// Convert the unsigned characters to integers
	//

	int idx;

	for (i = 0; i<N; i++)
		for (j = 0; j<M; j++)
		{
			idx = i*M + j;
			intImage[idx] = (int)charImage[idx];
		}

	image.setPixels(0,0,M * N, intImage);
	delete[] charImage;
	delete[] intImage;

	return (1);

}

int writeImage(char fname[], Image& image)
{
	int i, j;
	int N, M, Q;
	unsigned char *charImage;
	int* intImage;
	ofstream ofp;

	image.getImageInfo(N, M, Q);

	charImage = (unsigned char *) new unsigned char[M*N];
	intImage = new int[M * N];
	image.getPixels(0,0,M * N, intImage); // get rgb pixels
	
	// convert the integer values to unsigned char

	int idx;

	for (i = 0; i<N; i++)
	{
		for (j = 0; j<M; j++)
		{
			idx = i*M + j;
			charImage[idx] = (unsigned char)intImage[idx];
		}
	}

	ofp.open(fname, ios::out | ios::binary);

	if (!ofp)
	{
		cout << "Can't open file: " << fname << endl;
		exit(1);
	}

	ofp << "P5" << endl;
	ofp << M << " " << N << endl;
	ofp << Q << endl;

	ofp.write(reinterpret_cast<char *>(charImage), (M*N) * sizeof(unsigned char));

	if (ofp.fail())
	{
		cout << "Can't write image " << fname << endl;
		exit(0);
	}

	ofp.close();

	delete[] charImage;
	delete[] intImage;
	
	return(1);

}
	.file	"tmpxft_0025f50d_00000000-6_kernel.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3772:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3772:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4494:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4494:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3795:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3795:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Can't read image: "
.LC1:
	.string	"Image "
.LC2:
	.string	" is not PGM or PPM"
	.text
	.globl	_Z15readImageHeaderPcRiS0_S0_Rb
	.type	_Z15readImageHeaderPcRiS0_S0_Rb, @function
_Z15readImageHeaderPcRiS0_S0_Rb:
.LFB3767:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3767
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r8, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$664, %rsp
	.cfi_def_cfa_offset 720
	movq	%fs:40, %rax
	movq	%rax, 648(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB0:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	movq	8(%rsp), %rdi
	movl	$12, %edx
	movq	%rbp, %rsi
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	testb	$5, 312(%rsp)
	je	.L6
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%rbp, %rsi
.L25:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %edi
	call	exit@PLT
.L6:
	movb	$0, (%r12)
	movq	8(%rsp), %rdi
	movl	$10, %ecx
	leaq	548(%rsp), %rbx
	movl	$100, %edx
	movq	%rbx, %rsi
	call	_ZNSi7getlineEPclc@PLT
	cmpb	$80, 548(%rsp)
	jne	.L7
	movb	549(%rsp), %dl
	cmpb	$53, %dl
	je	.L15
	movb	$1, %al
	cmpb	$54, %dl
	je	.L8
.L7:
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%rbp, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	leaq	.LC2(%rip), %rsi
	jmp	.L25
.L15:
	xorl	%eax, %eax
.L8:
	movb	%al, (%r12)
.L11:
	movq	8(%rsp), %rdi
	movl	$10, %ecx
	movl	$100, %edx
	movq	%rbx, %rsi
	call	_ZNSi7getlineEPclc@PLT
	cmpb	$35, 548(%rsp)
	je	.L11
	leaq	16(%rsp), %rbp
	xorl	%edx, %edx
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	call	__isoc23_strtol@PLT
	movq	16(%rsp), %rdi
	movl	%eax, (%r15)
	call	atoi@PLT
	movq	8(%rsp), %rdi
	movl	$10, %ecx
	movq	%rbx, %rsi
	movl	%eax, (%r14)
	movl	$100, %edx
	call	_ZNSi7getlineEPclc@PLT
	movq	%rbx, %rdi
	xorl	%edx, %edx
	movq	%rbp, %rsi
	call	__isoc23_strtol@PLT
	movq	8(%rsp), %rdi
	movl	%eax, 0(%r13)
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE1:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	648(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	jmp	.L19
.L17:
	endbr64
	movq	%rax, %rbx
.L12:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	648(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L19:
	call	__stack_chk_fail@PLT
.L14:
	addq	$664, %rsp
	.cfi_def_cfa_offset 56
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3767:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3767:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3767-.LLSDACSB3767
.LLSDACSB3767:
	.uleb128 .LEHB0-.LFB3767
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3767
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L17-.LFB3767
	.uleb128 0
	.uleb128 .LEHB2-.LFB3767
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3767:
	.text
	.size	_Z15readImageHeaderPcRiS0_S0_Rb, .-_Z15readImageHeaderPcRiS0_S0_Rb
	.section	.rodata.str1.1
.LC3:
	.string	" is not PGM"
.LC4:
	.string	" has wrong size"
	.text
	.globl	_Z9readImagePcR5Image
	.type	_Z9readImagePcR5Image, @function
_Z9readImagePcR5Image:
.LFB3768:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3768
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$680, %rsp
	.cfi_def_cfa_offset 736
	movq	%rdi, 8(%rsp)
	movq	%rsi, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 664(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
.LEHB3:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE3:
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdi
	movl	$12, %edx
.LEHB4:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	testb	$5, 328(%rsp)
	je	.L28
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rsi
	movq	%rax, %rdi
.L55:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %edi
	call	exit@PLT
.L28:
	movq	(%rsp), %rdi
	movl	$10, %ecx
	movl	$100, %edx
	leaq	564(%rsp), %rbp
	movq	%rbp, %rsi
	call	_ZNSi7getlineEPclc@PLT
	cmpb	$80, 564(%rsp)
	jne	.L29
	cmpb	$53, 565(%rsp)
	je	.L33
.L29:
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	leaq	.LC3(%rip), %rsi
	jmp	.L55
.L58:
	cmpb	$35, 564(%rsp)
	jne	.L57
.L33:
	movq	(%rsp), %rdi
	movl	$10, %ecx
	movl	$100, %edx
	movq	%rbp, %rsi
	call	_ZNSi7getlineEPclc@PLT
	jmp	.L58
.L57:
	leaq	32(%rsp), %r12
	xorl	%edx, %edx
	movq	%rbp, %rdi
	movq	%r12, %rsi
	call	__isoc23_strtol@PLT
	movq	32(%rsp), %rdi
	movq	%rax, %rbx
	movl	%eax, %r15d
	call	atoi@PLT
	movq	(%rsp), %rdi
	movl	$10, %ecx
	movq	%rbp, %rsi
	movl	$100, %edx
	movl	%eax, %r14d
	call	_ZNSi7getlineEPclc@PLT
	movq	%rbp, %rdi
	xorl	%edx, %edx
	movq	%r12, %rsi
	call	__isoc23_strtol@PLT
	movl	%r14d, %eax
	imull	%ebx, %eax
	movslq	%eax, %rbp
	movl	%eax, 20(%rsp)
	movq	%rbp, %rdi
	call	_Znam@PLT
	movq	%rax, %r13
	movabsq	$2305843009213693950, %rax
	cmpq	%rbp, %rax
	jb	.L34
	leaq	0(,%rbp,4), %rdi
	call	_Znam@PLT
	movq	(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movq	%rax, %r12
	call	_ZNSi4readEPcl@PLT
	jmp	.L59
.L34:
	movq	664(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L47
	call	__cxa_throw_bad_array_new_length@PLT
.L59:
	movl	328(%rsp), %ebp
	andl	$5, %ebp
	je	.L37
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	leaq	.LC4(%rip), %rsi
	jmp	.L55
.L37:
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
	xorl	%ecx, %ecx
.L38:
	cmpl	%r14d, %ebp
	jge	.L40
	movslq	%ecx, %rdx
	xorl	%eax, %eax
	leaq	(%r12,%rdx,4), %rsi
	addq	%r13, %rdx
.L41:
	cmpl	%eax, %r15d
	jle	.L60
	movzbl	(%rdx,%rax), %edi
	movl	%edi, (%rsi,%rax,4)
	incq	%rax
	jmp	.L41
.L60:
	incl	%ebp
	addl	%ebx, %ecx
	jmp	.L38
.L40:
	movl	20(%rsp), %ecx
	movq	24(%rsp), %rdi
	movq	%r12, %r8
	xorl	%edx, %edx
	xorl	%esi, %esi
	call	_ZN5Image9setPixelsEiiiPi@PLT
.LEHE4:
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	664(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	jmp	.L47
.L45:
	endbr64
	movq	%rax, %rbx
.L42:
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	664(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L47
	movq	%rbx, %rdi
.LEHB5:
	call	_Unwind_Resume@PLT
.LEHE5:
.L47:
	call	__stack_chk_fail@PLT
.L44:
	addq	$680, %rsp
	.cfi_def_cfa_offset 56
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3768:
	.section	.gcc_except_table
.LLSDA3768:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3768-.LLSDACSB3768
.LLSDACSB3768:
	.uleb128 .LEHB3-.LFB3768
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB4-.LFB3768
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L45-.LFB3768
	.uleb128 0
	.uleb128 .LEHB5-.LFB3768
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
.LLSDACSE3768:
	.text
	.size	_Z9readImagePcR5Image, .-_Z9readImagePcR5Image
	.section	.rodata.str1.1
.LC5:
	.string	"Can't open file: "
.LC6:
	.string	"P5"
.LC7:
	.string	" "
.LC8:
	.string	"Can't write image "
	.text
	.globl	_Z10writeImagePcR5Image
	.type	_Z10writeImagePcR5Image, @function
_Z10writeImagePcR5Image:
.LFB3769:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3769
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$544, %rsp
	.cfi_def_cfa_offset 592
	movq	%fs:40, %rax
	movq	%rax, 536(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rbx
	movq	%rbx, %rdi
.LEHB6:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE6:
	leaq	20(%rsp), %rcx
	leaq	16(%rsp), %rdx
	movq	%r13, %rdi
	leaq	12(%rsp), %rsi
.LEHB7:
	call	_ZN5Image12getImageInfoERiS0_S0_@PLT
	movl	16(%rsp), %edi
	imull	12(%rsp), %edi
	movslq	%edi, %rdi
	call	_Znam@PLT
	movl	16(%rsp), %edi
	imull	12(%rsp), %edi
	movq	%rax, %rbp
	movabsq	$2305843009213693950, %rax
	movslq	%edi, %rdi
	cmpq	%rdi, %rax
	jb	.L62
	salq	$2, %rdi
	call	_Znam@PLT
	movl	16(%rsp), %ecx
	imull	12(%rsp), %ecx
	movq	%rax, %r8
	xorl	%edx, %edx
	xorl	%esi, %esi
	movq	%r13, %rdi
	movq	%rax, %r14
	call	_ZN5Image9getPixelsEiiiPi@PLT
	movl	12(%rsp), %r9d
	movl	16(%rsp), %edi
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	jmp	.L65
.L62:
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	call	__cxa_throw_bad_array_new_length@PLT
.L80:
	incl	%esi
	addl	%edi, %ecx
.L65:
	cmpl	%esi, %r9d
	jle	.L67
	movslq	%ecx, %rdx
	xorl	%eax, %eax
	leaq	(%r14,%rdx,4), %r8
	addq	%rbp, %rdx
.L68:
	cmpl	%eax, %edi
	jle	.L80
	movl	(%r8,%rax,4), %r10d
	movb	%r10b, (%rdx,%rax)
	incq	%rax
	jmp	.L68
.L67:
	movl	$20, %edx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	testb	$5, 304(%rsp)
	je	.L69
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%r12, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %edi
	jmp	.L79
.L69:
	leaq	.LC6(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	16(%rsp), %esi
	movq	%rbx, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leaq	.LC7(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	12(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	20(%rsp), %esi
	movq	%rbx, %rdi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	16(%rsp), %edx
	imull	12(%rsp), %edx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	movslq	%edx, %rdx
	call	_ZNSo5writeEPKcl@PLT
	testb	$5, 304(%rsp)
	je	.L70
	leaq	.LC8(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movq	%r12, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	xorl	%edi, %edi
.L79:
	call	exit@PLT
.L70:
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE7:
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	movq	%r14, %rdi
	call	_ZdaPv@PLT
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	je	.L73
	jmp	.L76
.L74:
	endbr64
	movq	%rax, %rbp
.L71:
	movq	%rbx, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	movq	%rbp, %rdi
.LEHB8:
	call	_Unwind_Resume@PLT
.LEHE8:
.L76:
	call	__stack_chk_fail@PLT
.L73:
	addq	$544, %rsp
	.cfi_def_cfa_offset 48
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3769:
	.section	.gcc_except_table
.LLSDA3769:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3769-.LLSDACSB3769
.LLSDACSB3769:
	.uleb128 .LEHB6-.LFB3769
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB7-.LFB3769
	.uleb128 .LEHE7-.LEHB7
	.uleb128 .L74-.LFB3769
	.uleb128 0
	.uleb128 .LEHB8-.LFB3769
	.uleb128 .LEHE8-.LEHB8
	.uleb128 0
	.uleb128 0
.LLSDACSE3769:
	.text
	.size	_Z10writeImagePcR5Image, .-_Z10writeImagePcR5Image
	.section	.rodata.str1.1
.LC9:
	.string	"USAGE: "
.LC10:
	.string	" INPUT_FILE OUTPUT_FILE [ENLARGE_SIZE]"
.LC11:
	.string	"Reading: "
.LC12:
	.string	"Negating image"
.LC13:
	.string	"Scaling by a factor of:"
.LC14:
	.string	"Reflecting image"
.LC15:
	.string	"Writing: "
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3766:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3766
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	jg	.L82
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
.LEHB9:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	0(%rbp), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC10(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %eax
	jmp	.L81
.L82:
	movl	$1, %r12d
	cmpl	$3, %edi
	je	.L84
	movq	24(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %r12d
.L84:
	movq	8(%rbp), %rdi
	leaq	12(%rsp), %rcx
	leaq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	leaq	3(%rsp), %r8
	call	_Z15readImageHeaderPcRiS0_S0_Rb
	leaq	16(%rsp), %rbx
	movl	4(%rsp), %esi
	movl	12(%rsp), %ecx
	movl	8(%rsp), %edx
	movq	%rbx, %rdi
	leaq	_ZSt4cout(%rip), %r13
	call	_ZN5ImageC1Eiii@PLT
.LEHE9:
	leaq	.LC11(%rip), %rsi
	movq	%r13, %rdi
.LEHB10:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	8(%rbp), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	8(%rbp), %rdi
	movq	%rbx, %rsi
	call	_Z9readImagePcR5Image
	cmpl	$1, %r12d
	jg	.L85
.L87:
	leaq	.LC12(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L96
.L85:
	leaq	.LC13(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	%r12d, %esi
	call	_ZNSolsEi@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%rbx, %rdx
	movl	%r12d, %esi
	movq	%rbx, %rdi
	call	_ZN5Image12enlargeImageEiRS_@PLT
	jmp	.L87
.L96:
	movq	%rbx, %rsi
	movq	%rbx, %rdi
	call	_ZN5Image11negateImageERS_@PLT
	leaq	.LC14(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%rbx, %rdx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	_ZN5Image12reflectImageEbRS_@PLT
	leaq	.LC15(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	16(%rbp), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	16(%rbp), %rdi
	movq	%rbx, %rsi
	call	_Z10writeImagePcR5Image
.LEHE10:
	movq	%rbx, %rdi
	call	_ZN5ImageD1Ev@PLT
	xorl	%eax, %eax
	jmp	.L81
.L92:
	endbr64
	movq	%rax, %rbp
.L88:
	movq	%rbx, %rdi
	call	_ZN5ImageD1Ev@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L95
	movq	%rbp, %rdi
.LEHB11:
	call	_Unwind_Resume@PLT
.LEHE11:
.L81:
	movq	40(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L90
.L95:
	call	__stack_chk_fail@PLT
.L90:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3766:
	.section	.gcc_except_table
.LLSDA3766:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3766-.LLSDACSB3766
.LLSDACSB3766:
	.uleb128 .LEHB9-.LFB3766
	.uleb128 .LEHE9-.LEHB9
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB10-.LFB3766
	.uleb128 .LEHE10-.LEHB10
	.uleb128 .L92-.LFB3766
	.uleb128 0
	.uleb128 .LEHB11-.LFB3766
	.uleb128 .LEHE11-.LEHB11
	.uleb128 0
	.uleb128 0
.LLSDACSE3766:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include "hip/hip_runtime.h"


#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cstdlib>
#include "Image.cuh"

using namespace std;

int readImage(char*, Image&);
int writeImage(char*, Image&);
int readImageHeader(char fname[], int& N, int& M, int& Q, bool& type);

int main(int argc, char* args[]) {
	int scale = 1;
	if (argc < 3) {
		std::cerr << "USAGE: " << args[0] << " INPUT_FILE OUTPUT_FILE [ENLARGE_SIZE]" << std::endl;
		return 1;
	}

	if (argc > 3) {
		scale = atoi(args[3]);
	}

	int N, M, Q;
	bool type;

	readImageHeader(args[1], N, M, Q, type);

	Image img(N, M, Q);
	cout << "Reading: " << args[1] << endl;
	readImage(args[1], img);


	if (scale > 1) {
		cout << "Scaling by a factor of:" << scale << endl;
		img.enlargeImage(scale, img);
	}

	cout << "Negating image" << endl;

	img.negateImage(img);

	cout << "Reflecting image" << endl;

	img.reflectImage(false, img);

	cout << "Writing: " << args[2] << endl;
	writeImage(args[2], img);

	return 0;
}

int readImageHeader(char fname[], int& N, int& M, int& Q, bool& type)
{
	int i, j;
	unsigned char *charImage;
	char header[100], *ptr;
	ifstream ifp;

	ifp.open(fname, ios::in | ios::binary);

	if (!ifp)
	{
		cout << "Can't read image: " << fname << endl;
		exit(1);
	}

	// read header

	type = false; // PGM

	ifp.getline(header, 100, '\n');
	if ((header[0] == 80) && (header[1] == 53))
	{
		type = false;
	}
	else if ((header[0] == 80) && (header[1] == 54))
	{
		type = true;
	}
	else
	{
		cout << "Image " << fname << " is not PGM or PPM" << endl;
		exit(1);
	}

	ifp.getline(header, 100, '\n');
	while (header[0] == '#')
		ifp.getline(header, 100, '\n');

	M = strtol(header, &ptr, 0);
	N = atoi(ptr);

	ifp.getline(header, 100, '\n');

	Q = strtol(header, &ptr, 0);

	ifp.close();

	return(1);
}

int readImage(char fname[], Image& image)
{
	int i, j;
	int N, M, Q;
	unsigned char *charImage;
	int* intImage;
	char header[100], *ptr;
	ifstream ifp;

	ifp.open(fname, ios::in | ios::binary);

	if (!ifp)
	{
		cout << "Can't read image: " << fname << endl;
		exit(1);
	}

	// read header

	ifp.getline(header, 100, '\n');
	if ((header[0] != 80) || (header[1] != 53))
	{
		cout << "Image " << fname << " is not PGM" << endl;
		exit(1);
	}

	ifp.getline(header, 100, '\n');
	while (header[0] == '#')
		ifp.getline(header, 100, '\n');

	M = strtol(header, &ptr, 0);
	N = atoi(ptr);

	ifp.getline(header, 100, '\n');
	Q = strtol(header, &ptr, 0);

	charImage = (unsigned char *) new unsigned char[M*N];
	intImage = new int[M * N];

	ifp.read(reinterpret_cast<char *>(charImage), (M*N) * sizeof(unsigned char));

	if (ifp.fail())
	{
		cout << "Image " << fname << " has wrong size" << endl;
		exit(1);
	}

	ifp.close();

	//
	// Convert the unsigned characters to integers
	//

	int idx;

	for (i = 0; i<N; i++)
		for (j = 0; j<M; j++)
		{
			idx = i*M + j;
			intImage[idx] = (int)charImage[idx];
		}

	image.setPixels(0,0,M * N, intImage);
	delete[] charImage;
	delete[] intImage;

	return (1);

}

int writeImage(char fname[], Image& image)
{
	int i, j;
	int N, M, Q;
	unsigned char *charImage;
	int* intImage;
	ofstream ofp;

	image.getImageInfo(N, M, Q);

	charImage = (unsigned char *) new unsigned char[M*N];
	intImage = new int[M * N];
	image.getPixels(0,0,M * N, intImage); // get rgb pixels
	
	// convert the integer values to unsigned char

	int idx;

	for (i = 0; i<N; i++)
	{
		for (j = 0; j<M; j++)
		{
			idx = i*M + j;
			charImage[idx] = (unsigned char)intImage[idx];
		}
	}

	ofp.open(fname, ios::out | ios::binary);

	if (!ofp)
	{
		cout << "Can't open file: " << fname << endl;
		exit(1);
	}

	ofp << "P5" << endl;
	ofp << M << " " << N << endl;
	ofp << Q << endl;

	ofp.write(reinterpret_cast<char *>(charImage), (M*N) * sizeof(unsigned char));

	if (ofp.fail())
	{
		cout << "Can't write image " << fname << endl;
		exit(0);
	}

	ofp.close();

	delete[] charImage;
	delete[] intImage;
	
	return(1);

}
	.text
	.file	"kernel.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	cmpl	$2, %edi
	jg	.LBB0_5
# %bb.1:
	movl	$_ZSt4cerr, %edi
	movl	$.L.str, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB0_2
# %bb.3:
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB0_4
.LBB0_5:
	movl	$1, %ebp
	cmpl	$3, %edi
	je	.LBB0_7
# %bb.6:
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
.LBB0_7:
	movq	8(%rbx), %rdi
	leaq	44(%rsp), %r14
	leaq	40(%rsp), %r15
	leaq	36(%rsp), %r12
	leaq	7(%rsp), %r8
	movq	%r14, %rsi
	movq	%r15, %rdx
	movq	%r12, %rcx
	callq	_Z15readImageHeaderPcRiS0_S0_Rb
	movl	(%r14), %esi
	movl	(%r15), %edx
	movl	(%r12), %ecx
	leaq	8(%rsp), %rdi
	callq	_ZN5ImageC1Eiii
.Ltmp0:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp1:
# %bb.8:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit16
	movq	8(%rbx), %r14
	testq	%r14, %r14
	je	.LBB0_9
# %bb.10:
	movq	%r14, %rdi
	callq	strlen
.Ltmp2:
	movl	$_ZSt4cout, %edi
	movq	%r14, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp3:
	jmp	.LBB0_11
.LBB0_2:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB0_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movl	$_ZSt4cerr, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.1, %esi
	movl	$38, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$1, %eax
	jmp	.LBB0_41
.LBB0_9:
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cout(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
.Ltmp4:
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.Ltmp5:
.LBB0_11:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit19
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp6:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp7:
# %bb.12:                               # %.noexc41
.Ltmp8:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp9:
# %bb.13:                               # %.noexc42
.Ltmp10:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp11:
# %bb.14:                               # %_ZNSolsEPFRSoS_E.exit
	movq	8(%rbx), %rdi
.Ltmp12:
	leaq	8(%rsp), %rsi
	callq	_Z9readImagePcR5Image
.Ltmp13:
# %bb.15:
	cmpl	$2, %ebp
	jl	.LBB0_22
# %bb.16:
.Ltmp14:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$23, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp15:
# %bb.17:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit22
.Ltmp16:
	movl	$_ZSt4cout, %edi
	movl	%ebp, %esi
	callq	_ZNSolsEi
.Ltmp17:
# %bb.18:
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp18:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp19:
# %bb.19:                               # %.noexc44
.Ltmp20:
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp21:
# %bb.20:                               # %.noexc45
.Ltmp22:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp23:
# %bb.21:                               # %_ZNSolsEPFRSoS_E.exit24
.Ltmp24:
	leaq	8(%rsp), %rdi
	movl	%ebp, %esi
	movq	%rdi, %rdx
	callq	_ZN5Image12enlargeImageEiRS_
.Ltmp25:
.LBB0_22:
.Ltmp26:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$14, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp27:
# %bb.23:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit26
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %r14
.Ltmp28:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp29:
# %bb.24:                               # %.noexc48
.Ltmp30:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp31:
# %bb.25:                               # %.noexc49
.Ltmp32:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp33:
# %bb.26:                               # %_ZNSolsEPFRSoS_E.exit28
.Ltmp34:
	leaq	8(%rsp), %rdi
	movq	%rdi, %rsi
	callq	_ZN5Image11negateImageERS_
.Ltmp35:
# %bb.27:
.Ltmp36:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$16, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp37:
# %bb.28:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit30
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %r14
.Ltmp38:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp39:
# %bb.29:                               # %.noexc52
.Ltmp40:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp41:
# %bb.30:                               # %.noexc53
.Ltmp42:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp43:
# %bb.31:                               # %_ZNSolsEPFRSoS_E.exit32
.Ltmp44:
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rdi, %rdx
	callq	_ZN5Image12reflectImageEbRS_
.Ltmp45:
# %bb.32:
.Ltmp46:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp47:
# %bb.33:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit34
	movq	16(%rbx), %r14
	testq	%r14, %r14
	je	.LBB0_34
# %bb.35:
	movq	%r14, %rdi
	callq	strlen
.Ltmp48:
	movl	$_ZSt4cout, %edi
	movq	%r14, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp49:
	jmp	.LBB0_36
.LBB0_34:
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cout(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
.Ltmp50:
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.Ltmp51:
.LBB0_36:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit38
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %edi
	addq	-24(%rax), %rdi
.Ltmp52:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp53:
# %bb.37:                               # %.noexc56
.Ltmp54:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp55:
# %bb.38:                               # %.noexc57
.Ltmp56:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp57:
# %bb.39:                               # %_ZNSolsEPFRSoS_E.exit40
	movq	16(%rbx), %rdi
.Ltmp58:
	leaq	8(%rsp), %rsi
	callq	_Z10writeImagePcR5Image
.Ltmp59:
# %bb.40:
	leaq	8(%rsp), %rdi
	callq	_ZN5ImageD1Ev
	xorl	%eax, %eax
.LBB0_41:
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB0_42:
	.cfi_def_cfa_offset 96
.Ltmp60:
	movq	%rax, %rbx
	leaq	8(%rsp), %rdi
	callq	_ZN5ImageD1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp3-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp3
	.uleb128 .Ltmp60-.Lfunc_begin0          #     jumps to .Ltmp60
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp4-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp59-.Ltmp4                 #   Call between .Ltmp4 and .Ltmp59
	.uleb128 .Ltmp60-.Lfunc_begin0          #     jumps to .Ltmp60
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp59-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Lfunc_end0-.Ltmp59            #   Call between .Ltmp59 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z15readImageHeaderPcRiS0_S0_Rb # -- Begin function _Z15readImageHeaderPcRiS0_S0_Rb
	.type	_Z15readImageHeaderPcRiS0_S0_Rb,@function
_Z15readImageHeaderPcRiS0_S0_Rb:        # @_Z15readImageHeaderPcRiS0_S0_Rb
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$648, %rsp                      # imm = 0x288
	.cfi_def_cfa_offset 704
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r8, %r13
	movq	%rcx, %rbx
	movq	%rdx, %r15
	movq	%rsi, %r14
	movq	%rdi, %r12
	leaq	128(%rsp), %rbp
	movq	%rbp, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
.Ltmp61:
	movq	%rbp, %rdi
	movq	%r12, %rsi
	movl	$12, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp62:
# %bb.1:
	movq	128(%rsp), %rax
	movq	-24(%rax), %rax
	testb	$5, 160(%rsp,%rax)
	jne	.LBB1_2
# %bb.9:
	movb	$0, (%r13)
.Ltmp69:
	leaq	128(%rsp), %rdi
	leaq	16(%rsp), %rsi
	movl	$100, %edx
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp70:
# %bb.10:
	movb	16(%rsp), %cl
	movb	17(%rsp), %al
	cmpb	$80, %cl
	jne	.LBB1_17
# %bb.11:
	cmpb	$53, %al
	jne	.LBB1_17
# %bb.12:
	xorl	%ecx, %ecx
	jmp	.LBB1_13
.LBB1_17:
	cmpb	$80, %cl
	jne	.LBB1_19
# %bb.18:
	movb	$1, %cl
	cmpb	$54, %al
	jne	.LBB1_19
.LBB1_13:
	movb	%cl, (%r13)
.Ltmp79:
	leaq	128(%rsp), %rdi
	leaq	16(%rsp), %rsi
	movl	$100, %edx
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp80:
# %bb.14:                               # %.preheader.preheader
	leaq	128(%rsp), %r12
	leaq	16(%rsp), %r13
.LBB1_15:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	cmpb	$35, 16(%rsp)
	jne	.LBB1_23
# %bb.16:                               #   in Loop: Header=BB1_15 Depth=1
.Ltmp86:
	movl	$100, %edx
	movq	%r12, %rdi
	movq	%r13, %rsi
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp87:
	jmp	.LBB1_15
.LBB1_23:
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r12, %rdi
	movq	%r13, %rsi
	xorl	%edx, %edx
	callq	__isoc23_strtol
	movl	%eax, (%r15)
	movq	(%r13), %rdi
	callq	atoi
	movl	%eax, (%r14)
.Ltmp81:
	leaq	128(%rsp), %rdi
	movl	$100, %edx
	movq	%r12, %rsi
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp82:
# %bb.24:
	leaq	16(%rsp), %rdi
	leaq	8(%rsp), %rsi
	xorl	%edx, %edx
	callq	__isoc23_strtol
	movl	%eax, (%rbx)
.Ltmp83:
	leaq	128(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp84:
# %bb.25:
	leaq	128(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movl	$1, %eax
	addq	$648, %rsp                      # imm = 0x288
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB1_2:
	.cfi_def_cfa_offset 704
.Ltmp63:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp64:
# %bb.3:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
.Ltmp65:
	movl	$_ZSt4cout, %edi
	movq	%r12, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp66:
# %bb.4:
.Ltmp67:
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp68:
.LBB1_5:                                # %_ZNSolsEPFRSoS_E.exit
	movl	$1, %edi
	callq	exit
.LBB1_19:
.Ltmp71:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$6, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp72:
# %bb.20:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit17
.Ltmp73:
	movl	$_ZSt4cout, %edi
	movq	%r12, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp74:
# %bb.21:
.Ltmp75:
	movq	%rax, %rbx
	movl	$.L.str.9, %esi
	movl	$18, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp76:
# %bb.22:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit18
.Ltmp77:
	movq	%rbx, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp78:
	jmp	.LBB1_5
.LBB1_7:                                # %.loopexit.split-lp
.Ltmp85:
	jmp	.LBB1_8
.LBB1_6:                                # %.loopexit
.Ltmp88:
.LBB1_8:
	movq	%rax, %rbx
	leaq	128(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	_Z15readImageHeaderPcRiS0_S0_Rb, .Lfunc_end1-_Z15readImageHeaderPcRiS0_S0_Rb
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp61-.Lfunc_begin1          #   Call between .Lfunc_begin1 and .Ltmp61
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp61-.Lfunc_begin1          # >> Call Site 2 <<
	.uleb128 .Ltmp80-.Ltmp61                #   Call between .Ltmp61 and .Ltmp80
	.uleb128 .Ltmp85-.Lfunc_begin1          #     jumps to .Ltmp85
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp86-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp87-.Ltmp86                #   Call between .Ltmp86 and .Ltmp87
	.uleb128 .Ltmp88-.Lfunc_begin1          #     jumps to .Ltmp88
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp81-.Lfunc_begin1          # >> Call Site 4 <<
	.uleb128 .Ltmp78-.Ltmp81                #   Call between .Ltmp81 and .Ltmp78
	.uleb128 .Ltmp85-.Lfunc_begin1          #     jumps to .Ltmp85
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp78-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Lfunc_end1-.Ltmp78            #   Call between .Ltmp78 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z9readImagePcR5Image           # -- Begin function _Z9readImagePcR5Image
	.type	_Z9readImagePcR5Image,@function
_Z9readImagePcR5Image:                  # @_Z9readImagePcR5Image
.Lfunc_begin2:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception2
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$664, %rsp                      # imm = 0x298
	.cfi_def_cfa_offset 720
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, 16(%rsp)                  # 8-byte Spill
	movq	%rdi, %r14
	leaq	144(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
.Ltmp89:
	movq	%rbx, %rdi
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	movq	%r14, %rsi
	movl	$12, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp90:
# %bb.1:
	movq	144(%rsp), %rax
	movq	-24(%rax), %rax
	testb	$5, 176(%rsp,%rax)
	jne	.LBB2_2
# %bb.8:
.Ltmp97:
	leaq	144(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movl	$100, %edx
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp98:
# %bb.9:
	cmpb	$80, 32(%rsp)
	jne	.LBB2_11
# %bb.10:
	cmpb	$53, 33(%rsp)
	jne	.LBB2_11
# %bb.15:
.Ltmp99:
	leaq	144(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movl	$100, %edx
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp100:
# %bb.16:                               # %.preheader47.preheader
	leaq	144(%rsp), %rbx
	leaq	32(%rsp), %r14
.LBB2_17:                               # %.preheader47
                                        # =>This Inner Loop Header: Depth=1
	cmpb	$35, 32(%rsp)
	jne	.LBB2_19
# %bb.18:                               #   in Loop: Header=BB2_17 Depth=1
.Ltmp122:
	movl	$100, %edx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp123:
	jmp	.LBB2_17
.LBB2_19:
	leaq	32(%rsp), %r14
	leaq	24(%rsp), %rbx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	xorl	%edx, %edx
	callq	__isoc23_strtol
	movq	%rax, %r15
	movq	(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebx
.Ltmp101:
	leaq	144(%rsp), %rdi
	movl	$100, %edx
	movq	%r14, %rsi
	movl	$10, %ecx
	callq	_ZNSi7getlineEPclc
.Ltmp102:
# %bb.20:
	leaq	32(%rsp), %rdi
	leaq	24(%rsp), %rsi
	xorl	%edx, %edx
	callq	__isoc23_strtol
	movl	%ebx, %ebp
	imull	%r15d, %ebp
	movslq	%ebp, %r14
.Ltmp103:
	movq	%r14, %rdi
	callq	_Znam
.Ltmp104:
# %bb.21:
	movq	%rax, %r12
	leaq	(,%r14,4), %rax
	testl	%ebp, %ebp
	movq	$-1, %rdi
	cmovnsq	%rax, %rdi
.Ltmp105:
	callq	_Znam
.Ltmp106:
# %bb.22:
.Ltmp107:
	movq	%rax, %r13
	leaq	144(%rsp), %rdi
	movq	%r12, %rsi
	movq	%r14, %rdx
	callq	_ZNSi4readEPcl
.Ltmp108:
# %bb.23:
	movq	144(%rsp), %rax
	movq	-24(%rax), %rax
	testb	$5, 176(%rsp,%rax)
	jne	.LBB2_24
# %bb.28:
.Ltmp117:
	leaq	144(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp118:
# %bb.29:                               # %.preheader46
	testl	%ebx, %ebx
	jle	.LBB2_35
# %bb.30:                               # %.preheader.lr.ph
	movl	%ebx, %eax
	movl	%r15d, %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
.LBB2_31:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_33 Depth 2
	testl	%r15d, %r15d
	jle	.LBB2_34
# %bb.32:                               # %.lr.ph
                                        #   in Loop: Header=BB2_31 Depth=1
	movl	%edx, %r8d
	leaq	(%r12,%r8), %rdi
	leaq	(,%r8,4), %r8
	addq	%r13, %r8
	xorl	%r9d, %r9d
.LBB2_33:                               #   Parent Loop BB2_31 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%rdi,%r9), %r10d
	movl	%r10d, (%r8,%r9,4)
	incq	%r9
	cmpq	%r9, %rcx
	jne	.LBB2_33
.LBB2_34:                               # %._crit_edge
                                        #   in Loop: Header=BB2_31 Depth=1
	incq	%rsi
	addl	%r15d, %edx
	cmpq	%rax, %rsi
	jne	.LBB2_31
.LBB2_35:                               # %._crit_edge50
.Ltmp119:
	movq	16(%rsp), %rdi                  # 8-byte Reload
	xorl	%esi, %esi
	xorl	%edx, %edx
	movl	%ebp, %ecx
	movq	%r13, %r8
	callq	_ZN5Image9setPixelsEiiiPi
.Ltmp120:
# %bb.36:
	movq	%r12, %rdi
	callq	_ZdaPv
	movq	%r13, %rdi
	callq	_ZdaPv
	leaq	144(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movl	$1, %eax
	addq	$664, %rsp                      # imm = 0x298
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_2:
	.cfi_def_cfa_offset 720
.Ltmp91:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp92:
# %bb.3:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
.Ltmp93:
	movl	$_ZSt4cout, %edi
	movq	8(%rsp), %rsi                   # 8-byte Reload
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp94:
# %bb.4:
.Ltmp95:
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp96:
	jmp	.LBB2_5
.LBB2_11:
.Ltmp125:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$6, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp126:
# %bb.12:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit39
.Ltmp127:
	movl	$_ZSt4cout, %edi
	movq	8(%rsp), %rsi                   # 8-byte Reload
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp128:
# %bb.13:
.Ltmp129:
	movq	%rax, %rbx
	movl	$.L.str.10, %esi
	movl	$11, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp130:
# %bb.14:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit40
.Ltmp131:
	movq	%rbx, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp132:
	jmp	.LBB2_5
.LBB2_24:
.Ltmp109:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$6, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp110:
# %bb.25:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit42
.Ltmp111:
	movl	$_ZSt4cout, %edi
	movq	8(%rsp), %rsi                   # 8-byte Reload
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp112:
# %bb.26:
.Ltmp113:
	movq	%rax, %rbx
	movl	$.L.str.11, %esi
	movl	$15, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp114:
# %bb.27:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit43
.Ltmp115:
	movq	%rbx, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp116:
.LBB2_5:                                # %_ZNSolsEPFRSoS_E.exit
	movl	$1, %edi
	callq	exit
.LBB2_37:
.Ltmp121:
	jmp	.LBB2_38
.LBB2_7:                                # %.loopexit.split-lp
.Ltmp133:
	jmp	.LBB2_38
.LBB2_6:                                # %.loopexit
.Ltmp124:
.LBB2_38:
	movq	%rax, %rbx
	leaq	144(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	_Z9readImagePcR5Image, .Lfunc_end2-_Z9readImagePcR5Image
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception2:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end2-.Lcst_begin2
.Lcst_begin2:
	.uleb128 .Lfunc_begin2-.Lfunc_begin2    # >> Call Site 1 <<
	.uleb128 .Ltmp89-.Lfunc_begin2          #   Call between .Lfunc_begin2 and .Ltmp89
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp89-.Lfunc_begin2          # >> Call Site 2 <<
	.uleb128 .Ltmp100-.Ltmp89               #   Call between .Ltmp89 and .Ltmp100
	.uleb128 .Ltmp133-.Lfunc_begin2         #     jumps to .Ltmp133
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp122-.Lfunc_begin2         # >> Call Site 3 <<
	.uleb128 .Ltmp123-.Ltmp122              #   Call between .Ltmp122 and .Ltmp123
	.uleb128 .Ltmp124-.Lfunc_begin2         #     jumps to .Ltmp124
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp101-.Lfunc_begin2         # >> Call Site 4 <<
	.uleb128 .Ltmp118-.Ltmp101              #   Call between .Ltmp101 and .Ltmp118
	.uleb128 .Ltmp133-.Lfunc_begin2         #     jumps to .Ltmp133
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp119-.Lfunc_begin2         # >> Call Site 5 <<
	.uleb128 .Ltmp120-.Ltmp119              #   Call between .Ltmp119 and .Ltmp120
	.uleb128 .Ltmp121-.Lfunc_begin2         #     jumps to .Ltmp121
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp91-.Lfunc_begin2          # >> Call Site 6 <<
	.uleb128 .Ltmp116-.Ltmp91               #   Call between .Ltmp91 and .Ltmp116
	.uleb128 .Ltmp133-.Lfunc_begin2         #     jumps to .Ltmp133
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp116-.Lfunc_begin2         # >> Call Site 7 <<
	.uleb128 .Lfunc_end2-.Ltmp116           #   Call between .Ltmp116 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end2:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z10writeImagePcR5Image         # -- Begin function _Z10writeImagePcR5Image
	.type	_Z10writeImagePcR5Image,@function
_Z10writeImagePcR5Image:                # @_Z10writeImagePcR5Image
.Lfunc_begin3:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception3
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$528, %rsp                      # imm = 0x210
	.cfi_def_cfa_offset 576
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %r12
	movq	%rdi, %rbx
	leaq	16(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp134:
	leaq	8(%rsp), %rsi
	leaq	4(%rsp), %rdx
	leaq	12(%rsp), %rcx
	movq	%r12, %rdi
	callq	_ZN5Image12getImageInfoERiS0_S0_
.Ltmp135:
# %bb.1:
	movslq	4(%rsp), %rax
	movslq	8(%rsp), %r13
	imulq	%rax, %r13
.Ltmp136:
	movq	%r13, %rdi
	callq	_Znam
.Ltmp137:
# %bb.2:
	movq	%rax, %r14
	movq	%r13, %rax
	shlq	$2, %rax
	testl	%r13d, %r13d
	movq	$-1, %rdi
	cmovnsq	%rax, %rdi
.Ltmp138:
	callq	_Znam
.Ltmp139:
# %bb.3:
.Ltmp140:
	movq	%rax, %r15
	movq	%r12, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	movl	%r13d, %ecx
	movq	%rax, %r8
	callq	_ZN5Image9getPixelsEiiiPi
.Ltmp141:
# %bb.4:                                # %.preheader43
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB3_10
# %bb.5:                                # %.preheader.lr.ph
	movl	4(%rsp), %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
.LBB3_6:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_8 Depth 2
	testl	%ecx, %ecx
	jle	.LBB3_9
# %bb.7:                                # %.lr.ph
                                        #   in Loop: Header=BB3_6 Depth=1
	movl	%edx, %r8d
	leaq	(%r14,%r8), %rdi
	leaq	(%r15,%r8,4), %r8
	xorl	%r9d, %r9d
.LBB3_8:                                #   Parent Loop BB3_6 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movb	(%r8,%r9,4), %r10b
	movb	%r10b, (%rdi,%r9)
	incq	%r9
	cmpq	%r9, %rcx
	jne	.LBB3_8
.LBB3_9:                                # %._crit_edge
                                        #   in Loop: Header=BB3_6 Depth=1
	incq	%rsi
	addl	%ecx, %edx
	cmpq	%rax, %rsi
	jne	.LBB3_6
.LBB3_10:                               # %._crit_edge46
.Ltmp143:
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	movl	$20, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp144:
# %bb.11:
	movq	16(%rsp), %rax
	movq	-24(%rax), %rax
	testb	$5, 48(%rsp,%rax)
	jne	.LBB3_12
# %bb.17:
.Ltmp151:
	leaq	16(%rsp), %r12
	movl	$.L.str.13, %esi
	movl	$2, %edx
	movq	%r12, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp152:
# %bb.18:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit25
	movq	16(%rsp), %rax
	addq	-24(%rax), %r12
.Ltmp153:
	movq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp154:
# %bb.19:                               # %.noexc
.Ltmp155:
	movsbl	%al, %esi
	leaq	16(%rsp), %rdi
	callq	_ZNSo3putEc
.Ltmp156:
# %bb.20:                               # %.noexc32
.Ltmp157:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp158:
# %bb.21:                               # %_ZNSolsEPFRSoS_E.exit26
	movl	4(%rsp), %esi
.Ltmp159:
	leaq	16(%rsp), %rdi
	callq	_ZNSolsEi
.Ltmp160:
# %bb.22:
.Ltmp161:
	movq	%rax, %r12
	movl	$.L.str.14, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp162:
# %bb.23:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit27
	movl	8(%rsp), %esi
.Ltmp163:
	movq	%r12, %rdi
	callq	_ZNSolsEi
.Ltmp164:
# %bb.24:
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
.Ltmp165:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp166:
# %bb.25:                               # %.noexc34
.Ltmp167:
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
.Ltmp168:
# %bb.26:                               # %.noexc35
.Ltmp169:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp170:
# %bb.27:                               # %_ZNSolsEPFRSoS_E.exit28
	movl	12(%rsp), %esi
.Ltmp171:
	leaq	16(%rsp), %rdi
	callq	_ZNSolsEi
.Ltmp172:
# %bb.28:
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
.Ltmp173:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp174:
# %bb.29:                               # %.noexc38
.Ltmp175:
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
.Ltmp176:
# %bb.30:                               # %.noexc39
.Ltmp177:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp178:
# %bb.31:                               # %_ZNSolsEPFRSoS_E.exit29
	movslq	4(%rsp), %rax
	movslq	8(%rsp), %rdx
	imulq	%rax, %rdx
.Ltmp179:
	leaq	16(%rsp), %rdi
	movq	%r14, %rsi
	callq	_ZNSo5writeEPKcl
.Ltmp180:
# %bb.32:
	movq	16(%rsp), %rax
	movq	-24(%rax), %rax
	testb	$5, 48(%rsp,%rax)
	jne	.LBB3_33
# %bb.37:
.Ltmp187:
	leaq	16(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp188:
# %bb.38:
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	%r15, %rdi
	callq	_ZdaPv
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	24(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 16(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	264(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	movl	$1, %eax
	addq	$528, %rsp                      # imm = 0x210
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB3_12:
	.cfi_def_cfa_offset 576
.Ltmp145:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.12, %esi
	movl	$17, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp146:
# %bb.13:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
.Ltmp147:
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp148:
# %bb.14:
.Ltmp149:
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp150:
# %bb.15:                               # %_ZNSolsEPFRSoS_E.exit
	movl	$1, %edi
	callq	exit
.LBB3_33:
.Ltmp181:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.15, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp182:
# %bb.34:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit30
.Ltmp183:
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
.Ltmp184:
# %bb.35:
.Ltmp185:
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
.Ltmp186:
# %bb.36:                               # %_ZNSolsEPFRSoS_E.exit31
	xorl	%edi, %edi
	callq	exit
.LBB3_39:
.Ltmp142:
	jmp	.LBB3_40
.LBB3_16:
.Ltmp189:
.LBB3_40:
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end3:
	.size	_Z10writeImagePcR5Image, .Lfunc_end3-_Z10writeImagePcR5Image
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table3:
.Lexception3:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end3-.Lcst_begin3
.Lcst_begin3:
	.uleb128 .Lfunc_begin3-.Lfunc_begin3    # >> Call Site 1 <<
	.uleb128 .Ltmp134-.Lfunc_begin3         #   Call between .Lfunc_begin3 and .Ltmp134
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp134-.Lfunc_begin3         # >> Call Site 2 <<
	.uleb128 .Ltmp141-.Ltmp134              #   Call between .Ltmp134 and .Ltmp141
	.uleb128 .Ltmp142-.Lfunc_begin3         #     jumps to .Ltmp142
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp143-.Lfunc_begin3         # >> Call Site 3 <<
	.uleb128 .Ltmp186-.Ltmp143              #   Call between .Ltmp143 and .Ltmp186
	.uleb128 .Ltmp189-.Lfunc_begin3         #     jumps to .Ltmp189
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp186-.Lfunc_begin3         # >> Call Site 4 <<
	.uleb128 .Lfunc_end3-.Ltmp186           #   Call between .Ltmp186 and .Lfunc_end3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end3:
	.p2align	2, 0x0
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"USAGE: "
	.size	.L.str, 8

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" INPUT_FILE OUTPUT_FILE [ENLARGE_SIZE]"
	.size	.L.str.1, 39

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Reading: "
	.size	.L.str.2, 10

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Scaling by a factor of:"
	.size	.L.str.3, 24

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Negating image"
	.size	.L.str.4, 15

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Reflecting image"
	.size	.L.str.5, 17

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Writing: "
	.size	.L.str.6, 10

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Can't read image: "
	.size	.L.str.7, 19

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Image "
	.size	.L.str.8, 7

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	" is not PGM or PPM"
	.size	.L.str.9, 19

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	" is not PGM"
	.size	.L.str.10, 12

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	" has wrong size"
	.size	.L.str.11, 16

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Can't open file: "
	.size	.L.str.12, 18

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"P5"
	.size	.L.str.13, 3

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	" "
	.size	.L.str.14, 2

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Can't write image "
	.size	.L.str.15, 19

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _ZSt4cerr
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
