// File: burakbugrul[P]NginxLogParser/NginxParser.cpp
// Function: NginxParser::statistics()
void NginxParser::statistics(){
	
	int current_max,w=35;
	string ip,id;
	
	ofstream output(output_file);
	output << setw(w) << left << "Number of unique IPs: " << users.size() << "\n\n";
	output << setw(w) << "Number of unique contents: " << contents.size() << "\n\n";
	output << setw(w) << "Total data sent: " << (double)total_data/1e9 << "GB\n\n";
	output << setw(w) << "Number of video requests: " << videos << "\n\n";
	output << setw(w) << "Number of audio requests: " << audios << "\n\n";
	output << setw(w) << "Number of cs hits requests: " << cs_hits << "\n\n";
	
	current_max = 0;
	for( auto &user: users )
		if( user.second > current_max ){
			current_max = user.second;
			ip = user.first;
		}
	
	output << setw(w) << "The IP that watched contents most: " << ip << " (" << current_max << " times)\n\n";
	
	current_max = 0;
	for( auto &content: contents )
		if( content.second > current_max ){
			current_max = content.second;
			id = content.first;
		}
	
	output << setw(w) << "The content that watched most: " << id << " (" << current_max << " times)\n\n";
	
	output << "Browsers:\n";
	for( auto &browser: user_agents )
		output << browser.first << ": %" << ((double)browser.second/valid_lines)*100.0 << "\n";
	
	output << "\nHTTP Statuses:\n";
	for( int i=0 ; i<5 ; i++ )
		output << i+1 << "xx: %" << ((double)http_statuses[i]/valid_lines)*100.0 << "\n";
	
	output << "\nBitrates:\n";
	for( auto &bitrate: bitrates )
		output << bitrate.first << ": %" << ((double)bitrate.second/valid_lines)*100.0 << "\n";
	
	output.close();
}

// Assembly:
subq $0x488, %rsp            # imm = 0x488
movq %rdi, 0x480(%rsp)
movq 0x480(%rsp), %rax
movq %rax, 0x170(%rsp)
movl $0x23, 0x478(%rsp)
leaq 0x458(%rsp), %rdi
callq 0x2270
leaq 0x438(%rsp), %rdi
callq 0x2270
movq 0x170(%rsp), %rsi
addq $0x48, %rsi
leaq 0x238(%rsp), %rdi
movl $0x10, %edx
callq 0x2340
jmp 0x4104
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0x16c(%rsp)
jmp 0x4119
movl 0x16c(%rsp), %eax
movl %eax, 0x228(%rsp)
movl 0x228(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0x160(%rsp)
jmp 0x4145
movq 0x160(%rsp), %rdi
leaq 0xfbc(%rip), %rsi       # 0x5110
callq 0x20a0
movq %rax, 0x158(%rsp)
jmp 0x4163
movq 0x158(%rsp), %rdi
leaq 0x3f33(%rip), %rsi      # 0x80a5
callq 0x21b0
movq %rax, 0x150(%rsp)
jmp 0x4181
movq 0x170(%rsp), %rdi
addq $0x110, %rdi            # imm = 0x110
callq 0x5130
movq 0x150(%rsp), %rdi
movq %rax, %rsi
callq 0x2060
movq %rax, 0x148(%rsp)
jmp 0x41af
movq 0x148(%rsp), %rdi
leaq 0x3fb2(%rip), %rsi      # 0x8170
callq 0x21b0
jmp 0x41c5
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0x144(%rsp)
jmp 0x41da
movl 0x144(%rsp), %eax
movl %eax, 0x224(%rsp)
movl 0x224(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0x138(%rsp)
jmp 0x4206
movq 0x138(%rsp), %rdi
leaq 0x3ea7(%rip), %rsi      # 0x80bc
callq 0x21b0
movq %rax, 0x130(%rsp)
jmp 0x4224
movq 0x170(%rsp), %rdi
addq $0xa0, %rdi
callq 0x5130
movq 0x130(%rsp), %rdi
movq %rax, %rsi
callq 0x2060
movq %rax, 0x128(%rsp)
jmp 0x4252
movq 0x128(%rsp), %rdi
leaq 0x3f0f(%rip), %rsi      # 0x8170
callq 0x21b0
jmp 0x4268
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0x124(%rsp)
jmp 0x427d
movl 0x124(%rsp), %eax
movl %eax, 0x220(%rsp)
movl 0x220(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0x118(%rsp)
jmp 0x42a9
movq 0x118(%rsp), %rdi
leaq 0x3e20(%rip), %rsi      # 0x80d8
callq 0x21b0
movq %rax, 0x110(%rsp)
jmp 0x42c7
movq 0x110(%rsp), %rdi
movq 0x170(%rsp), %rax
cvtsi2sdq 0x148(%rax), %xmm0
movsd 0x3d68(%rip), %xmm1     # 0x8050
divsd %xmm1, %xmm0
callq 0x2320
movq %rax, 0x108(%rsp)
jmp 0x42fb
movq 0x108(%rsp), %rdi
leaq 0x3de0(%rip), %rsi      # 0x80ea
callq 0x21b0
jmp 0x4311
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0x104(%rsp)
jmp 0x4326
movl 0x104(%rsp), %eax
movl %eax, 0x21c(%rsp)
movl 0x21c(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0xf8(%rsp)
jmp 0x4352
movq 0xf8(%rsp), %rdi
leaq 0x3d8e(%rip), %rsi      # 0x80ef
callq 0x21b0
movq %rax, 0xf0(%rsp)
jmp 0x4370
movq 0xf0(%rsp), %rdi
movq 0x170(%rsp), %rax
movl 0xc(%rax), %esi
callq 0x22f0
movq %rax, 0xe8(%rsp)
jmp 0x4392
movq 0xe8(%rsp), %rdi
leaq 0x3dcf(%rip), %rsi      # 0x8170
callq 0x21b0
jmp 0x43a8
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0xe4(%rsp)
jmp 0x43bd
movl 0xe4(%rsp), %eax
movl %eax, 0x218(%rsp)
movl 0x218(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0xd8(%rsp)
jmp 0x43e9
movq 0xd8(%rsp), %rdi
leaq 0x3d12(%rip), %rsi      # 0x810a
callq 0x21b0
movq %rax, 0xd0(%rsp)
jmp 0x4407
movq 0xd0(%rsp), %rdi
movq 0x170(%rsp), %rax
movl 0x10(%rax), %esi
callq 0x22f0
movq %rax, 0xc8(%rsp)
jmp 0x4429
movq 0xc8(%rsp), %rdi
leaq 0x3d38(%rip), %rsi      # 0x8170
callq 0x21b0
jmp 0x443f
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0xc4(%rsp)
jmp 0x4454
movl 0xc4(%rsp), %eax
movl %eax, 0x214(%rsp)
movl 0x214(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0xb8(%rsp)
jmp 0x4480
movq 0xb8(%rsp), %rdi
leaq 0x3c96(%rip), %rsi      # 0x8125
callq 0x21b0
movq %rax, 0xb0(%rsp)
jmp 0x449e
movq 0xb0(%rsp), %rdi
movq 0x170(%rsp), %rax
movl 0x8(%rax), %esi
callq 0x22f0
movq %rax, 0xa8(%rsp)
jmp 0x44c0
movq 0xa8(%rsp), %rdi
leaq 0x3ca1(%rip), %rsi      # 0x8170
callq 0x21b0
jmp 0x44d6
movq 0x170(%rsp), %rax
movl $0x0, 0x47c(%rsp)
addq $0x110, %rax            # imm = 0x110
movq %rax, 0x208(%rsp)
movq 0x208(%rsp), %rdi
callq 0x5140
movq %rax, 0x200(%rsp)
movq 0x208(%rsp), %rdi
callq 0x4fe0
movq %rax, 0x1f8(%rsp)
leaq 0x200(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
callq 0x5170
testb $0x1, %al
jne 0x453f
jmp 0x45e6
leaq 0x200(%rsp), %rdi
callq 0x5190
movq %rax, 0x1f0(%rsp)
movq 0x1f0(%rsp), %rax
movl 0x20(%rax), %eax
cmpl 0x47c(%rsp), %eax
jle 0x45d2
movq 0x1f0(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x47c(%rsp)
movq 0x1f0(%rsp), %rsi
leaq 0x458(%rsp), %rdi
callq 0x2030
jmp 0x4591
jmp 0x45d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
jmp 0x4b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x230(%rsp)
movl %eax, 0x22c(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x22a0
jmp 0x4b6c
jmp 0x45d4
leaq 0x200(%rsp), %rdi
callq 0x51b0
jmp 0x4521
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0xa4(%rsp)
jmp 0x45fb
movl 0xa4(%rsp), %eax
movl %eax, 0x1ec(%rsp)
movl 0x1ec(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0x98(%rsp)
jmp 0x4627
movq 0x98(%rsp), %rdi
leaq 0x3b0c(%rip), %rsi      # 0x8142
callq 0x21b0
movq %rax, 0x90(%rsp)
jmp 0x4645
movq 0x90(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0x2190
movq %rax, 0x88(%rsp)
jmp 0x4664
movq 0x88(%rsp), %rdi
leaq 0x3af3(%rip), %rsi      # 0x8166
callq 0x21b0
movq %rax, 0x80(%rsp)
jmp 0x4682
movq 0x80(%rsp), %rdi
movl 0x47c(%rsp), %esi
callq 0x22f0
movq %rax, 0x78(%rsp)
jmp 0x469d
movq 0x78(%rsp), %rdi
leaq 0x3ac0(%rip), %rsi      # 0x8169
callq 0x21b0
jmp 0x46b0
movq 0x170(%rsp), %rax
movl $0x0, 0x47c(%rsp)
addq $0xa0, %rax
movq %rax, 0x1e0(%rsp)
movq 0x1e0(%rsp), %rdi
callq 0x5140
movq %rax, 0x1d8(%rsp)
movq 0x1e0(%rsp), %rdi
callq 0x4fe0
movq %rax, 0x1d0(%rsp)
leaq 0x1d8(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x5170
testb $0x1, %al
jne 0x4716
jmp 0x477b
leaq 0x1d8(%rsp), %rdi
callq 0x5190
movq %rax, 0x1c8(%rsp)
movq 0x1c8(%rsp), %rax
movl 0x20(%rax), %eax
cmpl 0x47c(%rsp), %eax
jle 0x476a
movq 0x1c8(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x47c(%rsp)
movq 0x1c8(%rsp), %rsi
leaq 0x438(%rsp), %rdi
callq 0x2030
jmp 0x4768
jmp 0x476a
jmp 0x476c
leaq 0x1d8(%rsp), %rdi
callq 0x51b0
jmp 0x46fb
movl 0x478(%rsp), %edi
callq 0x50f0
movl %eax, 0x74(%rsp)
jmp 0x478d
movl 0x74(%rsp), %eax
movl %eax, 0x1c4(%rsp)
movl 0x1c4(%rsp), %esi
leaq 0x238(%rsp), %rdi
callq 0x21f0
movq %rax, 0x68(%rsp)
jmp 0x47b3
movq 0x68(%rsp), %rdi
leaq 0x39b4(%rip), %rsi      # 0x8173
callq 0x21b0
movq %rax, 0x60(%rsp)
jmp 0x47cb
movq 0x60(%rsp), %rdi
leaq 0x438(%rsp), %rsi
callq 0x2190
movq %rax, 0x58(%rsp)
jmp 0x47e4
movq 0x58(%rsp), %rdi
leaq 0x3976(%rip), %rsi      # 0x8166
callq 0x21b0
movq %rax, 0x50(%rsp)
jmp 0x47fc
movq 0x50(%rsp), %rdi
movl 0x47c(%rsp), %esi
callq 0x22f0
movq %rax, 0x48(%rsp)
jmp 0x4814
movq 0x48(%rsp), %rdi
leaq 0x3949(%rip), %rsi      # 0x8169
callq 0x21b0
jmp 0x4827
leaq 0x3965(%rip), %rsi      # 0x8193
leaq 0x238(%rsp), %rdi
callq 0x21b0
jmp 0x483d
movq 0x170(%rsp), %rax
addq $0xd8, %rax
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x5140
movq %rax, 0x1b0(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x4fe0
movq %rax, 0x1a8(%rsp)
leaq 0x1b0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x5170
testb $0x1, %al
jne 0x489b
jmp 0x4946
leaq 0x1b0(%rsp), %rdi
callq 0x5190
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0x2190
movq %rax, 0x40(%rsp)
jmp 0x48cc
movq 0x40(%rsp), %rdi
leaq 0x38d9(%rip), %rsi      # 0x81b1
callq 0x21b0
movq %rax, 0x38(%rsp)
jmp 0x48e4
movq 0x38(%rsp), %rdi
movq 0x170(%rsp), %rax
movq 0x1a0(%rsp), %rcx
cvtsi2sdl 0x20(%rcx), %xmm0
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0x3749(%rip), %xmm1     # 0x8058
mulsd %xmm1, %xmm0
callq 0x2320
movq %rax, 0x30(%rsp)
jmp 0x491f
movq 0x30(%rsp), %rdi
leaq 0x3846(%rip), %rsi      # 0x8171
callq 0x21b0
jmp 0x4932
jmp 0x4934
leaq 0x1b0(%rsp), %rdi
callq 0x51b0
jmp 0x487d
leaq 0x3851(%rip), %rsi      # 0x819e
leaq 0x238(%rsp), %rdi
callq 0x21b0
jmp 0x495c
movl $0x0, 0x19c(%rsp)
cmpl $0x5, 0x19c(%rsp)
jge 0x4a11
movl 0x19c(%rsp), %esi
incl %esi
leaq 0x238(%rsp), %rdi
callq 0x22f0
movq %rax, 0x28(%rsp)
jmp 0x4992
movq 0x28(%rsp), %rdi
leaq 0x3811(%rip), %rsi      # 0x81af
callq 0x21b0
movq %rax, 0x20(%rsp)
jmp 0x49aa
movq 0x20(%rsp), %rdi
movq 0x170(%rsp), %rax
movslq 0x19c(%rsp), %rcx
cvtsi2sdl 0x14(%rax,%rcx,4), %xmm0
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0x3682(%rip), %xmm1     # 0x8058
mulsd %xmm1, %xmm0
callq 0x2320
movq %rax, 0x18(%rsp)
jmp 0x49e6
movq 0x18(%rsp), %rdi
leaq 0x377f(%rip), %rsi      # 0x8171
callq 0x21b0
jmp 0x49f9
jmp 0x49fb
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x4967
leaq 0x379d(%rip), %rsi      # 0x81b5
leaq 0x238(%rsp), %rdi
callq 0x21b0
jmp 0x4a27
movq 0x170(%rsp), %rax
addq $0x68, %rax
movq %rax, 0x190(%rsp)
movq 0x190(%rsp), %rdi
callq 0x51e0
movq %rax, 0x188(%rsp)
movq 0x190(%rsp), %rdi
callq 0x5090
movq %rax, 0x180(%rsp)
leaq 0x188(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x5210
testb $0x1, %al
jne 0x4a83
jmp 0x4b2e
leaq 0x188(%rsp), %rdi
callq 0x5230
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rax
movl (%rax), %esi
leaq 0x238(%rsp), %rdi
callq 0x22f0
movq %rax, 0x10(%rsp)
jmp 0x4ab6
movq 0x10(%rsp), %rdi
leaq 0x36ef(%rip), %rsi      # 0x81b1
callq 0x21b0
movq %rax, 0x8(%rsp)
jmp 0x4ace
movq 0x8(%rsp), %rdi
movq 0x170(%rsp), %rax
movq 0x178(%rsp), %rcx
cvtsi2sdl 0x4(%rcx), %xmm0
cvtsi2sdl 0x4(%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0x355f(%rip), %xmm1     # 0x8058
mulsd %xmm1, %xmm0
callq 0x2320
movq %rax, (%rsp)
jmp 0x4b08
movq (%rsp), %rdi
leaq 0x365e(%rip), %rsi      # 0x8171
callq 0x21b0
jmp 0x4b1a
jmp 0x4b1c
leaq 0x188(%rsp), %rdi
callq 0x5250
jmp 0x4a65
leaq 0x238(%rsp), %rdi
callq 0x2280
jmp 0x4b3d
leaq 0x238(%rsp), %rdi
callq 0x22a0
leaq 0x438(%rsp), %rdi
callq 0x2140
leaq 0x458(%rsp), %rdi
callq 0x2140
addq $0x488, %rsp            # imm = 0x488
retq
leaq 0x438(%rsp), %rdi
callq 0x2140
leaq 0x458(%rsp), %rdi
callq 0x2140
movq 0x230(%rsp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)
nopl (%rax)