// File: ChnMasterOG[P]KmerGO2/kmergo/kmer_filtering.cpp
// Function: categorical_feature_filtering(unsigned short, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, KmerGO_parameters)
void categorical_feature_filtering(uint16_t Nprocess, std::vector<std::string> files_vec, KmerGO_parameters p)
{
	std::string line, kmer;
	std::string input_file_name = files_vec[Nprocess];
	std::string onput_file_name_l = joinPath(p.features_path, "categorical_l_" + std::to_string(Nprocess) + ".txt");
	std::string onput_file_name_n = joinPath(p.features_path, "categorical_n_" + std::to_string(Nprocess) + ".txt");
	std::ifstream input_file(input_file_name);
	std::ofstream output_file_l(onput_file_name_l);
	std::ofstream output_file_n(onput_file_name_n);
	std::vector<short> sample_label;	// -1 inexistence, 0 groupA, 1 groupB
	std::string::size_type position;

	/* read head text and set labels */
	std::getline(input_file, line);
	mtx.lock();	// mutex
	progress += line.size() + 1;	// update progress
	mtx.unlock();
	output_file_l << line << "\tASS\tLabel\n";	// write logical file head text
	output_file_n << line << "\tASS-l\tP\tASS-n\tLabel\n";	// write numerical file head text
	position = line.find("\t");
	line = line.substr(position + 1);	// remove string "k-mer"
	position = line.find("\t");
	while (position != line.npos)	// split groupA and groupB
	{
		std::string sample_name = line.substr(0, position);
		if (p.trait_information_map.find(sample_name) != p.trait_information_map.end())
		{
			if (p.trait_information_map[sample_name].compare(p.groupA_name) == 0) sample_label.push_back(0);
			else sample_label.push_back(1);
		}
		else sample_label.push_back(-1);
		line = line.substr(position + 1);
		position = line.find("\t");
	}
	if (p.trait_information_map.find(line) != p.trait_information_map.end())
	{
		if (p.trait_information_map[line].compare(p.groupA_name) == 0) sample_label.push_back(0);
		else sample_label.push_back(1);
	}
	else sample_label.push_back(-1);

	/* filtering */
	while (std::getline(input_file, line))
	{
		std::string src_line(line);
		position = line.find("\t");
		line = line.substr(position + 1);	// remove first k-mer
		position = line.find("\t");
		std::vector<float> group1, group2;
		int cnt = 0, tp = 0, tn = 0;
		std::string judge_label;
		while (position != line.npos)
		{
			std::string value_str = line.substr(0, position);
			float value_float = std::stof(value_str);
			/* add values to groups */
			if (sample_label[cnt] == 0)	// is groupA
			{
				group1.push_back(value_float);
				if (value_float > 0) ++tp;
			}
			else if(sample_label[cnt] == 1)	// is groupB
			{
				group2.push_back(value_float);
				if (value_float == 0) ++tn;
			}
			line = line.substr(position + 1);
			position = line.find("\t");
			++cnt;
		}
		/* calculation */
		float assL = ((float)tp / group1.size() + (float)tn / group2.size()) / 2;	// ass_l
		if (assL > 0.5) judge_label = p.groupA_name;
		else
		{
			judge_label = p.groupB_name;
			assL = 1 - assL;
		}
		if (assL >= p.assl)	// logical ASS
		{
			output_file_l << src_line << '\t' << std::to_string(assL) << '\t' << judge_label << '\n';
		}
		else	// numerical ASS
		{
			float pValue = ranksums(group1, group2);
			if (pValue < p.p_value)
			{
				std::vector<Logistic_Data> dataSet;
				for (float i : group1)
				{
					dataSet.push_back(Logistic_Data(std::vector<float>{i}, 0));	// 1 feature for group1
				}
				for (float i : group2)
				{
					dataSet.push_back(Logistic_Data(std::vector<float>{i}, 1));	// 1 feature for group2
				}
				std::vector<Logistic_Data> testdataSet(dataSet);
				Logistic model(dataSet);
				model.logisticRegression();	// fit the logistics model
				model.predictClass(testdataSet);
				/* calculate the confusion matrix */
				tp = tn = 0;
				for (unsigned int i = 0; i < group1.size(); i++)	// caculate tp
				{
					if (testdataSet[i].cls == dataSet[i].cls) ++tp;
				}
				for (unsigned int i = 0; i < group1.size(); i++)	// caculate tn
				{
					if (testdataSet[i].cls == dataSet[i].cls) ++tn;
				}
				float assN = ((float)tp / group1.size() + (float)tn / group2.size()) / 2;	// ass_n
				if (assN >= p.assn)
				{
					output_file_n << src_line << '\t' << std::to_string(assL) << '\t' << pValue <<
						'\t' << assN << '\t' << judge_label << '\n';
				}
			}
		}
		mtx.lock();
		progress += src_line.size() + 1;	// update progress
		mtx.unlock();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc60, %rsp            # imm = 0xC60
movq %rdx, -0xb20(%rbp)
movq %rsi, -0xb18(%rbp)
movw %di, %ax
movw %ax, -0x2(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x49eec0
leaq -0x58(%rbp), %rdi
callq 0x49eec0
movq -0xb18(%rbp), %rdi
movzwl -0x2(%rbp), %eax
movl %eax, %esi
callq 0x4072e0
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x4a15e0
jmp 0x41360a
movq -0xb20(%rbp), %rsi
subq $-0x80, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x4a15e0
jmp 0x413623
movzwl -0x2(%rbp), %esi
leaq -0x128(%rbp), %rdi
callq 0x4075b0
jmp 0x413635
leaq 0x1a2e84(%rip), %rsi    # 0x5b64c0
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rdx
callq 0x4077b0
jmp 0x413651
leaq 0x1a2c44(%rip), %rdx    # 0x5b629c
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x407350
jmp 0x41366d
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0x407470
jmp 0x413689
leaq -0xe8(%rbp), %rdi
callq 0x49efd0
leaq -0x108(%rbp), %rdi
callq 0x49efd0
leaq -0x128(%rbp), %rdi
callq 0x49efd0
leaq -0xc8(%rbp), %rdi
callq 0x49efd0
movq -0xb20(%rbp), %rsi
subq $-0x80, %rsi
leaq -0x168(%rbp), %rdi
callq 0x4a15e0
jmp 0x4136d2
movzwl -0x2(%rbp), %esi
leaq -0x1c8(%rbp), %rdi
callq 0x4075b0
jmp 0x4136e4
leaq 0x1a2de4(%rip), %rsi    # 0x5b64cf
leaq -0x1a8(%rbp), %rdi
leaq -0x1c8(%rbp), %rdx
callq 0x4077b0
jmp 0x413700
leaq 0x1a2b95(%rip), %rdx    # 0x5b629c
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x407350
jmp 0x41371c
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x407470
jmp 0x413738
leaq -0x188(%rbp), %rdi
callq 0x49efd0
leaq -0x1a8(%rbp), %rdi
callq 0x49efd0
leaq -0x1c8(%rbp), %rdi
callq 0x49efd0
leaq -0x168(%rbp), %rdi
callq 0x49efd0
leaq -0x3d0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0x8, %edx
callq 0x4750c0
jmp 0x41377f
leaq -0x5d0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x10, %edx
callq 0x475230
jmp 0x413799
leaq -0x7d0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
movl $0x10, %edx
callq 0x475230
jmp 0x4137b3
leaq -0x7e8(%rbp), %rdi
callq 0x416130
leaq -0x3d0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a1890
jmp 0x4137d1
leaq 0x226ef0(%rip), %rdi    # 0x63a6c8
callq 0x40b4f0
jmp 0x4137df
leaq -0x38(%rbp), %rdi
callq 0x49f1f0
movq 0x226ec9(%rip), %rcx    # 0x63a6b8
leaq 0x1(%rax,%rcx), %rax
movq %rax, 0x226ebd(%rip)    # 0x63a6b8
leaq 0x226ec6(%rip), %rdi    # 0x63a6c8
callq 0x40b520
jmp 0x413809
leaq -0x5d0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xb28(%rbp)
jmp 0x413822
movq -0xb28(%rbp), %rdi
leaq 0x1a2cae(%rip), %rsi    # 0x5b64de
callq 0x498c00
jmp 0x413837
leaq -0x7d0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xb30(%rbp)
jmp 0x413850
movq -0xb30(%rbp), %rdi
leaq 0x1a2c8c(%rip), %rsi    # 0x5b64ea
callq 0x498c00
jmp 0x413865
leaq 0x1a2ac3(%rip), %rsi    # 0x5b632f
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rdi
movq %rdi, -0xb38(%rbp)
callq 0x4a0b30
movq -0xb38(%rbp), %rsi
movq %rax, -0x7f0(%rbp)
movq -0x7f0(%rbp), %rdx
incq %rdx
leaq -0x810(%rbp), %rdi
movq $-0x1, %rcx
callq 0x4a1800
jmp 0x4138ad
leaq -0x38(%rbp), %rdi
leaq -0x810(%rbp), %rsi
callq 0x49f020
leaq -0x810(%rbp), %rdi
callq 0x49efd0
leaq -0x38(%rbp), %rdi
leaq 0x1a2a5b(%rip), %rsi    # 0x5b632f
xorl %eax, %eax
movl %eax, %edx
callq 0x4a0b30
movq %rax, -0x7f0(%rbp)
cmpq $-0x1, -0x7f0(%rbp)
je 0x413c34
movq -0x7f0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x830(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a1800
jmp 0x41390f
movq -0xb20(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
leaq -0x830(%rbp), %rsi
callq 0x416180
movq %rax, -0xb40(%rbp)
jmp 0x413932
movq -0xb20(%rbp), %rdi
movq -0xb40(%rbp), %rax
movq %rax, -0x838(%rbp)
addq $0x158, %rdi            # imm = 0x158
callq 0x40d970
movq %rax, -0x840(%rbp)
leaq -0x838(%rbp), %rdi
leaq -0x840(%rbp), %rsi
callq 0x416150
testb $0x1, %al
jne 0x413976
jmp 0x413ba9
movq -0xb20(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
leaq -0x830(%rbp), %rsi
callq 0x40bc10
movq %rax, -0xb48(%rbp)
jmp 0x413999
movq -0xb48(%rbp), %rdi
movq -0xb20(%rbp), %rsi
addq $0x108, %rsi            # imm = 0x108
callq 0x4a1030
movl %eax, -0xb4c(%rbp)
jmp 0x4139bb
movl -0xb4c(%rbp), %eax
cmpl $0x0, %eax
jne 0x413b87
movw $0x0, -0x842(%rbp)
leaq -0x7e8(%rbp), %rdi
leaq -0x842(%rbp), %rsi
callq 0x4161b0
jmp 0x4139e8
jmp 0x413ba7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414bdc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414bd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413a7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413a6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413a63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x49efd0
leaq -0x108(%rbp), %rdi
callq 0x49efd0
leaq -0x128(%rbp), %rdi
callq 0x49efd0
leaq -0xc8(%rbp), %rdi
callq 0x49efd0
jmp 0x414bd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414bc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413b06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413afa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413aee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x49efd0
leaq -0x1a8(%rbp), %rdi
callq 0x49efd0
leaq -0x1c8(%rbp), %rdi
callq 0x49efd0
leaq -0x168(%rbp), %rdi
callq 0x49efd0
jmp 0x414bc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414bbb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414baf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414ba3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414b8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x830(%rbp), %rdi
callq 0x49efd0
jmp 0x414b8b
movw $0x1, -0x844(%rbp)
leaq -0x7e8(%rbp), %rdi
leaq -0x844(%rbp), %rsi
callq 0x4161b0
jmp 0x413ba5
jmp 0x413ba7
jmp 0x413bc9
movw $0xffff, -0x846(%rbp)   # imm = 0xFFFF
leaq -0x7e8(%rbp), %rdi
leaq -0x846(%rbp), %rsi
callq 0x4161b0
jmp 0x413bc7
jmp 0x413bc9
movq -0x7f0(%rbp), %rdx
incq %rdx
leaq -0x868(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq $-0x1, %rcx
callq 0x4a1800
jmp 0x413bec
leaq -0x38(%rbp), %rdi
leaq -0x868(%rbp), %rsi
callq 0x49f020
leaq -0x868(%rbp), %rdi
callq 0x49efd0
leaq -0x38(%rbp), %rdi
leaq 0x1a271c(%rip), %rsi    # 0x5b632f
xorl %eax, %eax
movl %eax, %edx
callq 0x4a0b30
movq %rax, -0x7f0(%rbp)
leaq -0x830(%rbp), %rdi
callq 0x49efd0
jmp 0x4138e4
movq -0xb20(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
leaq -0x38(%rbp), %rsi
callq 0x416180
movq %rax, -0xb58(%rbp)
jmp 0x413c54
movq -0xb20(%rbp), %rdi
movq -0xb58(%rbp), %rax
movq %rax, -0x870(%rbp)
addq $0x158, %rdi            # imm = 0x158
callq 0x40d970
movq %rax, -0x878(%rbp)
leaq -0x870(%rbp), %rdi
leaq -0x878(%rbp), %rsi
callq 0x416150
testb $0x1, %al
jne 0x413c98
jmp 0x413d27
movq -0xb20(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
leaq -0x38(%rbp), %rsi
callq 0x40bc10
movq %rax, -0xb60(%rbp)
jmp 0x413cb8
movq -0xb60(%rbp), %rdi
movq -0xb20(%rbp), %rsi
addq $0x108, %rsi            # imm = 0x108
callq 0x4a1030
movl %eax, -0xb64(%rbp)
jmp 0x413cda
movl -0xb64(%rbp), %eax
cmpl $0x0, %eax
jne 0x413d05
movw $0x0, -0x87a(%rbp)
leaq -0x7e8(%rbp), %rdi
leaq -0x87a(%rbp), %rsi
callq 0x4161b0
jmp 0x413d03
jmp 0x413d25
movw $0x1, -0x87c(%rbp)
leaq -0x7e8(%rbp), %rdi
leaq -0x87c(%rbp), %rsi
callq 0x4161b0
jmp 0x413d23
jmp 0x413d25
jmp 0x413d47
movw $0xffff, -0x87e(%rbp)   # imm = 0xFFFF
leaq -0x7e8(%rbp), %rdi
leaq -0x87e(%rbp), %rsi
callq 0x4161b0
jmp 0x413d45
jmp 0x413d47
jmp 0x413d49
leaq -0x3d0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a1890
movq %rax, -0xb70(%rbp)
jmp 0x413d62
movq -0xb70(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x479520
movb %al, -0xb71(%rbp)
jmp 0x413d80
movb -0xb71(%rbp), %al
testb $0x1, %al
jne 0x413d8f
jmp 0x414b1f
leaq -0x8a0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a15e0
jmp 0x413da1
leaq 0x1a2587(%rip), %rsi    # 0x5b632f
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rdi
movq %rdi, -0xb80(%rbp)
callq 0x4a0b30
movq -0xb80(%rbp), %rsi
movq %rax, -0x7f0(%rbp)
movq -0x7f0(%rbp), %rdx
incq %rdx
leaq -0x8c0(%rbp), %rdi
movq $-0x1, %rcx
callq 0x4a1800
jmp 0x413de9
leaq -0x38(%rbp), %rdi
leaq -0x8c0(%rbp), %rsi
callq 0x49f020
leaq -0x8c0(%rbp), %rdi
callq 0x49efd0
leaq -0x38(%rbp), %rdi
leaq 0x1a251f(%rip), %rsi    # 0x5b632f
xorl %eax, %eax
movl %eax, %edx
callq 0x4a0b30
movq %rax, -0x7f0(%rbp)
leaq -0x8d8(%rbp), %rdi
callq 0x40be60
leaq -0x8f0(%rbp), %rdi
callq 0x40be60
movl $0x0, -0x8f4(%rbp)
movl $0x0, -0x8f8(%rbp)
movl $0x0, -0x8fc(%rbp)
leaq -0x920(%rbp), %rdi
callq 0x49eec0
cmpq $-0x1, -0x7f0(%rbp)
je 0x414025
movq -0x7f0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x940(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4a1800
jmp 0x413e8d
xorl %eax, %eax
movl %eax, %esi
leaq -0x940(%rbp), %rdi
callq 0x4161e0
movss %xmm0, -0xb84(%rbp)
jmp 0x413ea7
movss -0xb84(%rbp), %xmm0
movss %xmm0, -0x944(%rbp)
movslq -0x8f4(%rbp), %rsi
leaq -0x7e8(%rbp), %rdi
callq 0x416220
movswl (%rax), %eax
cmpl $0x0, %eax
jne 0x413f56
leaq -0x8d8(%rbp), %rdi
leaq -0x944(%rbp), %rsi
callq 0x416240
jmp 0x413eeb
movss -0x944(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x413f54
movl -0x8f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f8(%rbp)
jmp 0x413f54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414b11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414aed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x940(%rbp), %rdi
callq 0x49efd0
jmp 0x414aed
jmp 0x413fab
movslq -0x8f4(%rbp), %rsi
leaq -0x7e8(%rbp), %rdi
callq 0x416220
movswl (%rax), %eax
cmpl $0x1, %eax
jne 0x413fa9
leaq -0x8f0(%rbp), %rdi
leaq -0x944(%rbp), %rsi
callq 0x416240
jmp 0x413f86
movss -0x944(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x413fa7
jp 0x413fa7
movl -0x8fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8fc(%rbp)
jmp 0x413fa9
jmp 0x413fab
movq -0x7f0(%rbp), %rdx
incq %rdx
leaq -0x968(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movq $-0x1, %rcx
callq 0x4a1800
jmp 0x413fce
leaq -0x38(%rbp), %rdi
leaq -0x968(%rbp), %rsi
callq 0x49f020
leaq -0x968(%rbp), %rdi
callq 0x49efd0
leaq -0x38(%rbp), %rdi
leaq 0x1a233a(%rip), %rsi    # 0x5b632f
xorl %eax, %eax
movl %eax, %edx
callq 0x4a0b30
movq %rax, -0x7f0(%rbp)
movl -0x8f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f4(%rbp)
leaq -0x940(%rbp), %rdi
callq 0x49efd0
jmp 0x413e62
cvtsi2ssl -0x8f8(%rbp), %xmm0
movss %xmm0, -0xb90(%rbp)
leaq -0x8d8(%rbp), %rdi
callq 0x40fbc0
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xb8c(%rbp)
testq %rax, %rax
movss %xmm0, -0xb88(%rbp)
js 0x414082
movss -0xb8c(%rbp), %xmm0
movss %xmm0, -0xb88(%rbp)
movss -0xb90(%rbp), %xmm0
movss -0xb88(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xba0(%rbp)
cvtsi2ssl -0x8fc(%rbp), %xmm0
movss %xmm0, -0xb9c(%rbp)
leaq -0x8f0(%rbp), %rdi
callq 0x40fbc0
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xb98(%rbp)
testq %rax, %rax
movss %xmm0, -0xb94(%rbp)
js 0x4140fb
movss -0xb98(%rbp), %xmm0
movss %xmm0, -0xb94(%rbp)
movss -0xba0(%rbp), %xmm0
movss -0xb9c(%rbp), %xmm1
movss -0xb94(%rbp), %xmm2
divss %xmm2, %xmm1
addss %xmm1, %xmm0
movss 0x1a2395(%rip), %xmm1   # 0x5b64b8
divss %xmm1, %xmm0
movss %xmm0, -0x96c(%rbp)
movss -0x96c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1a236d(%rip), %xmm1   # 0x5b64b0
ucomisd %xmm1, %xmm0
jbe 0x414167
movq -0xb20(%rbp), %rsi
addq $0x108, %rsi            # imm = 0x108
leaq -0x920(%rbp), %rdi
callq 0x49f000
jmp 0x414165
jmp 0x41419b
movq -0xb20(%rbp), %rsi
addq $0x130, %rsi            # imm = 0x130
leaq -0x920(%rbp), %rdi
callq 0x49f000
jmp 0x414183
movss 0x1a2331(%rip), %xmm0   # 0x5b64bc
subss -0x96c(%rbp), %xmm0
movss %xmm0, -0x96c(%rbp)
movq -0xb20(%rbp), %rax
movss -0x96c(%rbp), %xmm0
ucomiss 0x10(%rax), %xmm0
jb 0x414296
leaq -0x5d0(%rbp), %rdi
leaq -0x8a0(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xba8(%rbp)
jmp 0x4141d0
movq -0xba8(%rbp), %rdi
movl $0x9, %esi
callq 0x498b30
movq %rax, -0xbb0(%rbp)
jmp 0x4141ea
movss -0x96c(%rbp), %xmm0
leaq -0x990(%rbp), %rdi
callq 0x4162b0
jmp 0x414200
movq -0xbb0(%rbp), %rdi
leaq -0x990(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xbb8(%rbp)
jmp 0x41421c
movq -0xbb8(%rbp), %rdi
movl $0x9, %esi
callq 0x498b30
movq %rax, -0xbc0(%rbp)
jmp 0x414236
movq -0xbc0(%rbp), %rdi
leaq -0x920(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xbc8(%rbp)
jmp 0x414252
movq -0xbc8(%rbp), %rdi
movl $0xa, %esi
callq 0x498b30
jmp 0x414265
leaq -0x990(%rbp), %rdi
callq 0x49efd0
jmp 0x414a7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x990(%rbp), %rdi
callq 0x49efd0
jmp 0x414aed
leaq -0x8d8(%rbp), %rdi
leaq -0x8f0(%rbp), %rsi
callq 0x42ae20
movss %xmm0, -0xbcc(%rbp)
jmp 0x4142b3
movq -0xb20(%rbp), %rax
movss -0xbcc(%rbp), %xmm0
movss %xmm0, -0x994(%rbp)
movss -0x994(%rbp), %xmm1
movss 0x14(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x414a7b
leaq -0x9b0(%rbp), %rdi
callq 0x416300
leaq -0x8d8(%rbp), %rax
movq %rax, -0x9b8(%rbp)
movq -0x9b8(%rbp), %rdi
callq 0x40fac0
movq %rax, -0x9c0(%rbp)
movq -0x9b8(%rbp), %rdi
callq 0x40f900
movq %rax, -0x9c8(%rbp)
leaq -0x9c0(%rbp), %rdi
leaq -0x9c8(%rbp), %rsi
callq 0x416320
testb $0x1, %al
jne 0x41433c
jmp 0x41446e
leaq -0x9c0(%rbp), %rdi
callq 0x40fe90
movss (%rax), %xmm0
movss %xmm0, -0x9cc(%rbp)
movss -0x9cc(%rbp), %xmm0
movss %xmm0, -0xa1c(%rbp)
leaq -0xa1c(%rbp), %rax
movq %rax, -0xa18(%rbp)
movq $0x1, -0xa10(%rbp)
leaq -0xa1d(%rbp), %rdi
movq %rdi, -0xbd8(%rbp)
callq 0x40cbd0
movq -0xbd8(%rbp), %rcx
movq -0xa18(%rbp), %rsi
movq -0xa10(%rbp), %rdx
leaq -0xa08(%rbp), %rdi
callq 0x416390
jmp 0x4143b3
leaq -0x9f0(%rbp), %rdi
leaq -0xa08(%rbp), %rsi
xorl %edx, %edx
callq 0x416410
jmp 0x4143ca
leaq -0x9b0(%rbp), %rdi
leaq -0x9f0(%rbp), %rsi
callq 0x416360
jmp 0x4143df
leaq -0x9f0(%rbp), %rdi
callq 0x416440
leaq -0xa08(%rbp), %rdi
callq 0x40c2b0
leaq -0xa1d(%rbp), %rdi
callq 0x4108f0
leaq -0x9c0(%rbp), %rdi
callq 0x416460
jmp 0x414320
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x41445d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414451
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x9f0(%rbp), %rdi
callq 0x416440
leaq -0xa08(%rbp), %rdi
callq 0x40c2b0
leaq -0xa1d(%rbp), %rdi
callq 0x4108f0
jmp 0x414a6d
leaq -0x8f0(%rbp), %rax
movq %rax, -0xa28(%rbp)
movq -0xa28(%rbp), %rdi
callq 0x40fac0
movq %rax, -0xa30(%rbp)
movq -0xa28(%rbp), %rdi
callq 0x40f900
movq %rax, -0xa38(%rbp)
leaq -0xa30(%rbp), %rdi
leaq -0xa38(%rbp), %rsi
callq 0x416320
testb $0x1, %al
jne 0x4144be
jmp 0x4145f3
leaq -0xa30(%rbp), %rdi
callq 0x40fe90
movss (%rax), %xmm0
movss %xmm0, -0xa3c(%rbp)
movss -0xa3c(%rbp), %xmm0
movss %xmm0, -0xa8c(%rbp)
leaq -0xa8c(%rbp), %rax
movq %rax, -0xa88(%rbp)
movq $0x1, -0xa80(%rbp)
leaq -0xa8d(%rbp), %rdi
movq %rdi, -0xbe0(%rbp)
callq 0x40cbd0
movq -0xbe0(%rbp), %rcx
movq -0xa88(%rbp), %rsi
movq -0xa80(%rbp), %rdx
leaq -0xa78(%rbp), %rdi
callq 0x416390
jmp 0x414535
leaq -0xa60(%rbp), %rdi
leaq -0xa78(%rbp), %rsi
movl $0x1, %edx
callq 0x416410
jmp 0x41454f
leaq -0x9b0(%rbp), %rdi
leaq -0xa60(%rbp), %rsi
callq 0x416360
jmp 0x414564
leaq -0xa60(%rbp), %rdi
callq 0x416440
leaq -0xa78(%rbp), %rdi
callq 0x40c2b0
leaq -0xa8d(%rbp), %rdi
callq 0x4108f0
leaq -0xa30(%rbp), %rdi
callq 0x416460
jmp 0x4144a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4145e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4145d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xa60(%rbp), %rdi
callq 0x416440
leaq -0xa78(%rbp), %rdi
callq 0x40c2b0
leaq -0xa8d(%rbp), %rdi
callq 0x4108f0
jmp 0x414a6d
leaq -0xaa8(%rbp), %rdi
leaq -0x9b0(%rbp), %rsi
callq 0x416480
jmp 0x414608
leaq -0xae0(%rbp), %rdi
leaq -0x9b0(%rbp), %rsi
callq 0x42caa0
jmp 0x41461d
leaq -0xae0(%rbp), %rdi
callq 0x42cc30
jmp 0x41462b
leaq -0xae0(%rbp), %rdi
leaq -0xaa8(%rbp), %rsi
callq 0x42d4a0
jmp 0x414640
movl $0x0, -0x8fc(%rbp)
movl $0x0, -0x8f8(%rbp)
movl $0x0, -0xae4(%rbp)
movl -0xae4(%rbp), %eax
movq %rax, -0xbe8(%rbp)
leaq -0x8d8(%rbp), %rdi
callq 0x40fbc0
movq %rax, %rcx
movq -0xbe8(%rbp), %rax
cmpq %rcx, %rax
jae 0x41472c
movl -0xae4(%rbp), %eax
movl %eax, %esi
leaq -0xaa8(%rbp), %rdi
callq 0x416570
movl 0x18(%rax), %eax
movl %eax, -0xbec(%rbp)
movl -0xae4(%rbp), %eax
movl %eax, %esi
leaq -0x9b0(%rbp), %rdi
callq 0x416570
movq %rax, %rcx
movl -0xbec(%rbp), %eax
cmpl 0x18(%rcx), %eax
jne 0x414716
movl -0x8f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f8(%rbp)
jmp 0x414716
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414a6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414a61
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x414a55
jmp 0x414718
movl -0xae4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xae4(%rbp)
jmp 0x41465e
movl $0x0, -0xae8(%rbp)
movl -0xae8(%rbp), %eax
movq %rax, -0xbf8(%rbp)
leaq -0x8d8(%rbp), %rdi
callq 0x40fbc0
movq %rax, %rcx
movq -0xbf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x4147c2
movl -0xae8(%rbp), %eax
movl %eax, %esi
leaq -0xaa8(%rbp), %rdi
callq 0x416570
movl 0x18(%rax), %eax
movl %eax, -0xbfc(%rbp)
movl -0xae8(%rbp), %eax
movl %eax, %esi
leaq -0x9b0(%rbp), %rdi
callq 0x416570
movq %rax, %rcx
movl -0xbfc(%rbp), %eax
cmpl 0x18(%rcx), %eax
jne 0x4147ac
movl -0x8fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8fc(%rbp)
jmp 0x4147ae
movl -0xae8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xae8(%rbp)
jmp 0x414736
cvtsi2ssl -0x8f8(%rbp), %xmm0
movss %xmm0, -0xc08(%rbp)
leaq -0x8d8(%rbp), %rdi
callq 0x40fbc0
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xc04(%rbp)
testq %rax, %rax
movss %xmm0, -0xc00(%rbp)
js 0x41481f
movss -0xc04(%rbp), %xmm0
movss %xmm0, -0xc00(%rbp)
movss -0xc08(%rbp), %xmm0
movss -0xc00(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xc18(%rbp)
cvtsi2ssl -0x8fc(%rbp), %xmm0
movss %xmm0, -0xc14(%rbp)
leaq -0x8f0(%rbp), %rdi
callq 0x40fbc0
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xc10(%rbp)
testq %rax, %rax
movss %xmm0, -0xc0c(%rbp)
js 0x414898
movss -0xc10(%rbp), %xmm0
movss %xmm0, -0xc0c(%rbp)
movq -0xb20(%rbp), %rax
movss -0xc18(%rbp), %xmm0
movss -0xc14(%rbp), %xmm1
movss -0xc0c(%rbp), %xmm2
divss %xmm2, %xmm1
addss %xmm1, %xmm0
movss 0x1a1bf1(%rip), %xmm1   # 0x5b64b8
divss %xmm1, %xmm0
movss %xmm0, -0xaec(%rbp)
movss -0xaec(%rbp), %xmm0
ucomiss 0x18(%rax), %xmm0
jb 0x414a2f
leaq -0x7d0(%rbp), %rdi
leaq -0x8a0(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xc20(%rbp)
jmp 0x414901
movq -0xc20(%rbp), %rdi
movl $0x9, %esi
callq 0x498b30
movq %rax, -0xc28(%rbp)
jmp 0x41491b
movss -0x96c(%rbp), %xmm0
leaq -0xb10(%rbp), %rdi
callq 0x4162b0
jmp 0x414931
movq -0xc28(%rbp), %rdi
leaq -0xb10(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xc30(%rbp)
jmp 0x41494d
movq -0xc30(%rbp), %rdi
movl $0x9, %esi
callq 0x498b30
movq %rax, -0xc38(%rbp)
jmp 0x414967
movq -0xc38(%rbp), %rdi
movss -0x994(%rbp), %xmm0
callq 0x499b80
movq %rax, -0xc40(%rbp)
jmp 0x414984
movq -0xc40(%rbp), %rdi
movl $0x9, %esi
callq 0x498b30
movq %rax, -0xc48(%rbp)
jmp 0x41499e
movq -0xc48(%rbp), %rdi
movss -0xaec(%rbp), %xmm0
callq 0x499b80
movq %rax, -0xc50(%rbp)
jmp 0x4149bb
movq -0xc50(%rbp), %rdi
movl $0x9, %esi
callq 0x498b30
movq %rax, -0xc58(%rbp)
jmp 0x4149d5
movq -0xc58(%rbp), %rdi
leaq -0x920(%rbp), %rsi
callq 0x4a1880
movq %rax, -0xc60(%rbp)
jmp 0x4149f1
movq -0xc60(%rbp), %rdi
movl $0xa, %esi
callq 0x498b30
jmp 0x414a04
leaq -0xb10(%rbp), %rdi
callq 0x49efd0
jmp 0x414a2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xb10(%rbp), %rdi
callq 0x49efd0
jmp 0x414a55
leaq -0xae0(%rbp), %rdi
callq 0x416590
leaq -0xaa8(%rbp), %rdi
callq 0x4165c0
leaq -0x9b0(%rbp), %rdi
callq 0x4165c0
jmp 0x414a7b
leaq -0xae0(%rbp), %rdi
callq 0x416590
leaq -0xaa8(%rbp), %rdi
callq 0x4165c0
leaq -0x9b0(%rbp), %rdi
callq 0x4165c0
jmp 0x414aed
jmp 0x414a7d
leaq 0x225c44(%rip), %rdi    # 0x63a6c8
callq 0x40b4f0
jmp 0x414a8b
leaq -0x8a0(%rbp), %rdi
callq 0x49f1f0
movq 0x225c1a(%rip), %rcx    # 0x63a6b8
leaq 0x1(%rax,%rcx), %rax
movq %rax, 0x225c0e(%rip)    # 0x63a6b8
leaq 0x225c17(%rip), %rdi    # 0x63a6c8
callq 0x40b520
jmp 0x414ab8
leaq -0x920(%rbp), %rdi
callq 0x49efd0
leaq -0x8f0(%rbp), %rdi
callq 0x40c2b0
leaq -0x8d8(%rbp), %rdi
callq 0x40c2b0
leaq -0x8a0(%rbp), %rdi
callq 0x49efd0
jmp 0x413d49
leaq -0x920(%rbp), %rdi
callq 0x49efd0
leaq -0x8f0(%rbp), %rdi
callq 0x40c2b0
leaq -0x8d8(%rbp), %rdi
callq 0x40c2b0
leaq -0x8a0(%rbp), %rdi
callq 0x49efd0
jmp 0x414b8b
leaq -0x7e8(%rbp), %rdi
callq 0x416620
leaq -0x7d0(%rbp), %rdi
callq 0x475cb0
leaq -0x5d0(%rbp), %rdi
callq 0x475cb0
leaq -0x3d0(%rbp), %rdi
callq 0x475df0
leaq -0x148(%rbp), %rdi
callq 0x49efd0
leaq -0xa8(%rbp), %rdi
callq 0x49efd0
leaq -0x78(%rbp), %rdi
callq 0x49efd0
leaq -0x58(%rbp), %rdi
callq 0x49efd0
leaq -0x38(%rbp), %rdi
callq 0x49efd0
addq $0xc60, %rsp            # imm = 0xC60
popq %rbp
retq
leaq -0x7e8(%rbp), %rdi
callq 0x416620
leaq -0x7d0(%rbp), %rdi
callq 0x475cb0
leaq -0x5d0(%rbp), %rdi
callq 0x475cb0
leaq -0x3d0(%rbp), %rdi
callq 0x475df0
leaq -0x148(%rbp), %rdi
callq 0x49efd0
leaq -0xa8(%rbp), %rdi
callq 0x49efd0
leaq -0x78(%rbp), %rdi
callq 0x49efd0
leaq -0x58(%rbp), %rdi
callq 0x49efd0
leaq -0x38(%rbp), %rdi
callq 0x49efd0
movq -0x80(%rbp), %rdi
callq 0x4d3c10
nopw (%rax,%rax)