// File: /workspace/github_c_makefile_star2_O1/DVaronos[P]AnLogProject1/hash.c
// Function: Readjson
LHash* Readjson(char* filename,LHash* H,LHash* Common,WHash** L){ //Diavazei to Json kai apothikei tis leksis sto leksilogio kai se ena WHash
  FILE* fp;
  if( (fp=fopen(filename,"r"))==NULL){
    perror("Fopen");
  }

  char symbols[] =  " /,\\,\n,[,],(,),*,&,^,%,$,#,@,!,:,;,<,>,`,~,+,_,-,=,{,}|,\",.," "";  //Ta simvolia ta opia tha xwrizoun tis lekseis
  (*L)=CreateWHash(200);
  char line[250];
  char* word;
  int count=0;

	while(fgets(line, sizeof(line),fp)){  //Diavazei to json grami gami

		word = strtok(line, """:");		//skip labels
		word=strtok(NULL,symbols);

		while(word!=NULL){ //Gia kathe leksi tis gramhs
			if(strlen(word)>2)
			{
				count++;
				for(int j=0; j<=strlen(word);j++){  //Metatrepei ta kefalea se peza
					if(word[j]>=65 && word[j]<=90)	word[j]=word[j]+32;
				}
				if(!LHashFind(Common,word)){  //Ean h leksh den einai mia apo tis common
					if(!WHashFind(*L,word))  H=LHashInsert(H,word); //Ean den exw isagi thn leksh allh fora sto stigekrimeno json
					*L=InsertWHash(*L,word);
				}
			}
			word=strtok(NULL,symbols);
		}
	}
	fclose(fp);
	(*L)=WHashTF(*L); //Ipoligismos twn tf gia kathe leksh tou TF
	for(int i=0 ; i<(*L)->size ; i++){
		if((*L)[i].word!=NULL){
			H=LHashIncreaseTf(H,(*L)[i].word,(*L)[i].tfidf);
		}
	}
return H;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r14
leaq 0xd81(%rip), %rsi       # 0x6016
callq 0x1200
movq %rax, %r13
testq %rax, %rax
je 0x5420
movq %r14, -0x30(%rbp)
movl $0xc8, %edi
callq 0x39d5
movq %rax, (%rbx)
leaq -0x140(%rbp), %rdi
movl $0xfa, %esi
movq %r13, %rdx
callq 0x1120
testq %rax, %rax
je 0x53ba
leaq -0x140(%rbp), %r14
leaq 0x104e(%rip), %r12      # 0x6330
movq %r13, -0x38(%rbp)
movq %r14, %rdi
leaq 0x1035(%rip), %rsi      # 0x6325
callq 0x1220
xorl %edi, %edi
movq %r12, %rsi
callq 0x1220
testq %rax, %rax
je 0x5396
movq %rax, %r13
movq %r13, %rdi
callq 0x10c0
cmpq $0x3, %rax
jb 0x5380
movq $-0x1, %r14
movb 0x1(%r13,%r14), %al
leal -0x41(%rax), %ecx
cmpb $0x19, %cl
ja 0x5334
orb $0x20, %al
movb %al, 0x1(%r13,%r14)
movq %r13, %rdi
callq 0x10c0
incq %r14
cmpq %r14, %rax
ja 0x5320
movq %r15, %rdi
movq %r13, %rsi
callq 0x4eb5
testl %eax, %eax
jne 0x5380
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x3d88
testl %eax, %eax
jne 0x5372
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x4b03
movq %rax, -0x30(%rbp)
movq (%rbx), %rdi
movq %r13, %rsi
callq 0x3a23
movq %rax, (%rbx)
xorl %edi, %edi
movq %r12, %rsi
callq 0x1220
movq %rax, %r13
testq %rax, %rax
jne 0x530b
leaq -0x140(%rbp), %r14
movq %r14, %rdi
movl $0xfa, %esi
movq -0x38(%rbp), %r13
movq %r13, %rdx
callq 0x1120
testq %rax, %rax
jne 0x52e6
movq %r13, %rdi
callq 0x10a0
movq (%rbx), %rdi
callq 0x3ccb
movq %rax, (%rbx)
cmpl $0x0, 0x14(%rax)
movq -0x30(%rbp), %r14
jle 0x540b
movl $0x8, %r15d
xorl %r12d, %r12d
movq (%rax,%r15), %rsi
testq %rsi, %rsi
je 0x53f8
movsd -0x8(%rax,%r15), %xmm0
movq %r14, %rdi
callq 0x51b9
incq %r12
movq (%rbx), %rax
movslq 0x14(%rax), %rcx
addq $0x18, %r15
cmpq %rcx, %r12
jl 0x53e0
movq %r14, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc02(%rip), %rdi       # 0x6029
callq 0x1210
jmp 0x52a6
nopl (%rax)