// File: /workspace/github_c_makefile_star2_O2/stefpant[P]TCPserver/webcrawler/webcrawler.c
// Function: main
int main(int argc,char* argv[]){
	int s_port,c_port;
	int n_threads = 5;//by default 5 threads
	char *savedir = NULL;
	char *hostid = NULL;
	pid_t pid;//for calling jobExec and in the end wait termination
	char *starting_url = NULL;
	int flagSHUTDOWN=0;//when set 1 exit
	int flagSEARCH=1;//first time(if crawler ready) call jobExecutor
	int FIFOfd,FIFOfd2;
	printf("Parent %ld: just started!\n", pthread_self());
//~~~~~~~~~~~~~~~~~~~~~~~~~~PARSE ARGUMENTS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	if(input_parse(argc,argv,&s_port,&c_port,&n_threads,&savedir,&hostid,&starting_url) < 0){
		free(savedir);
		free(hostid);
		free(starting_url);
		exit(9);
	}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//~~~~~~~~~~~~~~~~~~~~~INIT: pool,mutexes,conditions~~~~~~~~~~~~~~~~~~~~~~~
	urlpool_init(&up);

	pthread_mutex_init(&mtx, 0);
	pthread_mutex_init(&mtxwt, 0);
	pthread_mutex_init(&pumtx, 0);
	pthread_mutex_init(&mtxcounter, 0);
	pthread_mutex_init(&mtxbytes, 0);
	pthread_cond_init(&cv_notempty, 0);
	pthread_cond_init(&cv_notfull, 0);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~MAKING THREADS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	pthread_t *tids = NULL;
	tids = malloc(n_threads*sizeof(pthread_t));

	tdata *dat;//struct to send to threads
	dat = malloc(sizeof(tdata));
	dat->port = s_port;
	dat->savedir = malloc((strlen(savedir)+1)*sizeof(char));
	strcpy(dat->savedir,savedir);
	dat->hostname = malloc((strlen(hostid)+1)*sizeof(char));
	strcpy(dat->hostname,hostid);

	for(int i=0; i<n_threads; i++)//create threads to execute threadExec
		pthread_create(tids+i,NULL,threadExec, (void *)dat);

	printf("Parent %ld: just created new threads!\n", pthread_self());
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	pthread_mutex_lock(&pumtx);
	placedurls=malloc(sizeof(char*));
	pucounter++;
	placedurls[0]=starting_url;
	pthread_mutex_unlock(&pumtx);
	//place starting url in pool
	place(&up, starting_url);
	pthread_cond_signal(&cv_notempty);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	time_t start,localend;
	int hh,mm,ss;
	time(&start);//crawler started
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~MAKING SOCKETS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	int c_sock,newcsock;
	struct sockaddr_in server;
	struct sockaddr * serverptr = (struct sockaddr *)&server;
	if( (c_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) //socket for command port
		{perror("socket");exit(9);}
	server.sin_family = AF_INET;
	server.sin_addr.s_addr = htonl(INADDR_ANY);
	server.sin_port = htons(c_port);

	if( setsockopt(c_sock, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 },sizeof(int)) < 0 )
		{perror("setsockopt");exit(9);}
	if( bind(c_sock,serverptr,sizeof(server)) < 0 ){perror("bind");exit(9);}
	if( listen(c_sock,100) < 0 ){perror("listen");exit(9);}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~INIT POLL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	struct pollfd pfd[1];
	pfd[0].fd = c_sock;
	pfd[0].events = POLLIN;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~LOOP:ACCEPTING CONNECTIONS~~~~~~~~~~~~~~~~~~~~~~~
	while( 1 ){//only on command port

		poll(pfd,1,-1);//wait a connection
		if(pfd[0].revents & POLLIN){//client on command port
			if( (newcsock = accept(c_sock,NULL,NULL)) < 0)
				{perror("accept");exit(9);}
			while(1){//1
				char *buf = malloc(9*sizeof(char));//should not be resized
				read_command(newcsock,&buf,9);
				if( !strcmp(buf,"STATS") ){
					time(&localend);
					localend -= start;
					hh = localend/3600;//creating time format
					localend -= hh*3600;
					mm = localend/60;
					ss = localend - mm*60;
					char* statrep=NULL;
					if(asprintf(&statrep,"Crawler up for %02d:%02d:%02d, downloaded %d pages, %d bytes\n",hh,mm,ss,totalrc,totalBytes) != -1){
						int len=strlen(statrep);
						write(newcsock,statrep,len+1);
						free(statrep);
					}
					//printf("Crawler up for %02d:%02d:%02d, downloaded %d pages, %d bytes\n",hh,mm,ss,totalrc,totalBytes);
				}
				else if( !strcmp(buf,"SHUTDOWN") ){
					close(newcsock);
					free(buf);
					flagSHUTDOWN=1;//2
					break;
				}
				else if( !strcmp(buf,"STOP") ){//3
					close(newcsock);//4
					free(buf);//5
					break;//6
				}//7
				else{
					char* ms=NULL;//maybe search command
					//printf("%s\n",buf);
					nextWord(buf,&ms,0);
					if( !strcmp(ms,"SEARCH") ){
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~check if crawling is over~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
						if( waitingThreads!=n_threads || up->count!=0 ){//pool not empty or some threads not waiting
							//printf("Crawling in progress,wait!\n");
							write(newcsock,"Crawling in progress,wait!\n",28);
							free(ms);free(buf);
							continue;
						}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
						
						if(flagSEARCH){//first time got SEARCH command,init some structs
							char* sdoc="docfile.txt";
							createDocfile(savedir,sdoc);
//~~~~~~~~~~~~~~~~~~~~fifo for crawler-jobExecutor communication~~~~~~~~~~~~~~~~~~~~~~
							if(mkfifo("../JECfifo",0666) == -1){
								if(errno != EEXIST){
									perror("mkfifo");
									exit(21);
								}
								else{//if fifo exists unlink it and make it again :-)
									unlink("../JECfifo");
									if(mkfifo("../JECfifo",0666) == -1){
										perror("mkfifo isn't working");
										exit(99);
									}
								}
							}
							if(mkfifo("../CJEfifo",0666) == -1){
								if(errno != EEXIST){
									perror("mkfifo");
									exit(21);
								}
								else{//if fifo exists unlink it and make it again :-)
									unlink("../CJEfifo");
									if(mkfifo("../CJEfifo",0666) == -1){
										perror("mkfifo isn't working");
										exit(99);
									}
								}
							}
							pid = fork();
							if(pid < 0){perror("fork");exit(87);}
							else if(pid == 0){//child call jobExecutor...
								close(newcsock);
								char *const args[]={//arguments for jobExecutor
												"../PantoulasStefanosProject2/jobExecutor",//executable
												"-d",//flag for docfile
												"docfile.txt",//docfile
												"-w",//flag for workers
												"5",//workers
												"-n",//flag for fifo names for C-jE communication
												"../JECfifo",//jE reads from C in this fifo
												"../CJEfifo",//C reads from jE in this fifo
												NULL};
								execv("../PantoulasStefanosProject2/jobExecutor",args);
								exit(54);//unexpected return here
							}
							//parent continue from here
							FIFOfd = open("../JECfifo",O_WRONLY);
							FIFOfd2 = open("../CJEfifo",O_RDONLY);
							flagSEARCH=0;//never again here
						}
						char* msg=malloc((strlen(buf)+9)*sizeof(char));
						strcpy(msg,buf);
						strcat(msg," -d 1000");//add the deadline

						write(FIFOfd,msg,strlen(msg)+1);
						free(msg);

						while( 1 ){
							char *ans = malloc(9*sizeof(char));//should not be resized
							read_command(FIFOfd2,&ans,9);//read jobExec answers
							if(!strcmp(ans,"_STOP_")){free(ans);break;}//no more results
							char *realans=malloc((strlen(ans)+2)*sizeof(char));
							strcpy(realans,ans);
							strcat(realans,"\n");
							write(newcsock,realans,strlen(ans)+2);//write ans to socket
							free(realans);
							free(ans);
						}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
					}
					else
						write(newcsock,"Unknown command!\n",18);
					free(ms);
				}
				free(buf);
				//close(newcsock);//--8
			}
		}//9
		if(flagSHUTDOWN) break;//10
	}

	//clear pool and then place in pool exit msg
	urlpool_clear(&up);
	//here if i got SHUTDOWN command to send exit msg(sending "exit" in pool)
	for(int i=0; i<n_threads; i++){
		place(&up,"exit");
		pthread_cond_signal(&cv_notempty);
		printf("Parent: send stop!\n");
	}

	for(int i=0; i<n_threads; i++)
		 pthread_join(*(tids+i),NULL);//join threads

	if( !flagSEARCH ){//free struct from search
		write(FIFOfd,"/exit",6);
		close(FIFOfd);
		close(FIFOfd2);
	}

	//free structs
	pthread_mutex_destroy(&mtx);
	pthread_mutex_destroy(&mtxwt);
	pthread_mutex_destroy(&pumtx);
	pthread_mutex_destroy(&mtxcounter);
	pthread_mutex_destroy(&mtxbytes);
	pthread_cond_destroy(&cv_notempty);
	pthread_cond_destroy(&cv_notfull);
	urlpool_destroy(&up);
	destroyPU();
	free(dat->savedir);
	free(dat->hostname);
	free(savedir);
	free(hostid);
	free(tids);
	free(dat);
	if( !flagSEARCH ){//free other structs first to give jE some
		waitpid(pid,0,0);//time to exit and then
		unlink("../JECfifo");//unlink fifos
		unlink("../CJEfifo");
	}
	printf("Crawler about to exit!\n");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movl %edi, %r15d
leaq -0x2c(%rbp), %rax
movl $0x5, (%rax)
leaq -0x58(%rbp), %r13
andq $0x0, (%r13)
leaq -0x68(%rbp), %rbx
andq $0x0, (%rbx)
leaq -0x60(%rbp), %r12
andq $0x0, (%r12)
callq 0x2290
leaq 0x19ef(%rip), %rdi      # 0x51e1
movq %rax, -0x48(%rbp)
movq %rax, %rsi
xorl %eax, %eax
callq 0x2100
leaq -0x74(%rbp), %rdx
leaq -0x70(%rbp), %rcx
movl %r15d, %edi
movq %r14, %rsi
leaq -0x2c(%rbp), %r8
movq %r13, %r9
pushq %r12
pushq %rbx
callq 0x2e1a
popq %rcx
popq %rdx
testl %eax, %eax
js 0x401b
leaq 0x3a8a(%rip), %rdi      # 0x72b8
callq 0x31f5
leaq 0x39fe(%rip), %rdi      # 0x7238
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x2360
leaq 0x3a45(%rip), %rdi      # 0x7290
xorl %esi, %esi
callq 0x2360
leaq 0x39b7(%rip), %rdi      # 0x7210
xorl %esi, %esi
callq 0x2360
leaq 0x3a89(%rip), %rdi      # 0x72f0
xorl %esi, %esi
callq 0x2360
leaq 0x3aa3(%rip), %rdi      # 0x7318
xorl %esi, %esi
callq 0x2360
leaq 0x39dd(%rip), %rdi      # 0x7260
xorl %esi, %esi
callq 0x21f0
leaq 0x3a2f(%rip), %rdi      # 0x72c0
xorl %esi, %esi
callq 0x21f0
movslq -0x2c(%rbp), %r13
movq %r13, %rdi
shlq $0x3, %rdi
callq 0x2220
movq %rax, %r15
pushq $0x18
popq %rdi
callq 0x2220
movq %rax, %rbx
movl -0x74(%rbp), %eax
movl %eax, (%rbx)
movq -0x58(%rbp), %r14
movq %r14, %rdi
callq 0x20f0
leaq 0x1(%rax), %rdi
callq 0x2220
movq %rax, 0x10(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x2070
movq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x20f0
leaq 0x1(%rax), %rdi
callq 0x2220
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movq %r14, %rsi
callq 0x2070
leaq -0x53f(%rip), %r14      # 0x33cb
movq %r15, -0x98(%rbp)
movslq %r13d, %rax
cmpq %rax, %r12
jge 0x3936
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2280
incq %r12
movl -0x2c(%rbp), %r13d
addq $0x8, %r15
jmp 0x3911
movq %rbx, -0x90(%rbp)
leaq 0x18b8(%rip), %rdi      # 0x51fc
movq -0x48(%rbp), %rsi
xorl %eax, %eax
callq 0x2100
leaq 0x38ba(%rip), %rbx      # 0x7210
movq %rbx, %rdi
callq 0x2390
pushq $0x8
popq %rdi
callq 0x2220
incl 0x389c(%rip)            # 0x7208
movq %rax, 0x388d(%rip)      # 0x7200
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movq %rbx, %rdi
callq 0x2210
movq -0x60(%rbp), %rsi
leaq 0x392b(%rip), %rdi      # 0x72b8
callq 0x32a1
leaq 0x38c7(%rip), %rdi      # 0x7260
callq 0x2160
leaq -0xa0(%rbp), %rdi
callq 0x21d0
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x23a0
testl %eax, %eax
js 0x4038
movl %eax, %r15d
movw $0x2, -0xb4(%rbp)
andl $0x0, -0xb0(%rbp)
movzwl -0x70(%rbp), %eax
rolw $0x8, %ax
movw %ax, -0xb2(%rbp)
leaq -0xa4(%rbp), %rcx
movl $0x1, (%rcx)
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %r8
movl %r15d, %edi
callq 0x20a0
testl %eax, %eax
js 0x4041
leaq -0xb4(%rbp), %rsi
pushq $0x10
popq %rdx
movl %r15d, %edi
callq 0x2270
testl %eax, %eax
js 0x404a
pushq $0x64
popq %rsi
movl %r15d, %edi
callq 0x2230
testl %eax, %eax
js 0x4053
leaq -0x88(%rbp), %rbx
movl %r15d, (%rbx)
movw $0x1, 0x4(%rbx)
pushq $0x1
popq %r12
pushq $-0x1
popq %r13
pushq $0x9
popq %r14
pushq $0x1
popq %rax
movl %eax, -0x3c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x2260
testb $0x1, -0x82(%rbp)
je 0x3a57
movl %r15d, %r13d
movl %r15d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22f0
movl %eax, %r12d
testl %eax, %eax
leaq -0x38(%rbp), %rbx
js 0x3fcd
pushq $0x9
popq %rdi
callq 0x2220
movq %rax, -0x38(%rbp)
movl %r12d, %edi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x279d
movq -0x38(%rbp), %r15
movq %r15, %rdi
leaq 0x178d(%rip), %rsi      # 0x5241
callq 0x2180
testl %eax, %eax
je 0x3b27
movq %r15, %rdi
leaq 0x17be(%rip), %rsi      # 0x5285
callq 0x2180
testl %eax, %eax
je 0x3e35
movq %r15, %rdi
leaq 0x17b0(%rip), %rsi      # 0x528e
callq 0x2180
testl %eax, %eax
je 0x3e0d
andq $0x0, -0x50(%rbp)
movq %r15, %rdi
leaq -0x50(%rbp), %rsi
xorl %edx, %edx
callq 0x283d
movq -0x50(%rbp), %rdi
leaq 0x178a(%rip), %rsi      # 0x5293
callq 0x2180
testl %eax, %eax
je 0x3beb
movl %r12d, %edi
leaq 0x181d(%rip), %rsi      # 0x533d
pushq $0x12
jmp 0x3c0f
leaq -0x80(%rbp), %rdi
callq 0x21d0
movq -0x80(%rbp), %r8
subq -0xa0(%rbp), %r8
movq %r8, %rax
cqto
movl $0xe10, %ecx            # imm = 0xE10
idivq %rcx
movq %rax, %rcx
movabsq $0xe1000000000, %rdx    # imm = 0xE1000000000
imulq %rdx, %rax
sarq $0x20, %rax
subq %rax, %r8
movq %r8, -0x80(%rbp)
movq %r8, %rax
cqto
pushq $0x3c
popq %rsi
idivq %rsi
movq %rax, %rdx
movabsq $0x3c00000000, %rsi     # imm = 0x3C00000000
imulq %rsi, %rdx
andq $0x0, -0x100(%rbp)
shrq $0x20, %rdx
subl %edx, %r8d
movl 0x365a(%rip), %r9d      # 0x71f0
movl 0x3657(%rip), %r10d     # 0x71f4
subq $0x8, %rsp
leaq -0x100(%rbp), %rdi
leaq 0x1698(%rip), %rsi      # 0x5247
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
pushq %r10
callq 0x2250
popq %rcx
popq %rdx
cmpl $-0x1, %eax
je 0x3c1e
movq -0x100(%rbp), %r15
movq %r15, %rdi
callq 0x20f0
incl %eax
movslq %eax, %rdx
movl %r12d, %edi
movq %r15, %rsi
callq 0x20b0
movq -0x100(%rbp), %rdi
jmp 0x3c19
movl 0x3607(%rip), %eax      # 0x71f8
cmpl -0x2c(%rbp), %eax
jne 0x3c03
movq 0x36bb(%rip), %rax      # 0x72b8
cmpl $0x0, 0xc(%rax)
je 0x3c2c
movl %r12d, %edi
leaq 0x168d(%rip), %rsi      # 0x529a
pushq $0x1c
popq %rdx
callq 0x20b0
movq -0x50(%rbp), %rdi
callq 0x2030
movq -0x38(%rbp), %rdi
callq 0x2030
jmp 0x3a8c
cmpl $0x0, -0x3c(%rbp)
je 0x3d05
movq -0x58(%rbp), %rdi
leaq 0x1675(%rip), %rsi      # 0x52b6
callq 0x2c6f
leaq 0x1675(%rip), %rbx      # 0x52c2
movq %rbx, %rdi
movl $0x1b6, %esi            # imm = 0x1B6
callq 0x21b0
cmpl $-0x1, %eax
leaq 0x1685(%rip), %r15      # 0x52e9
jne 0x3c92
callq 0x2040
cmpl $0x11, (%rax)
jne 0x4067
movq %rbx, %rdi
callq 0x2050
movq %rbx, %rdi
movl $0x1b6, %esi            # imm = 0x1B6
callq 0x21b0
cmpl $-0x1, %eax
je 0x4077
movq %r15, %rdi
movl $0x1b6, %esi            # imm = 0x1B6
callq 0x21b0
cmpl $-0x1, %eax
jne 0x3cd0
callq 0x2040
cmpl $0x11, (%rax)
jne 0x4067
movq %r15, %rdi
callq 0x2050
movq %r15, %rdi
movl $0x1b6, %esi            # imm = 0x1B6
callq 0x21b0
cmpl $-0x1, %eax
je 0x4077
callq 0x2380
testl %eax, %eax
js 0x400b
movl %eax, -0x6c(%rbp)
je 0x3fd9
movq %rbx, %rdi
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x22c0
movl %eax, -0x40(%rbp)
movq %r15, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x22c0
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0x20f0
leaq 0x9(%rax), %rdi
callq 0x2220
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
movq %rbx, %rdi
callq 0x20f0
movabsq $0x3030303120642d20, %rcx # imm = 0x3030303120642D20
movq %rcx, (%rbx,%rax)
movb $0x0, 0x8(%rbx,%rax)
movq %rbx, %rdi
callq 0x20f0
leaq 0x1(%rax), %rdx
movl -0x40(%rbp), %edi
movq %rbx, %rsi
callq 0x20b0
movq %rbx, %rdi
callq 0x2030
pushq $0x9
popq %rdi
callq 0x2220
movq %rax, -0x100(%rbp)
movl -0x48(%rbp), %edi
leaq -0x100(%rbp), %rsi
movl %r14d, %edx
callq 0x279d
movq -0x100(%rbp), %r15
movq %r15, %rdi
leaq 0x15a2(%rip), %rsi      # 0x5336
callq 0x2180
testl %eax, %eax
je 0x3df5
movq %r15, %rdi
callq 0x20f0
leaq 0x2(%rax), %rdi
callq 0x2220
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
movq %rbx, %rdi
callq 0x20f0
movw $0xa, (%rbx,%rax)
movq %r15, %rdi
callq 0x20f0
leaq 0x2(%rax), %rdx
movl %r12d, %edi
movq %rbx, %rsi
callq 0x20b0
movq %rbx, %rdi
callq 0x2030
movq -0x100(%rbp), %rdi
jmp 0x3d5d
movq %r15, %rdi
callq 0x2030
movl $0x0, -0x3c(%rbp)
leaq -0x38(%rbp), %rbx
jmp 0x3c15
movl %r12d, %edi
callq 0x2130
movq -0x38(%rbp), %rdi
callq 0x2030
leaq -0x88(%rbp), %rbx
movl %r13d, %r15d
pushq $0x1
popq %r12
pushq $-0x1
popq %r13
jmp 0x3a57
movl %r12d, %edi
callq 0x2130
movq -0x38(%rbp), %rdi
callq 0x2030
leaq 0x346b(%rip), %rbx      # 0x72b8
movq %rbx, %rdi
callq 0x322a
xorl %r13d, %r13d
leaq 0x14f1(%rip), %r14      # 0x5350
leaq 0x33fa(%rip), %r15      # 0x7260
leaq 0x1533(%rip), %r12      # 0x53a0
movl -0x2c(%rbp), %eax
cmpl %eax, %r13d
jge 0x3e95
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32a1
movq %r15, %rdi
callq 0x2160
movq %r12, %rdi
callq 0x2090
incl %r13d
jmp 0x3e6d
xorl %ebx, %ebx
movq -0x98(%rbp), %r14
movl -0x3c(%rbp), %r15d
cltq
cmpq %rax, %rbx
jge 0x3ebc
movq (%r14,%rbx,8), %rdi
xorl %esi, %esi
callq 0x2350
incq %rbx
movl -0x2c(%rbp), %eax
jmp 0x3ea2
testl %r15d, %r15d
jne 0x3ee4
leaq 0x1487(%rip), %rsi      # 0x534f
pushq $0x6
popq %rdx
movl -0x40(%rbp), %ebx
movl %ebx, %edi
callq 0x20b0
movl %ebx, %edi
callq 0x2130
movl -0x48(%rbp), %edi
callq 0x2130
leaq 0x334d(%rip), %rdi      # 0x7238
callq 0x2110
leaq 0x3399(%rip), %rdi      # 0x7290
callq 0x2110
leaq 0x330d(%rip), %rdi      # 0x7210
callq 0x2110
leaq 0x33e1(%rip), %rdi      # 0x72f0
callq 0x2110
leaq 0x33fd(%rip), %rdi      # 0x7318
callq 0x2110
leaq 0x3339(%rip), %rdi      # 0x7260
callq 0x22b0
leaq 0x338d(%rip), %rdi      # 0x72c0
callq 0x22b0
leaq 0x3379(%rip), %rdi      # 0x72b8
callq 0x327f
callq 0x31c1
movq -0x90(%rbp), %rbx
movq 0x10(%rbx), %rdi
callq 0x2030
movq 0x8(%rbx), %rdi
callq 0x2030
movq -0x58(%rbp), %rdi
callq 0x2030
movq -0x68(%rbp), %rdi
callq 0x2030
movq %r14, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
testl %r15d, %r15d
jne 0x3fad
movl -0x6c(%rbp), %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a0
leaq 0x1326(%rip), %rdi      # 0x52c2
callq 0x2050
leaq 0x1341(%rip), %rdi      # 0x52e9
callq 0x2050
leaq 0x13d5(%rip), %rdi      # 0x5389
callq 0x2090
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1266(%rip), %rdi      # 0x523a
jmp 0x405a
movl %r12d, %edi
callq 0x2130
leaq 0x2dc8(%rip), %rsi      # 0x6db0
pushq $0x9
popq %rcx
leaq -0x100(%rbp), %rax
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x12fa(%rip), %rdi      # 0x52f9
movq %rax, %rsi
callq 0x2370
pushq $0x36
jmp 0x4061
leaq 0x12e2(%rip), %rdi      # 0x52f4
callq 0x22e0
pushq $0x57
jmp 0x4061
movq -0x58(%rbp), %rdi
callq 0x2030
movq -0x68(%rbp), %rdi
callq 0x2030
movq -0x60(%rbp), %rdi
callq 0x2030
jmp 0x405f
leaq 0x1163(%rip), %rdi      # 0x51a2
jmp 0x405a
leaq 0x11db(%rip), %rdi      # 0x5223
jmp 0x405a
leaq 0x11dd(%rip), %rdi      # 0x522e
jmp 0x405a
leaq 0x11d9(%rip), %rdi      # 0x5233
callq 0x22e0
pushq $0x9
popq %rdi
callq 0x2330
leaq 0x125f(%rip), %rdi      # 0x52cd
callq 0x22e0
pushq $0x15
jmp 0x4061
leaq 0x1256(%rip), %rdi      # 0x52d4
callq 0x22e0
pushq $0x63
jmp 0x4061