// File: /workspace/github_cpp_makefile_star2_O3/burakbugrul[P]NginxLogParser/NginxParser.cpp
// Function: NginxParser::parse()
void NginxParser::parse(){
	
	ifstream input(input_file);
	int length, left, right, begin, end, bitrate, ten, http_status, sent_bytes;
	char line[MAX_LINE], type;
	string ip, id, user_agent;
	bool flag = true, cs_hit, cs_flag;
	
	while( input.getline(line,MAX_LINE,'\n') ){
		
		lines++;
		length = strlen(line);
		
		if( (ip = findIP(line)) == "-1" )
			continue;
		if( characterCount(line,length,'"') != 10 )
			continue;
		
		right = 0;
		flag = true;
		
		for( int i=0 ; i<5 ; i++ ){
			
			left = findCharacter(line,right,length,'"');
			right = findCharacter(line,left+1,length,'"');
			
			if( right-left == 2 ) // Empty parts
				continue;
			
			else if( strncmp(line+left+1,"GET",3)==0 || 
				strncmp(line+left+1,"POST",4)==0 || 
				strncmp(line+left+1,"HEAD",4)==0 || 
				strncmp(line+left+1,"PUT",3)==0 || 
				strncmp(line+left+1,"DELETE",6)==0 || 
				strncmp(line+left+1,"OPTIONS",7)==0 || 
				strncmp(line+left+1,"CONNECT",7)==0 ){ // Url part
				
				end = left;
				for( int j=0 ; j<2; j++ ){ // Finding ID
					begin = findCharacter(line,end+1,right,'/');
					end = findCharacter(line,begin+1,right,'/');
				}
				
				id = ""; // Saving ID
				for( int j=begin+1 ; j<end ; j++ )
					id += line[j];
				
				begin = findCharacter(line,end+1,right,'('); // Finding bitrate
				if( begin == right ){
					flag = false;
					break;
				}
				
				bitrate = (line[begin+1]-'0')*10+(line[begin+2]-'0');
				
				for( int j=begin+3 ; line[j]!=')' ; j++ ) // Saving bitrate
					bitrate = bitrate*10;
				
				begin = findCharacter(line,begin+1,right,'('); // Finding type
				if( begin == right ){
					flag = false;
					break;
				}
				
				type = line[begin+1]; // Saving type
				
			}
			
			else if( isdigit(line[left+2]) ){ // HTTP Status and sent bytes
				
				http_status = line[left+2]-'0'; // Saving HTTP Status
				
				sent_bytes = 0;
				ten = 1;
				for( int j=right-2 ; line[j]!=' ' ; j--,ten*=10 ) // Saving sent bytes
					sent_bytes += (line[j]-'0')*ten;
				
			}
			else{
				
				user_agent = "";

				for( int j=left+1 ; j < right && line[j] != ' ' ; j++ ) // Finding User Agent
					user_agent += line[j];
			}
			
		}
		
		cs_flag = false;
		for( int j=length-1 ; j>right ; j-- ) // Finding cs hit
			if( line[j] == 'c' && line[j+1] == 's' && line[j+2] == '=' ){
				cs_flag = true;
				cs_hit = (line[j+3] == 'H');
				break;
			}
		
		if( !flag || !cs_flag )
			continue;
		
		valid_lines++;
		total_data += sent_bytes;
		cs_hits += cs_hit;
		if( type == 'a' )
			audios++;
		else
			videos++;
		http_statuses[http_status-1]++;
		
		/* // This part is for comparing users by amount of their data transfers. If used, type of the second parameter of map should be 'long long int'
		 * if( users.find(ip) == users.end() )
			users[ip] = sent_bytes;
		else
			users[ip] += sent_bytes;
		*/
		
		// This part is for comparing users by amount of their data requests
		if( users.find(ip) == users.end() )
			users[ip] = 1;
		else
			users[ip] += 1;
		
		if( contents.find(id) == contents.end() )
			contents[id] = 1;
		else
			contents[id] ++;
			
		if( bitrates.find(bitrate) == bitrates.end() )
			bitrates[bitrate] = 1;
		else
			bitrates[bitrate] ++;
		
		if( user_agents.find(user_agent) == user_agents.end() )
			user_agents[user_agent] = 1;
		else
			user_agents[user_agent] ++;
		
	}
	
	input.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4f8, %rsp            # imm = 0x4F8
movq %rdi, %rbx
leaq 0x28(%rdi), %rsi
leaq 0x2f0(%rsp), %rdi
movl $0x8, %edx
callq 0x2250
leaq 0xa8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x60(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x40(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x110(%rbx), %rax
movq %rax, 0x70(%rsp)
leaq 0xa0(%rbx), %rax
movq %rax, 0xb8(%rsp)
leaq 0x68(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0xd8(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0xd0(%rsp), %r13
leaq 0x2f0(%rsp), %r14
movl $0x1f4, %edx            # imm = 0x1F4
movq %r14, %rdi
leaq 0xf0(%rsp), %rsi
movl $0xa, %ecx
callq 0x22a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x335a
incl (%rbx)
leaq 0xf0(%rsp), %r12
movq %r12, %rdi
callq 0x20d0
movq %rax, %r15
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3a52
leaq 0x98(%rsp), %rdi
movq %r13, %rsi
callq 0x21c0
movq %rax, %rdi
leaq 0x23b7(%rip), %rsi      # 0x5090
callq 0x2070
movl %eax, %r13d
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x2d06
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2190
testl %r13d, %r13d
setne %al
testl %r15d, %r15d
setg %cl
testb %cl, %al
leaq 0xd0(%rsp), %r13
je 0x2c70
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpb $0x22, 0xf0(%rsp,%rcx)
sete %sil
addl %esi, %edx
incq %rcx
cmpq %rcx, %rax
jne 0x2d2e
cmpl $0xa, %edx
jne 0x2c70
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x80(%rsp)
movslq %r15d, %rax
movq %rax, 0x88(%rsp)
movq $0x0, 0x90(%rsp)
movb $0x1, %dil
xorl %r14d, %r14d
movq %rbx, 0x78(%rsp)
cmpl %r15d, %r14d
jge 0x2da7
movslq %r14d, %rax
addq %rsp, %rax
addq $0xf0, %rax
cmpb $0x22, (%rax)
je 0x2da7
incl %r14d
incq %rax
cmpl %r14d, %r15d
jne 0x2d92
movl %r15d, %edx
jmp 0x2daa
movl %r14d, %edx
cmpl %r15d, %edx
movl %r15d, %ebp
cmovll %edx, %ebp
leal 0x1(%rbp), %esi
movl %esi, %r13d
cmpl %r15d, %esi
jge 0x2df2
movslq %edx, %rax
movq 0x88(%rsp), %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
leal 0x1(%rax), %r13d
leaq 0xf1(%rsp), %rcx
addq %rcx, %rax
cmpb $0x22, (%rax)
je 0x2df2
incl %r13d
incq %rax
cmpl %r13d, %r15d
jne 0x2ddf
movl %r15d, %r13d
cmpl %r15d, %r13d
movl %r15d, %r14d
cmovll %r13d, %r14d
movl %r14d, %eax
subl %ebp, %eax
cmpl $0x2, %eax
je 0x3129
movq %rax, 0xc8(%rsp)
movl %esi, 0x28(%rsp)
movl %edx, 0x2c(%rsp)
movb %dil, 0x9(%rsp)
movslq %ebp, %rcx
leaq 0xf1(%rsp), %rax
leaq (%rax,%rcx), %r12
movq %rcx, 0xc0(%rsp)
movb 0xf1(%rsp,%rcx), %al
movb %al, 0xb(%rsp)
cmpb $0x47, %al
jne 0x2e59
cmpb $0x45, 0x1(%r12)
jne 0x2e59
cmpb $0x54, 0x2(%r12)
je 0x2f77
movl $0x4, %edx
movq %r12, %rdi
leaq 0x222b(%rip), %rsi      # 0x5093
callq 0x20e0
testl %eax, %eax
je 0x2f77
movl $0x4, %edx
movq %r12, %rdi
leaq 0x2214(%rip), %rsi      # 0x5098
callq 0x20e0
testl %eax, %eax
je 0x2f77
cmpb $0x50, 0xb(%rsp)
jne 0x2ead
movq %r12, %rcx
cmpb $0x55, 0x1(%r12)
jne 0x2ead
cmpb $0x54, 0x2(%rcx)
je 0x2f77
movl $0x6, %edx
movq %r12, %rdi
leaq 0x21e1(%rip), %rsi      # 0x509d
callq 0x20e0
testl %eax, %eax
je 0x2f77
movl $0x7, %edx
movq %r12, %rdi
leaq 0x21cc(%rip), %rsi      # 0x50a4
callq 0x20e0
testl %eax, %eax
je 0x2f77
movl $0x7, %edx
movq %r12, %rdi
leaq 0x21b8(%rip), %rsi      # 0x50ac
callq 0x20e0
testl %eax, %eax
je 0x2f77
leaq 0xf0(%rsp), %rax
movq 0xc0(%rsp), %rcx
movsbl 0x2(%rcx,%rax), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
ja 0x3150
movslq %r14d, %rcx
movb 0xee(%rsp,%rcx), %sil
movl $0x0, 0x14(%rsp)
cmpb $0x20, %sil
je 0x2f6e
addq $-0x2, %rcx
leaq 0xef(%rsp), %rdx
addq %rdx, %rcx
movl $0x1, %edx
xorl %edi, %edi
movsbl %sil, %esi
addl $-0x30, %esi
imull %edx, %esi
addl %esi, %edi
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
movb (%rcx), %sil
decq %rcx
cmpb $0x20, %sil
jne 0x2f4d
movl %edi, 0x14(%rsp)
movl %eax, 0x10(%rsp)
jmp 0x3129
movslq %r13d, %rax
movb $0x1, %cl
leaq 0xf1(%rsp), %rsi
movq 0x88(%rsp), %rdi
leal 0x1(%rbp), %r12d
cmpl %r14d, %r12d
jge 0x2fae
movslq %ebp, %rdx
addq %rsi, %rdx
cmpb $0x2f, (%rdx)
je 0x2fae
incl %r12d
incq %rdx
cmpl %r12d, %r14d
jne 0x2f9b
movl %r14d, %r12d
cmpl %r14d, %r12d
movl %r14d, %ebp
cmovll %r12d, %ebp
incl %ebp
cmpl %r14d, %ebp
jge 0x2fe8
movslq %r12d, %rdx
cmpq %rax, %rdx
cmovgeq %rax, %rdx
cmpq %rdi, %rdx
cmovgeq %rdi, %rdx
leal 0x1(%rdx), %ebp
addq %rsi, %rdx
cmpb $0x2f, (%rdx)
je 0x2fe8
incl %ebp
incq %rdx
cmpl %ebp, %r14d
jne 0x2fd6
movl %r14d, %ebp
cmpl %r14d, %ebp
cmovgel %r14d, %ebp
testb $0x1, %cl
movl $0x0, %ecx
jne 0x2f8c
movq 0x58(%rsp), %rdx
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
leaq 0x2175(%rip), %rcx      # 0x5181
xorl %r8d, %r8d
callq 0x2230
cmpl %r13d, %r12d
cmovgel %r13d, %r12d
movslq %r12d, %r12
movq 0x80(%rsp), %rax
cmpq %rax, %r12
cmovgeq %rax, %r12
movslq %ebp, %rbx
incq %r12
cmpq %rbx, %r12
jge 0x3050
movsbl 0xf0(%rsp,%r12), %esi
incq %r12
leaq 0x50(%rsp), %rdi
callq 0x2160
jmp 0x3033
incl %ebp
cmpl %r14d, %ebp
jge 0x3081
movslq %ebp, %rax
addq %rsp, %rax
addq $0xf0, %rax
movq 0x78(%rsp), %rbx
movb 0x9(%rsp), %dil
cmpb $0x28, (%rax)
je 0x308b
incl %ebp
incq %rax
cmpl %ebp, %r14d
jne 0x306d
jmp 0x31bd
movq 0x78(%rsp), %rbx
movb 0x9(%rsp), %dil
cmpl %ebp, %r14d
jle 0x31bd
movslq %ebp, %rax
movsbl 0xf1(%rsp,%rax), %ecx
leal (%rcx,%rcx,4), %ecx
leaq 0xf0(%rsp), %rdx
movsbl 0x2(%rax,%rdx), %edx
leal (%rdx,%rcx,2), %ecx
addl $0xfffffdf0, %ecx       # imm = 0xFFFFFDF0
movl %ecx, 0xc(%rsp)
cmpb $0x29, 0xf3(%rsp,%rax)
je 0x30e7
leaq 0x3(%rax), %rdx
leaq 0xf1(%rsp), %rsi
addq %rsi, %rdx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
cmpb $0x29, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x30d5
movl %ecx, 0xc(%rsp)
leaq 0x1(%rax), %rcx
cmpl %r14d, %ecx
jge 0x310d
addq %rsp, %rax
addq $0xf1, %rax
cmpb $0x28, (%rax)
je 0x310d
incl %ecx
incq %rax
cmpl %ecx, %r14d
jne 0x30f9
jmp 0x31bd
cmpl %ecx, %r14d
jle 0x31bd
movslq %ecx, %rax
leaq 0xf0(%rsp), %rcx
movb 0x1(%rax,%rcx), %al
movb %al, 0xa(%rsp)
movq 0x90(%rsp), %rax
cmpl $0x4, %eax
leal 0x1(%rax), %eax
setb %dil
movl %eax, %ecx
movq %rcx, 0x90(%rsp)
cmpl $0x5, %eax
jne 0x2d81
jmp 0x31bd
movq 0x38(%rsp), %rdx
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
leaq 0x201e(%rip), %rcx      # 0x5181
xorl %r8d, %r8d
callq 0x2230
cmpl %r14d, 0x28(%rsp)
movl 0x2c(%rsp), %eax
jge 0x3129
cltq
movq 0x80(%rsp), %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
leaq (%rsp,%rax), %r12
addq $0xf0, %r12
movl $0x1, %ebp
movb (%r12,%rbp), %al
cmpb $0x20, %al
je 0x3129
movsbl %al, %esi
leaq 0x30(%rsp), %rdi
callq 0x2160
incq %rbp
cmpl %ebp, 0xc8(%rsp)
jne 0x3197
jmp 0x3129
leal -0x1(%r15), %eax
cmpl %eax, %r13d
leaq 0xd0(%rsp), %r13
jge 0x2c68
cltq
movslq %r14d, %rcx
cmpb $0x63, 0xf0(%rsp,%rax)
jne 0x31ff
movslq %r15d, %rdx
cmpb $0x73, 0xf0(%rsp,%rdx)
jne 0x31ff
leal 0x1(%r15), %edx
movslq %edx, %rdx
cmpb $0x3d, 0xf0(%rsp,%rdx)
je 0x320f
decq %rax
decl %r15d
cmpq %rcx, %rax
jg 0x31d7
jmp 0x2c68
testb $0x1, %dil
jne 0x2c68
addl $0x2, %r15d
movslq %r15d, %rax
xorl %ecx, %ecx
cmpb $0x48, 0xf0(%rsp,%rax)
sete %cl
incl 0x4(%rbx)
movslq 0x14(%rsp), %rax
addq %rax, 0x148(%rbx)
addl %ecx, 0x8(%rbx)
cmpb $0x61, 0xa(%rsp)
jne 0x324b
incl 0x10(%rbx)
jmp 0x324e
incl 0xc(%rbx)
movq 0x70(%rsp), %r14
movl 0x10(%rsp), %eax
cltq
incl 0x10(%rbx,%rax,4)
movq %r14, %rdi
leaq 0x98(%rsp), %rsi
callq 0x3c78
movq 0xb8(%rsp), %r15
testq %rax, %rax
je 0x328e
movq %r14, %rdi
leaq 0x98(%rsp), %rsi
callq 0x3d90
incl (%rax)
jmp 0x32a4
movq %r14, %rdi
leaq 0x98(%rsp), %rsi
callq 0x3d90
movl $0x1, (%rax)
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x3c78
testq %rax, %rax
je 0x32c7
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x3d90
incl (%rax)
jmp 0x32da
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x3d90
movl $0x1, (%rax)
movq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x40e2
testq %rax, %rax
je 0x3301
movq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x413e
incl (%rax)
jmp 0x3316
movq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x413e
movl $0x1, (%rax)
movq 0x18(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3c78
testq %rax, %rax
je 0x3340
movq 0x18(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3d90
incl (%rax)
jmp 0x2c68
movq 0x18(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3d90
movl $0x1, (%rax)
jmp 0x2c68
leaq 0x2f0(%rsp), %rdi
callq 0x2040
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3383
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x339f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x33c4
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x2f0(%rsp), %rdi
callq 0x2050
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
jmp 0x33f7
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3416
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x3432
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x3457
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x2f0(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2280