// File: sorazy[P]canny/main.cpp
// Function: main
int main(int argc, char **argv)
{
	// Exit program if proper arguments are not provided by user
	if (argc != 4)
	{
		cout << "Proper syntax: ./a.out <input_filename> <high_threshold> <sigma_value>" << endl;
		return 0;
	}

	// Exit program if file doesn't open
	string filename(argv[1]);
	string path = "./input_images/" + filename;
	ifstream infile(path, ios::binary);
	if (!infile.is_open())
	{
		cout << "File " << path << " not found in directory." << endl;
		return 0;
	}	

	// Opening output files
	ofstream img1("./output_images/canny_mag.pgm", ios::binary);
	ofstream img2("./output_images/canny_peaks.pgm", ios::binary);		
	ofstream img3("./output_images/canny_final.pgm", ios::binary);

	::hi = stoi(argv[2]);
	::lo = .35 * hi;
	::sig = stoi(argv[3]);

	// Storing header information and copying into the new ouput images
	infile >> ::type >> ::width >> ::height >> ::intensity;
	img1 << type << endl << width << " " << height << endl << intensity << endl;
	img2 << type << endl << width << " " << height << endl << intensity << endl;
	img3 << type << endl << width << " " << height << endl << intensity << endl;

	// These matrices will hold the integer values of the input image and masks.
	// I'm dynamically allocating arrays to easily pass them into functions.
	double **pic = new double*[height], **mag = new double*[height], **final = new double*[height];
	double **x = new double*[height], **y = new double*[height];

	for (int i = 0; i < height; i++)
	{
		pic[i] = new double[width];
		mag[i] = new double[width];
		final[i] = new double[width];
		x[i] = new double[width];
		y[i] = new double[width];
	}

	// Reading in the input image as integers
	for (int i = 0; i < height; i++)
		for (int j = 0; j < width; j++)
			pic[i][j] = (int)infile.get();

	// Create the magniute matrix
	magnitude_matrix(pic, mag, x, y);

	// Get all the peaks and store them in vector
	HashMap *peaks = new HashMap();
	vector<Point*> v = peak_detection(mag, peaks, x, y);

	// Go through the vector and call the recursive function and each point. If the value
	// in the mag matrix is hi, then immediately accept it in final. If lo, then immediately
	// reject. If between lo and hi, then check if it's next to a hi pixel using recursion
	HashMap *h = new HashMap();
	int a, b;
	for (int i = 0; i < v.size(); i++)
	{
		a = v.at(i)->x;
		b = v.at(i)->y;

		if (mag[a][b] >= hi)
			final[a][b] = 255;
		else if (mag[a][b] < lo)
			final[a][b] = 0;
		else
			recursiveDT(mag, final, h, peaks, a, b, 0);
	}

	// ================================= IMAGE OUTPUT =================================
	// Outputting the 'mag' matrix to img1. It's very important to cast it to a char.
	// To make sure that the decimal doesn't produce any wonky results, cast to an int
	// ================================= IMAGE OUTPUT =================================
	for (int i = 0; i < height; i++)
		for (int j = 0; j < width; j++)
			img1 << (char)((int)mag[i][j]);

	// Outputting the points stored in the vector to img2
	int k = 0;
	for (int i = 0; i < v.size(); i++)
	{
		while(k++ != (v.at(i)->x * height + v.at(i)->y - 1))
			img2 << (char)(0);

		img2 << (char)(255);
	}

	// Output the 'final' matrix to img1
	for (int i = 0; i < height; i++)
		for (int j = 0; j < width; j++)
			img3 << (char)((int)final[i][j]);		

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb20, %rsp            # imm = 0xB20
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x4, -0x8(%rbp)
je 0x25dd
movq 0x6a1a(%rip), %rdi      # 0x8fd0
leaq 0x3a5b(%rip), %rsi      # 0x6018
callq 0x21e0
movq %rax, %rdi
movq 0x69f4(%rip), %rsi      # 0x8fc0
callq 0x2210
movl $0x0, -0x4(%rbp)
jmp 0x34c1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x960(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x958(%rbp)
callq 0x2380
movq -0x960(%rbp), %rsi
movq -0x958(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x34e0
jmp 0x2615
leaq -0x31(%rbp), %rdi
callq 0x2230
leaq 0x3a3a(%rip), %rsi      # 0x605f
leaq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x3590
jmp 0x2634
leaq -0x270(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x4, %edx
callq 0x2310
jmp 0x264b
leaq -0x270(%rbp), %rdi
callq 0x2300
movb %al, -0x961(%rbp)
jmp 0x265f
movb -0x961(%rbp), %al
testb $0x1, %al
jne 0x2738
jmp 0x266f
movq 0x695a(%rip), %rdi      # 0x8fd0
leaq 0x39f2(%rip), %rsi      # 0x606f
callq 0x21e0
movq %rax, -0x970(%rbp)
jmp 0x268b
movq -0x970(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x21d0
movq %rax, -0x978(%rbp)
jmp 0x26a4
movq -0x978(%rbp), %rdi
leaq 0x39c3(%rip), %rsi      # 0x6075
callq 0x21e0
movq %rax, -0x980(%rbp)
jmp 0x26c0
movq -0x980(%rbp), %rdi
movq 0x68f2(%rip), %rsi      # 0x8fc0
callq 0x2210
jmp 0x26d5
movl $0x0, -0x4(%rbp)
movl $0x1, -0x274(%rbp)
jmp 0x3481
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x2230
jmp 0x34cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x34b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x34ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x34a1
leaq 0x394f(%rip), %rsi      # 0x608e
leaq -0x478(%rbp), %rdi
movl $0x4, %edx
callq 0x2240
jmp 0x2752
leaq 0x3953(%rip), %rsi      # 0x60ac
leaq -0x678(%rbp), %rdi
movl $0x4, %edx
callq 0x2240
jmp 0x276c
leaq 0x3959(%rip), %rsi      # 0x60cc
leaq -0x878(%rbp), %rdi
movl $0x4, %edx
callq 0x2240
jmp 0x2786
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x990(%rbp)
leaq -0x899(%rbp), %rdi
movq %rdi, -0x988(%rbp)
callq 0x2380
movq -0x990(%rbp), %rsi
movq -0x988(%rbp), %rdx
leaq -0x898(%rbp), %rdi
callq 0x34e0
jmp 0x27c4
xorl %eax, %eax
movl %eax, %esi
leaq -0x898(%rbp), %rdi
movl $0xa, %edx
callq 0x36a0
movl %eax, -0x994(%rbp)
jmp 0x27e1
movl -0x994(%rbp), %eax
movl %eax, 0x6a33(%rip)      # 0x9220
leaq -0x898(%rbp), %rdi
callq 0x2130
leaq -0x899(%rbp), %rdi
callq 0x2230
cvtsi2sdl 0x6a13(%rip), %xmm0 # 0x9220
movsd 0x37f3(%rip), %xmm1     # 0x6008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x6a01(%rip)      # 0x9224
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x9a8(%rbp)
leaq -0x8c1(%rbp), %rdi
movq %rdi, -0x9a0(%rbp)
callq 0x2380
movq -0x9a8(%rbp), %rsi
movq -0x9a0(%rbp), %rdx
leaq -0x8c0(%rbp), %rdi
callq 0x34e0
jmp 0x2861
xorl %eax, %eax
movl %eax, %esi
leaq -0x8c0(%rbp), %rdi
movl $0xa, %edx
callq 0x36a0
movl %eax, -0x9ac(%rbp)
jmp 0x287e
movl -0x9ac(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x6998(%rip)     # 0x9228
leaq -0x8c0(%rbp), %rdi
callq 0x2130
leaq -0x8c1(%rbp), %rdi
callq 0x2230
leaq 0x695a(%rip), %rsi      # 0x9209
leaq -0x270(%rbp), %rdi
callq 0x36e0
movq %rax, -0x9b8(%rbp)
jmp 0x28c4
movq -0x9b8(%rbp), %rdi
leaq 0x6946(%rip), %rsi      # 0x9218
callq 0x2120
movq %rax, -0x9c0(%rbp)
jmp 0x28e0
movq -0x9c0(%rbp), %rdi
leaq 0x6926(%rip), %rsi      # 0x9214
callq 0x2120
movq %rax, -0x9c8(%rbp)
jmp 0x28fc
movq -0x9c8(%rbp), %rdi
leaq 0x6912(%rip), %rsi      # 0x921c
callq 0x2120
jmp 0x2911
leaq 0x68f1(%rip), %rsi      # 0x9209
leaq -0x478(%rbp), %rdi
callq 0x21e0
movq %rax, -0x9d0(%rbp)
jmp 0x292d
movq -0x9d0(%rbp), %rdi
movq 0x6685(%rip), %rsi      # 0x8fc0
callq 0x2210
movq %rax, -0x9d8(%rbp)
jmp 0x2949
movq -0x9d8(%rbp), %rdi
movl 0x68c2(%rip), %esi      # 0x9218
callq 0x2360
movq %rax, -0x9e0(%rbp)
jmp 0x2964
movq -0x9e0(%rbp), %rdi
leaq 0x388d(%rip), %rsi      # 0x61ff
callq 0x21e0
movq %rax, -0x9e8(%rbp)
jmp 0x2980
movq -0x9e8(%rbp), %rdi
movl 0x6887(%rip), %esi      # 0x9214
callq 0x2360
movq %rax, -0x9f0(%rbp)
jmp 0x299b
movq -0x9f0(%rbp), %rdi
movq 0x6617(%rip), %rsi      # 0x8fc0
callq 0x2210
movq %rax, -0x9f8(%rbp)
jmp 0x29b7
movq -0x9f8(%rbp), %rdi
movl 0x6858(%rip), %esi      # 0x921c
callq 0x2360
movq %rax, -0xa00(%rbp)
jmp 0x29d2
movq -0xa00(%rbp), %rdi
movq 0x65e0(%rip), %rsi      # 0x8fc0
callq 0x2210
jmp 0x29e7
leaq 0x681b(%rip), %rsi      # 0x9209
leaq -0x678(%rbp), %rdi
callq 0x21e0
movq %rax, -0xa08(%rbp)
jmp 0x2a03
movq -0xa08(%rbp), %rdi
movq 0x65af(%rip), %rsi      # 0x8fc0
callq 0x2210
movq %rax, -0xa10(%rbp)
jmp 0x2a1f
movq -0xa10(%rbp), %rdi
movl 0x67ec(%rip), %esi      # 0x9218
callq 0x2360
movq %rax, -0xa18(%rbp)
jmp 0x2a3a
movq -0xa18(%rbp), %rdi
leaq 0x37b7(%rip), %rsi      # 0x61ff
callq 0x21e0
movq %rax, -0xa20(%rbp)
jmp 0x2a56
movq -0xa20(%rbp), %rdi
movl 0x67b1(%rip), %esi      # 0x9214
callq 0x2360
movq %rax, -0xa28(%rbp)
jmp 0x2a71
movq -0xa28(%rbp), %rdi
movq 0x6541(%rip), %rsi      # 0x8fc0
callq 0x2210
movq %rax, -0xa30(%rbp)
jmp 0x2a8d
movq -0xa30(%rbp), %rdi
movl 0x6782(%rip), %esi      # 0x921c
callq 0x2360
movq %rax, -0xa38(%rbp)
jmp 0x2aa8
movq -0xa38(%rbp), %rdi
movq 0x650a(%rip), %rsi      # 0x8fc0
callq 0x2210
jmp 0x2abd
leaq 0x6745(%rip), %rsi      # 0x9209
leaq -0x878(%rbp), %rdi
callq 0x21e0
movq %rax, -0xa40(%rbp)
jmp 0x2ad9
movq -0xa40(%rbp), %rdi
movq 0x64d9(%rip), %rsi      # 0x8fc0
callq 0x2210
movq %rax, -0xa48(%rbp)
jmp 0x2af5
movq -0xa48(%rbp), %rdi
movl 0x6716(%rip), %esi      # 0x9218
callq 0x2360
movq %rax, -0xa50(%rbp)
jmp 0x2b10
movq -0xa50(%rbp), %rdi
leaq 0x36e1(%rip), %rsi      # 0x61ff
callq 0x21e0
movq %rax, -0xa58(%rbp)
jmp 0x2b2c
movq -0xa58(%rbp), %rdi
movl 0x66db(%rip), %esi      # 0x9214
callq 0x2360
movq %rax, -0xa60(%rbp)
jmp 0x2b47
movq -0xa60(%rbp), %rdi
movq 0x646b(%rip), %rsi      # 0x8fc0
callq 0x2210
movq %rax, -0xa68(%rbp)
jmp 0x2b63
movq -0xa68(%rbp), %rdi
movl 0x66ac(%rip), %esi      # 0x921c
callq 0x2360
movq %rax, -0xa70(%rbp)
jmp 0x2b7e
movq -0xa70(%rbp), %rdi
movq 0x6434(%rip), %rsi      # 0x8fc0
callq 0x2210
jmp 0x2b93
movslq 0x667a(%rip), %rax      # 0x9214
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xa78(%rbp)
jmp 0x2bbe
movq -0xa78(%rbp), %rax
movq %rax, -0x8d0(%rbp)
movslq 0x6641(%rip), %rax      # 0x9214
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xa80(%rbp)
jmp 0x2bf7
movq -0xa80(%rbp), %rax
movq %rax, -0x8d8(%rbp)
movslq 0x6608(%rip), %rax      # 0x9214
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xa88(%rbp)
jmp 0x2c30
movq -0xa88(%rbp), %rax
movq %rax, -0x8e0(%rbp)
movslq 0x65cf(%rip), %rax      # 0x9214
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xa90(%rbp)
jmp 0x2c69
movq -0xa90(%rbp), %rax
movq %rax, -0x8e8(%rbp)
movslq 0x6596(%rip), %rax      # 0x9214
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xa98(%rbp)
jmp 0x2ca2
movq -0xa98(%rbp), %rax
movq %rax, -0x8f0(%rbp)
movl $0x0, -0x8f4(%rbp)
movl -0x8f4(%rbp), %eax
cmpl 0x654e(%rip), %eax      # 0x9214
jge 0x2ed5
movslq 0x6545(%rip), %rax      # 0x9218
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xaa0(%rbp)
jmp 0x2cf7
movq -0xaa0(%rbp), %rdx
movq -0x8d0(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq 0x6501(%rip), %rax      # 0x9218
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xaa8(%rbp)
jmp 0x2d3b
movq -0xaa8(%rbp), %rdx
movq -0x8d8(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq 0x64bd(%rip), %rax      # 0x9218
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xab0(%rbp)
jmp 0x2d7f
movq -0xab0(%rbp), %rdx
movq -0x8e0(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq 0x6479(%rip), %rax      # 0x9218
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xab8(%rbp)
jmp 0x2dc3
movq -0xab8(%rbp), %rdx
movq -0x8e8(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq 0x6435(%rip), %rax      # 0x9218
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0xac0(%rbp)
jmp 0x2e07
movq -0xac0(%rbp), %rdx
movq -0x8f0(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x8f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f4(%rbp)
jmp 0x2cba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3467
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2e7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x898(%rbp), %rdi
callq 0x2130
leaq -0x899(%rbp), %rdi
callq 0x2230
jmp 0x345b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2eb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x8c0(%rbp), %rdi
callq 0x2130
leaq -0x8c1(%rbp), %rdi
callq 0x2230
jmp 0x345b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x345b
movl $0x0, -0x8f8(%rbp)
movl -0x8f8(%rbp), %eax
cmpl 0x6329(%rip), %eax      # 0x9214
jge 0x2f68
movl $0x0, -0x8fc(%rbp)
movl -0x8fc(%rbp), %eax
cmpl 0x6315(%rip), %eax      # 0x9218
jge 0x2f52
leaq -0x270(%rbp), %rdi
callq 0x2280
movl %eax, -0xac4(%rbp)
jmp 0x2f19
movl -0xac4(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x8d0(%rbp), %rax
movslq -0x8f8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x8fc(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x8fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8fc(%rbp)
jmp 0x2ef7
jmp 0x2f54
movl -0x8f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f8(%rbp)
jmp 0x2edf
movq -0x8d0(%rbp), %rdi
movq -0x8d8(%rbp), %rsi
movq -0x8e8(%rbp), %rdx
movq -0x8f0(%rbp), %rcx
callq 0x3ec0
jmp 0x2f8b
movl $0x40, %edi
callq 0x21f0
movq %rax, -0xad0(%rbp)
jmp 0x2f9e
movq -0xad0(%rbp), %rdi
callq 0x5670
jmp 0x2fac
movq -0xad0(%rbp), %rax
movq %rax, -0x908(%rbp)
movq -0x8d8(%rbp), %rsi
movq -0x908(%rbp), %rdx
movq -0x8e8(%rbp), %rcx
movq -0x8f0(%rbp), %r8
leaq -0x920(%rbp), %rdi
callq 0x44c0
jmp 0x2fe4
movl $0x40, %edi
callq 0x21f0
movq %rax, -0xad8(%rbp)
jmp 0x2ff7
movq -0xad8(%rbp), %rdi
callq 0x5670
jmp 0x3005
movq -0xad8(%rbp), %rax
movq %rax, -0x928(%rbp)
movl $0x0, -0x934(%rbp)
movslq -0x934(%rbp), %rax
movq %rax, -0xae0(%rbp)
leaq -0x920(%rbp), %rdi
callq 0x3730
movq %rax, %rcx
movq -0xae0(%rbp), %rax
cmpq %rcx, %rax
jae 0x31fa
movslq -0x934(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x3750
movq %rax, -0xae8(%rbp)
jmp 0x3066
movq -0xae8(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x92c(%rbp)
movslq -0x934(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x3750
movq %rax, -0xaf0(%rbp)
jmp 0x3094
movq -0xaf0(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x930(%rbp)
movq -0x8d8(%rbp), %rax
movslq -0x92c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x930(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsi2sdl 0x6153(%rip), %xmm1 # 0x9220
ucomisd %xmm1, %xmm0
jb 0x3157
movq -0x8e0(%rbp), %rax
movslq -0x92c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x930(%rbp), %rcx
movsd 0x2f18(%rip), %xmm0     # 0x6010
movsd %xmm0, (%rax,%rcx,8)
jmp 0x31e4
movq -0xad0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
movl $0x40, %esi
callq 0x2200
jmp 0x345b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x344f
movq -0xad8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
movl $0x40, %esi
callq 0x2200
jmp 0x344f
movq -0x8d8(%rbp), %rax
movslq -0x92c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x930(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
cvtsi2sdl 0x60a7(%rip), %xmm0 # 0x9224
ucomisd %xmm1, %xmm0
jbe 0x31a6
movq -0x8e0(%rbp), %rax
movslq -0x92c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x930(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x31e2
movq -0x8d8(%rbp), %rdi
movq -0x8e0(%rbp), %rsi
movq -0x928(%rbp), %rdx
movq -0x908(%rbp), %rcx
movl -0x92c(%rbp), %r8d
movl -0x930(%rbp), %r9d
movq %rsp, %rax
movl $0x0, (%rax)
callq 0x4ac0
jmp 0x31e0
jmp 0x31e2
jmp 0x31e4
jmp 0x31e6
movl -0x934(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x934(%rbp)
jmp 0x301d
movl $0x0, -0x938(%rbp)
movl -0x938(%rbp), %eax
cmpl 0x6004(%rip), %eax      # 0x9214
jge 0x327f
movl $0x0, -0x93c(%rbp)
movl -0x93c(%rbp), %eax
cmpl 0x5ff0(%rip), %eax      # 0x9218
jge 0x326c
movq -0x8d8(%rbp), %rax
movslq -0x938(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x93c(%rbp), %rcx
cvttsd2si (%rax,%rcx,8), %eax
movsbl %al, %esi
leaq -0x478(%rbp), %rdi
callq 0x2270
jmp 0x3259
jmp 0x325b
movl -0x93c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x93c(%rbp)
jmp 0x321c
jmp 0x326e
movl -0x938(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x938(%rbp)
jmp 0x3204
movl $0x0, -0x940(%rbp)
movl $0x0, -0x944(%rbp)
movslq -0x944(%rbp), %rax
movq %rax, -0xaf8(%rbp)
leaq -0x920(%rbp), %rdi
callq 0x3730
movq %rax, %rcx
movq -0xaf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x3387
jmp 0x32c2
movl -0x940(%rbp), %eax
movl %eax, -0xb04(%rbp)
incl %eax
movl %eax, -0x940(%rbp)
movslq -0x944(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x3750
movq %rax, -0xb00(%rbp)
jmp 0x32f2
movq -0xb00(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl 0x5f10(%rip), %ecx      # 0x9214
imull %ecx, %eax
movl %eax, -0xb14(%rbp)
movslq -0x944(%rbp), %rsi
leaq -0x920(%rbp), %rdi
callq 0x3750
movq %rax, -0xb10(%rbp)
jmp 0x3329
movl -0xb04(%rbp), %eax
movl -0xb14(%rbp), %ecx
movq -0xb10(%rbp), %rdx
movq (%rdx), %rdx
addl 0x4(%rdx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x335e
leaq -0x678(%rbp), %rdi
xorl %esi, %esi
callq 0x2270
jmp 0x3359
jmp 0x32c2
leaq -0x678(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2270
jmp 0x3371
jmp 0x3373
movl -0x944(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x944(%rbp)
jmp 0x3293
movl $0x0, -0x948(%rbp)
movl -0x948(%rbp), %eax
cmpl 0x5e77(%rip), %eax      # 0x9214
jge 0x340c
movl $0x0, -0x94c(%rbp)
movl -0x94c(%rbp), %eax
cmpl 0x5e63(%rip), %eax      # 0x9218
jge 0x33f9
movq -0x8e0(%rbp), %rax
movslq -0x948(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x94c(%rbp), %rcx
cvttsd2si (%rax,%rcx,8), %eax
movsbl %al, %esi
leaq -0x878(%rbp), %rdi
callq 0x2270
jmp 0x33e6
jmp 0x33e8
movl -0x94c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94c(%rbp)
jmp 0x33a9
jmp 0x33fb
movl -0x948(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x948(%rbp)
jmp 0x3391
movl $0x0, -0x4(%rbp)
movl $0x1, -0x274(%rbp)
leaq -0x920(%rbp), %rdi
callq 0x3790
leaq -0x878(%rbp), %rdi
callq 0x22c0
leaq -0x678(%rbp), %rdi
callq 0x22c0
leaq -0x478(%rbp), %rdi
callq 0x22c0
jmp 0x3481
leaq -0x920(%rbp), %rdi
callq 0x3790
leaq -0x878(%rbp), %rdi
callq 0x22c0
leaq -0x678(%rbp), %rdi
callq 0x22c0
leaq -0x478(%rbp), %rdi
callq 0x22c0
jmp 0x34a1
leaq -0x270(%rbp), %rdi
callq 0x2070
leaq -0x68(%rbp), %rdi
callq 0x2130
leaq -0x30(%rbp), %rdi
callq 0x2130
jmp 0x34c1
leaq -0x270(%rbp), %rdi
callq 0x2070
leaq -0x68(%rbp), %rdi
callq 0x2130
leaq -0x30(%rbp), %rdi
callq 0x2130
jmp 0x34cd
movl -0x4(%rbp), %eax
addq $0xb20, %rsp            # imm = 0xB20
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2370
nopw %cs:(%rax,%rax)