// File: mbourand[P]webserv/srcs/Response.cpp
// Function: Response::setCompression(std::vector<Header*, std::allocator<Header*>> const&)
void	Response::setCompression(const std::vector<Header*>& headers)
{
	AcceptEncodingHeader* aeh = NULL;
	for (std::vector<Header*>::const_iterator it = headers.begin(); it != headers.end(); it++)
		if ((*it)->getType() == AcceptEncodingHeader().getType()) {
			aeh = reinterpret_cast<AcceptEncodingHeader*>(*it);
			break;
		}
	if (!aeh)
		return;
	std::multimap<float, std::string, std::greater<float> > encoding_preferences = aeh->getPreferences();
	for (std::map<float, std::string, std::greater<float> >::const_iterator it = encoding_preferences.begin(); it != encoding_preferences.end(); it++)
	{
		if (it->second == "gzip" && it->first == encoding_preferences.begin()->first)
			_cangzip = true;
		else if (it->second == "deflate" && it->first == encoding_preferences.begin()->first)
			_candeflate = true;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x118(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x14440
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x144b0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x14470
testb $0x1, %al
jne 0x64656
jmp 0x64737
leaq -0x20(%rbp), %rdi
callq 0x14570
movq (%rax), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x48(%rbp), %rdi
callq *%rax
leaq -0x90(%rbp), %rdi
callq 0xaad0
jmp 0x6467d
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xabc0
jmp 0x6468f
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x144e0
movb %al, -0x119(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x9c98
leaq -0x90(%rbp), %rdi
callq 0xab50
leaq -0x48(%rbp), %rdi
callq 0x9c98
movb -0x119(%rbp), %al
testb $0x1, %al
jne 0x646cc
jmp 0x6471e
leaq -0x20(%rbp), %rdi
callq 0x14570
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x64737
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x64710
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0xab50
leaq -0x48(%rbp), %rdi
callq 0x9c98
jmp 0x6495d
jmp 0x64720
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x14590
movq %rax, -0xa8(%rbp)
jmp 0x64633
cmpq $0x0, -0x18(%rbp)
jne 0x64743
jmp 0x64954
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
leaq -0xd8(%rbp), %rdi
callq *0x28(%rax)
leaq -0xd8(%rbp), %rdi
callq 0x145d0
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x14600
leaq -0xd8(%rbp), %rdi
callq 0x14650
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x14600
leaq -0xe0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x14620
testb $0x1, %al
jne 0x647bc
jmp 0x64948
leaq -0xe0(%rbp), %rdi
callq 0x14680
movq %rax, %rdi
addq $0x8, %rdi
leaq 0x9516(%rip), %rsi      # 0x6dcec
callq 0xdf50
movb %al, -0x11a(%rbp)
jmp 0x647e3
movb -0x11a(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x11b(%rbp)
jne 0x647f8
jmp 0x64848
leaq -0xe0(%rbp), %rdi
callq 0x14680
movss (%rax), %xmm0
movss %xmm0, -0x120(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x145d0
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x65670
movss -0x120(%rbp), %xmm0
ucomiss (%rax), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0x11b(%rbp)
movb -0x11b(%rbp), %al
testb $0x1, %al
jne 0x64854
jmp 0x64887
movq -0x118(%rbp), %rax
movb $0x1, 0xd(%rax)
jmp 0x6492c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xcf30
jmp 0x6495d
leaq -0xe0(%rbp), %rdi
callq 0x14680
movq %rax, %rdi
addq $0x8, %rdi
leaq 0x7405(%rip), %rsi      # 0x6bca6
callq 0xdf50
movb %al, -0x121(%rbp)
jmp 0x648ae
movb -0x121(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x122(%rbp)
jne 0x648c3
jmp 0x64913
leaq -0xe0(%rbp), %rdi
callq 0x14680
movss (%rax), %xmm0
movss %xmm0, -0x128(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x145d0
movq %rax, -0x108(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x65670
movss -0x128(%rbp), %xmm0
ucomiss (%rax), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0x122(%rbp)
movb -0x122(%rbp), %al
testb $0x1, %al
jne 0x6491f
jmp 0x6492a
movq -0x118(%rbp), %rax
movb $0x1, 0xc(%rax)
jmp 0x6492c
jmp 0x6492e
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
callq 0x14750
movq %rax, -0x110(%rbp)
jmp 0x6477a
leaq -0xd8(%rbp), %rdi
callq 0xcf30
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x9af0
nopl (%rax)