Function at 0x509520
Capabilities:
Compress data via zlib inflate or deflate

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x10
push esi
push edi
mov edi, ecx
mov dword [ebp - 0xc], edx
test edi, edi
je 0x509d41
mov esi, dword [edi + 0x1c]
test esi, esi
je 0x509d41
cmp edx, 4
ja 0x509d41
cmp dword [edi + 0xc], 0
je 0x509d39
cmp dword [edi], 0
jne 0x509562
cmp dword [edi + 4], 0
jne 0x509d39
mov eax, dword [esi + 4]
cmp eax, 0x29a
jne 0x509575
cmp edx, 4
jne 0x509d39
cmp dword [edi + 0x10], 0
push ebx
je 0x509bea
mov ecx, dword [esi + 0x28]
mov dword [esi], edi
mov dword [ebp - 0x10], ecx
mov dword [esi + 0x28], edx
cmp eax, 0x2a
jne 0x50982a
cmp dword [esi + 0x18], 2
jne 0x50978d
mov dword [edi + 0x30], 0
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], 0x1f
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], 0x8b
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], 8
mov edx, dword [esi + 0x14]
mov ebx, dword [esi + 0x1c]
inc edx
mov dword [esi + 0x14], edx
test ebx, ebx
jne 0x50965e
mov eax, dword [esi + 8]
mov byte [edx + eax], bl
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], bl
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], bl
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], bl
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], bl
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x84]
inc edx
mov dword [esi + 0x14], edx
cmp eax, 9
jne 0x509627
mov cl, 2
jmp 0x50963b
cmp dword [esi + 0x88], 2
jge 0x509639
cmp eax, 2
jl 0x509639
xor cl, cl
jmp 0x50963b
mov cl, 4
mov eax, dword [esi + 8]
mov byte [edx + eax], cl
inc dword [esi + 0x14]
mov ecx, dword [esi + 0x14]
mov eax, dword [esi + 8]
mov byte [ecx + eax], 0xb
mov eax, 0x71
inc dword [esi + 0x14]
mov dword [esi + 4], eax
jmp 0x50982a
mov ecx, dword [ebx + 0x24]
mov eax, dword [ebx + 0x2c]
neg ecx
sbb cl, cl
and cl, 0x10
neg eax
sbb al, al
and al, 2
add cl, al
mov eax, dword [ebx + 0x1c]
neg eax
sbb al, al
and al, 8
add cl, al
mov eax, dword [ebx + 0x10]
neg eax
sbb al, al
and al, 4
add cl, al
cmp dword [ebx], 0
setne al
add cl, al
mov eax, dword [esi + 8]
mov byte [edx + eax], cl
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
mov ecx, dword [esi + 8]
movzx eax, byte [eax + 4]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
mov ecx, dword [esi + 8]
movzx eax, byte [eax + 5]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
mov ecx, dword [esi + 8]
movzx eax, byte [eax + 6]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
movzx eax, byte [eax + 7]
mov byte [edx + ecx], al
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x84]
inc edx
mov dword [esi + 0x14], edx
cmp eax, 9
jne 0x5096f9
mov cl, 2
jmp 0x50970d
cmp dword [esi + 0x88], 2
jge 0x50970b
cmp eax, 2
jl 0x50970b
xor cl, cl
jmp 0x50970d
mov cl, 4
mov eax, dword [esi + 8]
mov byte [edx + eax], cl
inc dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
mov al, byte [eax + 0xc]
mov byte [edx + ecx], al
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
inc edx
mov dword [esi + 0x14], edx
cmp dword [eax + 0x10], 0
je 0x50975b
movzx eax, byte [eax + 0x14]
mov ecx, dword [esi + 8]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
movzx eax, byte [eax + 0x15]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x2c], 0
je 0x509779
mov eax, dword [esi + 8]
test eax, eax
je 0x509776
mov ecx, dword [edi + 0x30]
push edx
mov edx, eax
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
mov eax, 0x45
mov dword [esi + 0x20], 0
mov dword [esi + 4], eax
jmp 0x50982a
mov eax, dword [esi + 0x30]
shl eax, 0xc
sub eax, 0x7800
cmp dword [esi + 0x88], 2
jge 0x5097d1
mov ecx, dword [esi + 0x84]
cmp ecx, 2
jl 0x5097d1
cmp ecx, 6
jge 0x5097bb
mov edx, 0x40
lea ecx, [edx + 0x20]
jmp 0x5097d8
jne 0x5097c7
mov edx, 0x80
lea ecx, [edx + 0x20]
jmp 0x5097d8
mov edx, 0xc0
lea ecx, [edx + 0x20]
jmp 0x5097d8
xor edx, edx
mov ecx, 0x20
cmp dword [esi + 0x6c], 0
mov dword [esi + 4], 0x71
cmove ecx, edx
or ecx, eax
mov eax, 0x8421085
mul ecx
sub ecx, edx
shr ecx, 1
add ecx, edx
shr ecx, 4
inc ecx
mov edx, ecx
shl edx, 5
sub edx, ecx
mov ecx, esi
call fcn.00509da0
cmp dword [esi + 0x6c], 0
je 0x509823
movzx edx, word [edi + 0x32]
mov ecx, esi
call fcn.00509da0
movzx edx, word [edi + 0x30]
mov ecx, esi
call fcn.00509da0
mov dword [edi + 0x30], 1
mov eax, dword [esi + 4]
cmp eax, 0x45
jne 0x509901
mov edx, dword [esi + 0x1c]
cmp dword [edx + 0x10], 0
je 0x5098f9
movzx eax, word [edx + 0x14]
mov ecx, dword [esi + 0x14]
mov ebx, ecx
mov dword [ebp - 8], ecx
cmp dword [esi + 0x20], eax
jae 0x5098be
cmp ebx, dword [esi + 0xc]
jne 0x509893
cmp dword [edx + 0x2c], 0
je 0x50987f
cmp ebx, ecx
jbe 0x50987f
mov edx, dword [esi + 8]
sub ebx, ecx
add edx, ecx
jne 0x509870
xor eax, eax
jmp 0x50987c
mov ecx, dword [edi + 0x30]
push ebx
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
mov ecx, edi
call fcn.00509d50
mov ecx, dword [esi + 0x14]
mov ebx, ecx
mov dword [ebp - 8], ecx
cmp ecx, dword [esi + 0xc]
je 0x5098be
mov eax, dword [esi + 0x1c]
mov ecx, dword [esi + 8]
mov edx, dword [eax + 0x10]
mov eax, dword [esi + 0x20]
mov al, byte [edx + eax]
mov byte [ebx + ecx], al
mov ebx, dword [esi + 0x14]
inc dword [esi + 0x20]
inc ebx
mov ecx, dword [ebp - 8]
mov dword [esi + 0x14], ebx
mov edx, dword [esi + 0x1c]
movzx eax, word [edx + 0x14]
cmp dword [esi + 0x20], eax
jb 0x509854
mov edx, dword [esi + 0x1c]
cmp dword [edx + 0x2c], 0
je 0x5098ea
cmp ebx, ecx
jbe 0x5098ea
mov edx, dword [esi + 8]
sub ebx, ecx
add edx, ecx
jne 0x5098d8
xor eax, eax
jmp 0x5098e4
mov ecx, dword [edi + 0x30]
push ebx
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
mov edx, dword [esi + 0x1c]
mov eax, dword [esi + 0x20]
cmp eax, dword [edx + 0x14]
jne 0x50993f
mov dword [esi + 0x20], 0
mov eax, 0x49
mov dword [esi + 4], eax
cmp eax, 0x49
jne 0x5099dc
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x1c], 0
je 0x5099d4
mov ecx, dword [esi + 0x14]
mov ebx, ecx
mov dword [ebp - 4], ecx
nop
cmp ebx, dword [esi + 0xc]
jne 0x509967
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x2c], 0
je 0x509953
cmp ebx, ecx
jbe 0x509953
mov edx, dword [esi + 8]
sub ebx, ecx
add edx, ecx
jne 0x509944
xor eax, eax
jmp 0x509950
mov eax, dword [esi + 4]
jmp 0x509901
mov ecx, dword [edi + 0x30]
push ebx
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
mov ecx, edi
call fcn.00509d50
mov ecx, dword [esi + 0x14]
mov ebx, ecx
mov dword [ebp - 4], ecx
cmp ecx, dword [esi + 0xc]
je 0x509997
mov eax, dword [esi + 0x1c]
mov ecx, dword [esi + 0x20]
mov eax, dword [eax + 0x1c]
mov dl, byte [ecx + eax]
movzx eax, dl
mov dword [ebp - 8], eax
lea eax, [ecx + 1]
mov ecx, dword [ebp - 4]
mov dword [esi + 0x20], eax
mov eax, dword [esi + 8]
mov byte [ebx + eax], dl
mov ebx, dword [esi + 0x14]
inc ebx
cmp dword [ebp - 8], 0
mov dword [esi + 0x14], ebx
je 0x50999e
jmp 0x509920
mov dword [ebp - 8], 1
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x2c], 0
je 0x5099c7
cmp ebx, ecx
jbe 0x5099c7
mov edx, dword [esi + 8]
sub ebx, ecx
add edx, ecx
jne 0x5099b8
xor eax, eax
jmp 0x5099c4
mov ecx, dword [edi + 0x30]
push ebx
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
cmp dword [ebp - 8], 0
jne 0x509a1f
mov dword [esi + 0x20], 0
mov eax, 0x5b
mov dword [esi + 4], eax
cmp eax, 0x5b
jne 0x509abd
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x24], 0
je 0x509bbf
mov ecx, dword [esi + 0x14]
mov ebx, ecx
mov dword [ebp - 8], ecx
nop word [eax + eax]
cmp ebx, dword [esi + 0xc]
jne 0x509a47
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x2c], 0
je 0x509a33
cmp ebx, ecx
jbe 0x509a33
mov edx, dword [esi + 8]
sub ebx, ecx
add edx, ecx
jne 0x509a24
xor eax, eax
jmp 0x509a30
mov eax, dword [esi + 4]
jmp 0x5099dc
mov ecx, dword [edi + 0x30]
push ebx
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
mov ecx, edi
call fcn.00509d50
mov ecx, dword [esi + 0x14]
mov ebx, ecx
mov dword [ebp - 8], ecx
cmp ecx, dword [esi + 0xc]
je 0x509a77
mov eax, dword [esi + 0x1c]
mov ecx, dword [esi + 0x20]
mov eax, dword [eax + 0x24]
mov dl, byte [ecx + eax]
movzx eax, dl
mov dword [ebp - 4], eax
lea eax, [ecx + 1]
mov ecx, dword [ebp - 8]
mov dword [esi + 0x20], eax
mov eax, dword [esi + 8]
mov byte [ebx + eax], dl
mov ebx, dword [esi + 0x14]
inc ebx
cmp dword [ebp - 4], 0
mov dword [esi + 0x14], ebx
je 0x509a7e
jmp 0x509a00
mov dword [ebp - 4], 1
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x2c], 0
je 0x509aa7
cmp ebx, ecx
jbe 0x509aa7
mov edx, dword [esi + 8]
sub ebx, ecx
add edx, ecx
jne 0x509a98
xor eax, eax
jmp 0x509aa4
mov ecx, dword [edi + 0x30]
push ebx
call fcn.0050a520
add esp, 4
mov dword [edi + 0x30], eax
cmp dword [ebp - 4], 0
jne 0x509bb7
mov dword [esi + 4], 0x67
mov eax, 0x67
cmp eax, 0x67
jne 0x509b17
mov eax, dword [esi + 0x1c]
cmp dword [eax + 0x2c], 0
je 0x509b10
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 0xc]
lea eax, [edx + 2]
cmp eax, ecx
jbe 0x509ae5
mov ecx, edi
call fcn.00509d50
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 0xc]
lea eax, [edx + 2]
cmp eax, ecx
ja 0x509b17
mov ecx, dword [esi + 8]
movzx eax, byte [edi + 0x30]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
movzx eax, byte [edi + 0x31]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov dword [edi + 0x30], 0
mov dword [esi + 4], 0x71
cmp dword [esi + 0x14], 0
je 0x509bcb
mov ecx, edi
call fcn.00509d50
cmp dword [edi + 0x10], 0
je 0x509d29
mov ebx, dword [ebp - 0xc]
mov eax, dword [esi + 4]
cmp eax, 0x29a
jne 0x509b49
cmp dword [edi + 4], 0
jne 0x509bea
cmp dword [edi + 4], 0
jne 0x509b68
cmp dword [esi + 0x74], 0
jne 0x509b68
test ebx, ebx
je 0x509c46
cmp eax, 0x29a
je 0x509c46
mov eax, dword [esi + 0x84]
push ebx
push esi
lea eax, [eax + eax*2]
mov eax, dword [eax*4 + 0x7a1450]
call eax
add esp, 8
cmp eax, 2
je 0x509b89
cmp eax, 3
jne 0x509b90
mov dword [esi + 4], 0x29a
test eax, eax
je 0x509d23
cmp eax, 2
je 0x509d23
cmp eax, 1
jne 0x509c46
mov ecx, esi
cmp ebx, eax
jne 0x509bfe
call fcn.00504ee0
jmp 0x509c35
mov eax, dword [esi + 4]
jmp 0x509abd
mov dword [esi + 4], 0x67
jmp 0x509ac2
cmp dword [edi + 4], 0
mov ebx, dword [ebp - 0xc]
jne 0x509b35
cmp ebx, dword [ebp - 0x10]
jg 0x509b35
cmp ebx, 4
je 0x509b35
mov eax, dword [str.buffer_error]
pop ebx
mov dword [edi + 0x18], eax
mov eax, 0xfffffffb
pop edi
pop esi
mov esp, ebp
pop ebp
ret
push 0
push 0
xor edx, edx
call fcn.00505090
add esp, 8
cmp ebx, 3
jne 0x509c35
mov eax, dword [esi + 0x44]
xor edx, edx
mov ecx, dword [esi + 0x4c]
mov word [eax + ecx*2 - 2], dx
mov eax, dword [esi + 0x4c]
lea eax, [eax*2 - 2]
push eax
push edx
push dword [esi + 0x44]
call fcn.004c0240
add esp, 0xc
mov ecx, edi
call fcn.00509d50
cmp dword [edi + 0x10], 0
je 0x509d29
cmp ebx, 4
jne 0x509d30
mov eax, dword [esi + 0x18]
test eax, eax
jg 0x509c60
lea eax, [ebx - 3]
pop ebx
pop edi
pop esi
mov esp, ebp
pop ebp
ret
cmp eax, 2
jne 0x509ceb
mov edx, dword [esi + 0x14]
movzx eax, byte [edi + 0x30]
mov ecx, dword [esi + 8]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
movzx eax, byte [edi + 0x31]
mov ecx, dword [esi + 8]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
movzx eax, byte [edi + 0x32]
mov ecx, dword [esi + 8]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
movzx eax, byte [edi + 0x33]
mov ecx, dword [esi + 8]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
movzx eax, byte [edi + 8]
mov ecx, dword [esi + 8]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
movzx eax, byte [edi + 9]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
movzx eax, byte [edi + 0xa]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
mov edx, dword [esi + 0x14]
mov ecx, dword [esi + 8]
movzx eax, byte [edi + 0xb]
mov byte [edx + ecx], al
inc dword [esi + 0x14]
jmp 0x509d01
movzx edx, word [edi + 0x32]
mov ecx, esi
call fcn.00509da0
movzx edx, word [edi + 0x30]
mov ecx, esi
call fcn.00509da0
mov ecx, edi
call fcn.00509d50
mov eax, dword [esi + 0x18]
test eax, eax
jle 0x509d14
neg eax
mov dword [esi + 0x18], eax
xor eax, eax
cmp dword [esi + 0x14], eax
pop ebx
pop edi
sete al
pop esi
mov esp, ebp
pop ebp
ret
cmp dword [edi + 0x10], 0
jne 0x509d30
mov dword [esi + 0x28], 0xffffffff
pop ebx
pop edi
xor eax, eax
pop esi
mov esp, ebp
pop ebp
ret
mov eax, dword [str.stream_error]
mov dword [edi + 0x18], eax
pop edi
mov eax, 0xfffffffe
pop esi
mov esp, ebp
pop ebp
ret