// File: /workspace/github_cpp_makefile_star2_O1/WeiqiangZhou[P]BIRD/source/predict_function.cpp
// Function: WriteWIG(double**, char**, 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>>>>, char*, int, int, int, int, double, int)
int WriteWIG(double **data_out, char **select_idx, std::vector<std::string> outname, char *outfile, int bin_size, int loci_length, int sample_size, int flag, double up_bound, int flag_log)
{
	char *part;
	char temp_name[255];
	char chrname[10];
	int startsite, count;
	double value;
	FILE * pFile;

	//standard output
	if (flag != 1)
	{
		pFile = fopen(outfile, "w");
		if (pFile != NULL)
		{
			fprintf(pFile, "Chromosome\tStart\tEnd\t");
			for (int i = 0; i < sample_size-1; i++)
			{
				fprintf(pFile, "%s\t", outname[i].c_str());
			}
			fprintf(pFile, "%s\n", outname[sample_size-1].c_str());
			for (int i = 0; i < loci_length; i++)
			{
				fprintf(pFile, "%s\t", select_idx[i]);
				for (int j = 0; j < sample_size-1; j++)
				{
					value = data_out[j][i];
					if (value < 0)
					{
						value = 0;
					}
					else if (value > up_bound)
					{
						value = up_bound;
					}
					fprintf(pFile, "%lf\t", value);   //report original output value, log2(x+1) transformed.
				}

				value = data_out[sample_size-1][i];
				if (value < 0)
				{
					value = 0;
				}
				else if (value > up_bound)
				{
					value = up_bound;
				}
				fprintf(pFile, "%lf\n", value);

			}
			fclose(pFile);
		}
		else
		{
			std::cout << "Error! Cannot write file " << outfile << std::endl;
			return 1;
		}


	}
	else    //WIG output
	{
		std::vector<std::vector<int> > location;
		std::vector<int>::iterator it;
		for (int i = 0; i < 23; i++)
		{
			location.push_back(std::vector<int>());
		}

		for (int i = 0; i < loci_length; i++)
		{
			part = strtok(select_idx[i], "\t\0");
			if (strcmp(part, "chrX") == 0)
			{
				part = strtok(NULL, "\t\0");
				startsite = atoi(part);
				location[22].push_back(startsite);
			}
			else
			{
				for (int j = 0; j < 22; j++)
				{
					sprintf(chrname, "chr%d", j + 1);
					if (strcmp(part, chrname) == 0)
					{
						part = strtok(NULL, "\t\0");
						startsite = atoi(part);
						location[j].push_back(startsite);
						break;
					}
				}
			}
		}
        
        if (flag_log != 1)
        {
            for (int i = 0; i < sample_size; i++)
            {
                count = 0;
                strcpy(temp_name, outfile);
                strcat(temp_name, ".");
                strcat(temp_name, outname[i].c_str());
                strcat(temp_name, ".wig");
                std::cout << "Writing file " << temp_name << std::endl;
                pFile = fopen(temp_name, "w");
                if (pFile != NULL)
                {
                    fprintf(pFile, "track\ttype=wiggle_0\tname=%s\tvisibility=full\tautoScale=off\tmaxHeightPixels=100:50:10\tviewLimits=0.0:100.0\tyLineOnOff=off\n", outname[i].c_str());
                    //print chr1-chr22
                    for (int j = 0; j < 22; j++)
                    {
                        fprintf(pFile, "variableStep\tchrom=chr%d\tspan=%d\n", j + 1, bin_size);
                        for (it = location[j].begin(); it != location[j].end(); it++)
                        {
                            value = pow(2, data_out[i][count]) - 1;
                            if (value < 0)
                            {
                                value = 0;
                            }
                            else if (value > pow(2,up_bound))
                            {
                                value = pow(2,up_bound);
                            }
                            count++;
                            fprintf(pFile, "%d\t%lf\n", (*it), value);        //report value is limited from 0 to 10000.
                        }
                    }
                    //print chrX
                    fprintf(pFile, "variableStep\tchrom=chrX\tspan=%d\n", bin_size);
                    for (it = location[22].begin(); it != location[22].end(); it++)
                    {
                        value = pow(2, data_out[i][count]) - 1;
                        if (value < 0)
                        {
                            value = 0;
                        }
                        else if (value > pow(2,up_bound))
                        {
                            value = pow(2,up_bound);
                        }
                        count++;
                        fprintf(pFile, "%d\t%lf\n", (*it), value);
                    }

                    fclose(pFile);
                }
                else
                {
                    std::cout << "Error! Cannot write file " << temp_name << std::endl;
                    return 1;
                }

            }
        }
        else
        {
            for (int i = 0; i < sample_size; i++)
            {
                count = 0;
                strcpy(temp_name, outfile);
                strcat(temp_name, ".");
                strcat(temp_name, outname[i].c_str());
                strcat(temp_name, ".wig");
                std::cout << "Writing file " << temp_name << std::endl;
                pFile = fopen(temp_name, "w");
                if (pFile != NULL)
                {
                    fprintf(pFile, "track\ttype=wiggle_0\tname=%s\tvisibility=full\tautoScale=off\tmaxHeightPixels=100:50:10\tviewLimits=0.0:100.0\tyLineOnOff=off\n", outname[i].c_str());
                    //print chr1-chr22
                    for (int j = 0; j < 22; j++)
                    {
                        fprintf(pFile, "variableStep\tchrom=chr%d\tspan=%d\n", j + 1, bin_size);
                        for (it = location[j].begin(); it != location[j].end(); it++)
                        {
                            value = data_out[i][count];
                            if (value < 0)
                            {
                                value = 0;
                            }
                            else if (value > up_bound)
                            {
                                value = up_bound;
                            }
                            count++;
                            fprintf(pFile, "%d\t%lf\n", (*it), value);        //report value is limited from 0 to 10000.
                        }
                    }
                    //print chrX
                    fprintf(pFile, "variableStep\tchrom=chrX\tspan=%d\n", bin_size);
                    for (it = location[22].begin(); it != location[22].end(); it++)
                    {
                        value = data_out[i][count];
                        if (value < 0)
                        {
                            value = 0;
                        }
                        else if (value > up_bound)
                        {
                            value = up_bound;
                        }
                        count++;
                        fprintf(pFile, "%d\t%lf\n", (*it), value);
                    }

                    fclose(pFile);
                }
                else
                {
                    std::cout << "Error! Cannot write file " << temp_name << std::endl;
                    return 1;
                }

            }
        }
        
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movsd %xmm0, -0x30(%rbp)
movl %r9d, %r13d
movl %r8d, -0x40(%rbp)
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, -0x50(%rbp)
movq %rdi, -0x58(%rbp)
movl 0x10(%rbp), %r12d
cmpl $0x1, 0x18(%rbp)
jne 0x5d50
movq %r15, -0x90(%rbp)
movq %rbx, -0x60(%rbp)
xorpd %xmm0, %xmm0
leaq -0x80(%rbp), %r14
movapd %xmm0, (%r14)
movq $0x0, 0x10(%r14)
movl $0x17, %ebx
leaq -0xb0(%rbp), %r12
xorpd %xmm0, %xmm0
movapd %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x7266
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x59c4
callq 0x21d0
decl %ebx
jne 0x5991
testl %r13d, %r13d
jle 0x5b08
movl %r13d, %eax
movq %rax, -0x88(%rbp)
leaq 0x2ebd(%rip), %r15      # 0x889f
xorl %ecx, %ecx
movq -0x50(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq (%rax,%rcx,8), %rdi
movq %r15, %rsi
callq 0x2300
movq %rax, %r14
movq %rax, %rdi
leaq 0x2b31(%rip), %rsi      # 0x8536
callq 0x2290
testl %eax, %eax
je 0x5a94
movl $0x18, %r15d
movq $-0x10, %r13
movl $0x1, %r12d
cmpl $0xfffffe08, %r15d      # imm = 0xFFFFFE08
je 0x5aed
leaq -0xba(%rbp), %rbx
movq %rbx, %rdi
leaq 0x2af8(%rip), %rsi      # 0x853b
movl %r12d, %edx
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2290
addq $-0x18, %r15
addq $0x18, %r13
incl %r12d
testl %eax, %eax
jne 0x5a25
xorl %edi, %edi
leaq 0x2e2f(%rip), %rsi      # 0x889f
callq 0x2300
movq %rax, %rdi
callq 0x22f0
movl %eax, -0x44(%rbp)
movq -0x80(%rbp), %rdi
movq (%rdi,%r13), %rsi
cmpq 0x8(%rdi,%r13), %rsi
je 0x5ae1
addq %r13, %rdi
jmp 0x5ac4
xorl %edi, %edi
movq %r15, %rsi
callq 0x2300
movq %rax, %rdi
callq 0x22f0
movl %eax, -0x44(%rbp)
movq -0x80(%rbp), %rdi
movq 0x218(%rdi), %rsi
cmpq 0x220(%rdi), %rsi
je 0x5acf
addq $0x218, %rdi            # imm = 0x218
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, (%rdi)
jmp 0x5aed
addq $0x210, %rdi            # imm = 0x210
leaq -0x44(%rbp), %rdx
callq 0x7478
jmp 0x5aed
subq %r15, %rdi
leaq -0x44(%rbp), %rdx
callq 0x7478
movq -0x38(%rbp), %rcx
incq %rcx
cmpq -0x88(%rbp), %rcx
leaq 0x2d9d(%rip), %r15      # 0x889f
jne 0x59e4
movl 0x10(%rbp), %eax
cmpl $0x1, 0x20(%rbp)
jne 0x5ebe
testl %eax, %eax
movq -0x60(%rbp), %r15
jle 0x614f
movl %eax, %eax
movq %rax, -0x50(%rbp)
leaq -0x1c0(%rbp), %r13
movq 0x64a3(%rip), %r14      # 0xbfd8
xorl %r12d, %r12d
movq %r13, %rdi
movq -0x90(%rbp), %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x2100
movw $0x2e, -0x1c0(%rbp,%rax)
movq %r15, %rbx
movq (%r15), %rax
movq %r12, %r15
shlq $0x5, %r15
movq (%rax,%r15), %rsi
movq %r13, %rdi
callq 0x2390
movq %r13, %rdi
callq 0x2100
movl $0x6769772e, -0x1c0(%rbp,%rax) # imm = 0x6769772E
movb $0x0, -0x1bc(%rbp,%rax)
movl $0xd, %edx
movq %r14, %rdi
leaq 0x29aa(%rip), %rsi      # 0x8546
callq 0x2230
movq %r13, %rdi
callq 0x2100
movq %r14, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2230
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq %r13, %rdi
leaq 0x266c(%rip), %rsi      # 0x8254
callq 0x2240
testq %rax, %rax
je 0x61a2
movq %rax, %r14
movq (%rbx), %rax
movq (%rax,%r15), %rdx
xorl %ebx, %ebx
movq %r14, %rdi
leaq 0x2948(%rip), %rsi      # 0x8554
xorl %eax, %eax
callq 0x22a0
xorl %r15d, %r15d
leaq 0x1(%rbx), %rdx
movq %r14, %rdi
leaq 0x29a9(%rip), %rsi      # 0x85cd
movq %rdx, -0x38(%rbp)
movl -0x40(%rbp), %ecx
xorl %eax, %eax
callq 0x22a0
movq -0x80(%rbp), %rax
leaq (%rbx,%rbx,2), %rbx
movq (%rax,%rbx,8), %r13
cmpq 0x8(%rax,%rbx,8), %r13
je 0x5c97
movslq %r15d, %r15
movq -0x58(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r15,8), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x5c70
ucomisd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
jbe 0x5c70
movsd -0x30(%rbp), %xmm0
incq %r15
movl (%r13), %edx
movq %r14, %rdi
leaq 0x296e(%rip), %rsi      # 0x85ef
movb $0x1, %al
callq 0x22a0
addq $0x4, %r13
movq -0x80(%rbp), %rax
cmpq 0x8(%rax,%rbx,8), %r13
jne 0x5c48
movq -0x38(%rbp), %rbx
cmpq $0x16, %rbx
jne 0x5c16
movq %r14, %rdi
leaq 0x2948(%rip), %rsi      # 0x85f7
movl -0x40(%rbp), %edx
xorl %eax, %eax
callq 0x22a0
movq -0x80(%rbp), %rax
movq 0x210(%rax), %rbx
cmpq 0x218(%rax), %rbx
leaq -0x1c0(%rbp), %r13
je 0x5d2b
movslq %r15d, %r15
shlq $0x3, %r15
movq -0x58(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r15), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x5d03
ucomisd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
jbe 0x5d03
movsd -0x30(%rbp), %xmm0
movl (%rbx), %edx
movq %r14, %rdi
leaq 0x28e0(%rip), %rsi      # 0x85ef
movb $0x1, %al
callq 0x22a0
addq $0x4, %rbx
movq -0x80(%rbp), %rax
addq $0x8, %r15
cmpq 0x218(%rax), %rbx
jne 0x5cdb
movq %r14, %rdi
callq 0x21f0
incq %r12
cmpq -0x50(%rbp), %r12
movq -0x60(%rbp), %r15
movq 0x6293(%rip), %r14      # 0xbfd8
jne 0x5b38
jmp 0x614f
leaq 0x24fd(%rip), %rsi      # 0x8254
movq %r15, %rdi
callq 0x2240
testq %rax, %rax
je 0x615f
movq %rax, %r14
movl %r13d, -0x40(%rbp)
leaq 0x27aa(%rip), %rdi      # 0x8520
movl $0x15, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x23e0
leal -0x1(%r12), %eax
movl %eax, -0x38(%rbp)
movl %eax, %r15d
cmpl $0x2, %r12d
movq %rbx, %r12
jl 0x5dc7
movq %r15, %r13
shlq $0x5, %r13
xorl %ebx, %ebx
movq (%r12), %rax
movq (%rax,%rbx), %rdx
movq %r14, %rdi
leaq 0x26d9(%rip), %rsi      # 0x8490
xorl %eax, %eax
callq 0x22a0
addq $0x20, %rbx
cmpq %rbx, %r13
jne 0x5da5
movslq -0x38(%rbp), %rcx
movq (%r12), %rax
movq %rcx, -0x38(%rbp)
shlq $0x5, %rcx
movq (%rax,%rcx), %rdx
leaq 0x26ba(%rip), %rsi      # 0x849c
movq %r14, %rdi
xorl %eax, %eax
callq 0x22a0
movl -0x40(%rbp), %eax
testl %eax, %eax
jle 0x5eb1
movl %eax, %eax
movq %rax, -0x40(%rbp)
leaq 0x269c(%rip), %r13      # 0x84a0
xorl %r12d, %r12d
movq -0x50(%rbp), %rax
movq (%rax,%r12,8), %rdx
movq %r14, %rdi
leaq 0x2677(%rip), %rsi      # 0x8490
xorl %eax, %eax
callq 0x22a0
movl 0x10(%rbp), %eax
cmpl $0x2, %eax
jl 0x5e67
xorl %ebx, %ebx
movq -0x58(%rbp), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r12,8), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x5e52
ucomisd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
jbe 0x5e52
movsd -0x30(%rbp), %xmm0
movq %r14, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x22a0
incq %rbx
cmpq %rbx, %r15
jne 0x5e2a
movq -0x58(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r12,8), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x5e93
ucomisd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
jbe 0x5e93
movsd -0x30(%rbp), %xmm0
movq %r14, %rdi
leaq 0x2755(%rip), %rsi      # 0x85f2
movb $0x1, %al
callq 0x22a0
incq %r12
cmpq -0x40(%rbp), %r12
jne 0x5e07
movq %r14, %rdi
callq 0x21f0
jmp 0x6158
testl %eax, %eax
movq -0x60(%rbp), %r14
jle 0x614f
movl %eax, %eax
movq %rax, -0x88(%rbp)
leaq -0x1c0(%rbp), %r15
movq 0x60f7(%rip), %r13      # 0xbfd8
xorl %r12d, %r12d
movq %r15, %rdi
movq -0x90(%rbp), %rsi
callq 0x21c0
movq %r15, %rdi
callq 0x2100
movw $0x2e, -0x1c0(%rbp,%rax)
movq %r14, %rbx
movq (%r14), %rax
movq %r12, %r14
shlq $0x5, %r14
movq (%rax,%r14), %rsi
movq %r15, %rdi
callq 0x2390
movq %r15, %rdi
callq 0x2100
movl $0x6769772e, -0x1c0(%rbp,%rax) # imm = 0x6769772E
movb $0x0, -0x1bc(%rbp,%rax)
movl $0xd, %edx
movq %r13, %rdi
leaq 0x25fe(%rip), %rsi      # 0x8546
callq 0x2230
movq %r15, %rdi
callq 0x2100
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2230
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movq %r15, %rdi
leaq 0x22bf(%rip), %rsi      # 0x8254
callq 0x2240
testq %rax, %rax
je 0x620b
movq %rax, %r13
movq (%rbx), %rax
movq (%rax,%r14), %rdx
xorl %ebx, %ebx
movq %r13, %rdi
leaq 0x259b(%rip), %rsi      # 0x8554
xorl %eax, %eax
callq 0x22a0
xorl %r14d, %r14d
leaq 0x1(%rbx), %rdx
movq %r13, %rdi
leaq 0x25fc(%rip), %rsi      # 0x85cd
movq %rdx, -0x50(%rbp)
movl -0x40(%rbp), %ecx
xorl %eax, %eax
callq 0x22a0
movq -0x80(%rbp), %rax
leaq (%rbx,%rbx,2), %r15
movq (%rax,%r15,8), %rbx
cmpq 0x8(%rax,%r15,8), %rbx
je 0x606b
movslq %r14d, %r14
movq -0x58(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x21b0
movapd %xmm0, %xmm1
addsd 0x245c(%rip), %xmm1     # 0x8470
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x6046
movsd -0x30(%rbp), %xmm0
movsd %xmm1, -0x38(%rbp)
callq 0x21b0
movsd -0x38(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movapd %xmm1, %xmm0
jbe 0x6046
movsd -0x30(%rbp), %xmm0
callq 0x21b0
incq %r14
movl (%rbx), %edx
movq %r13, %rdi
leaq 0x259a(%rip), %rsi      # 0x85ef
movb $0x1, %al
callq 0x22a0
addq $0x4, %rbx
movq -0x80(%rbp), %rax
cmpq 0x8(%rax,%r15,8), %rbx
jne 0x5ff5
movq -0x50(%rbp), %rbx
cmpq $0x16, %rbx
jne 0x5fc3
movq %r13, %rdi
leaq 0x2574(%rip), %rsi      # 0x85f7
movl -0x40(%rbp), %edx
xorl %eax, %eax
callq 0x22a0
movq -0x80(%rbp), %rax
movq 0x210(%rax), %r15
cmpq 0x218(%rax), %r15
je 0x6125
movslq %r14d, %rbx
shlq $0x3, %rbx
movq -0x58(%rbp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%rbx), %xmm0
callq 0x21b0
movapd %xmm0, %xmm1
addsd 0x23a6(%rip), %xmm1     # 0x8470
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
ja 0x60fc
movsd -0x30(%rbp), %xmm0
movsd %xmm1, -0x38(%rbp)
callq 0x21b0
movsd -0x38(%rbp), %xmm1
ucomisd %xmm0, %xmm1
movapd %xmm1, %xmm0
jbe 0x60fc
movsd -0x30(%rbp), %xmm0
callq 0x21b0
movl (%r15), %edx
movq %r13, %rdi
leaq 0x24e6(%rip), %rsi      # 0x85ef
movb $0x1, %al
callq 0x22a0
addq $0x4, %r15
movq -0x80(%rbp), %rax
addq $0x8, %rbx
cmpq 0x218(%rax), %r15
jne 0x60ac
movq %r13, %rdi
callq 0x21f0
incq %r12
cmpq -0x88(%rbp), %r12
movq -0x60(%rbp), %r14
leaq -0x1c0(%rbp), %r15
movq 0x5e8f(%rip), %r13      # 0xbfd8
jne 0x5ee4
leaq -0x80(%rbp), %rdi
callq 0x66dc
xorl %eax, %eax
jmp 0x62c0
movq 0x5e72(%rip), %rbx      # 0xbfd8
leaq 0x2338(%rip), %rsi      # 0x84a5
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2230
testq %r15, %r15
je 0x627d
movq %r15, %rdi
callq 0x2100
movq 0x5e46(%rip), %rdi      # 0xbfd8
movq %r15, %rsi
movq %rax, %rdx
callq 0x2230
jmp 0x6294
movq 0x5e2f(%rip), %rdi      # 0xbfd8
leaq 0x22f5(%rip), %rsi      # 0x84a5
movl $0x19, %edx
callq 0x2230
leaq -0x1c0(%rbp), %r14
movq %r14, %rdi
callq 0x2100
movq 0x5e08(%rip), %rbx      # 0xbfd8
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2230
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x5ddc(%rip), %rdi      # 0xbfd8
callq 0x2040
movq %rax, %rdi
callq 0x2150
jmp 0x6272
movq 0x5dc6(%rip), %rdi      # 0xbfd8
leaq 0x228c(%rip), %rsi      # 0x84a5
movl $0x19, %edx
callq 0x2230
leaq -0x1c0(%rbp), %r14
movq %r14, %rdi
callq 0x2100
movq 0x5d9f(%rip), %rbx      # 0xbfd8
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2230
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq 0x5d73(%rip), %rdi      # 0xbfd8
callq 0x2040
movq %rax, %rdi
callq 0x2150
leaq -0x80(%rbp), %rdi
callq 0x66dc
jmp 0x62bb
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
movl $0x1, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x62dc
jmp 0x62dc
jmp 0x62dc
jmp 0x62dc
jmp 0x62dc
movq %rax, %rbx
jmp 0x62f5
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x62f5
callq 0x21d0
leaq -0x80(%rbp), %rdi
callq 0x66dc
movq %rbx, %rdi
callq 0x2380