Function at 0x513858
Capabilities:
Act as tcp client
Connect socket
Connect tcp socket
Create tcp socket
Initialize winsock library

Disassembly:
push ebp
mov ebp, esp
add esp, 0xfffffe48
push ebx
push esi
xor ebx, ebx
mov dword [ebp - 0x1b4], ebx
mov esi, ecx
mov ebx, edx
mov dword [ebp - 4], eax
mov eax, dword [ebp - 4]
call fcn.00405c0c
xor eax, eax
push ebp
push 0x513b30
push dword fs:[eax]
mov dword fs:[eax], esp
mov byte [ebp - 5], 0
mov word [0x59c600], si
cmp dword [ebp + 8], 0
je 0x51389f
mov eax, dword [ebp + 8]
mov byte [eax], 0
lea eax, [ebp - 0x1a0]
push eax
push 0x101
call sub.wsock32.dll_WSAStartup
test eax, eax
je 0x5138d6
cmp dword [ebp + 8], 0
je 0x513b0f
push ebp
call sub.wsock32.dll_WSAGetLastError
mov edx, eax
mov eax, 0x513b4c
call fcn.005136b0
pop ecx
jmp 0x513b0f
xor eax, eax
push ebp
push 0x513b08
push dword fs:[eax]
mov dword fs:[eax], esp
push 0x513658
call sub.wsock32.dll_WSASetBlockingHook
test eax, eax
jne 0x513915
cmp dword [ebp + 8], 0
je 0x51390b
push ebp
call sub.wsock32.dll_WSAGetLastError
mov edx, eax
mov eax, 0x513b60
call fcn.005136b0
pop ecx
call fcn.00405168
jmp 0x513b0f
xor eax, eax
push ebp
push 0x513aee
push dword fs:[eax]
mov dword fs:[eax], esp
push 6
push 1
push 2
call sub.wsock32.dll_socket
mov dword [ebp - 0xc], eax
cmp dword [ebp - 0xc], 0xffffffff
jne 0x51395f
cmp dword [ebp + 8], 0
je 0x513950
push ebp
call sub.wsock32.dll_WSAGetLastError
mov edx, eax
mov eax, 0x513b7c
call fcn.005136b0
pop ecx
call fcn.00405168
call fcn.00405168
jmp 0x513b0f
xor eax, eax
push ebp
push 0x513ad4
push dword fs:[eax]
mov dword fs:[eax], esp
mov word [ebp - 0x1b0], 2
mov word [ebp - 0x1ae], 0
xor eax, eax
mov dword [ebp - 0x1ac], eax
push 0x10
lea eax, [ebp - 0x1b0]
push eax
mov eax, dword [ebp - 0xc]
push eax
call sub.wsock32.dll_bind
test eax, eax
je 0x5139ca
cmp dword [ebp + 8], 0
je 0x5139b6
push ebp
call sub.wsock32.dll_WSAGetLastError
mov edx, eax
mov eax, 0x513b8c
call fcn.005136b0
pop ecx
call fcn.00405168
call fcn.00405168
call fcn.00405168
jmp 0x513b0f
mov word [ebp - 0x1b0], 2
push ebx
call sub.wsock32.dll_htons
mov word [ebp - 0x1ae], ax
movzx eax, byte [ebp + 0xc]
dec eax
sub al, 4
jae 0x513a1e
push ebp
lea edx, [ebp - 0x1b4]
mov eax, dword [ebp - 4]
call fcn.00513750
pop ecx
mov eax, dword [ebp - 0x1b4]
call fcn.00405c1c
push eax
call sub.wsock32.dll_inet_addr
mov dword [ebp - 0x1b8], eax
mov eax, dword [ebp - 0x1b8]
mov dword [ebp - 0x1ac], eax
jmp 0x513a3e
mov eax, dword [ebp - 4]
call fcn.00405c1c
push eax
call sub.wsock32.dll_inet_addr
mov dword [ebp - 0x1b8], eax
mov eax, dword [ebp - 0x1b8]
mov dword [ebp - 0x1ac], eax
call sub.kernel32.dll_GetTickCount_1
mov dword [0x59c604], eax
push 0x10
lea eax, [ebp - 0x1b0]
push eax
mov eax, dword [ebp - 0xc]
push eax
call sub.wsock32.dll_connect
test eax, eax
je 0x513a7d
mov byte [ebp - 5], 0
cmp dword [ebp + 8], 0
je 0x513abd
push ebp
call sub.wsock32.dll_WSAGetLastError
mov edx, eax
mov eax, 0x513b9c
call fcn.005136b0
pop ecx
jmp 0x513abd
mov dword [ebp - 0x10], 0x10
lea eax, [ebp - 0x10]
push eax
lea eax, [ebp - 0x1b0]
push eax
mov eax, dword [ebp - 0xc]
push eax
call sub.wsock32.dll_getpeername
test eax, eax
sete byte [ebp - 5]
cmp byte [ebp - 5], 0
jne 0x513abd
cmp dword [ebp + 8], 0
je 0x513abd
push ebp
call sub.wsock32.dll_WSAGetLastError
mov edx, eax
mov eax, 0x513bac
call fcn.005136b0
pop ecx
xor eax, eax
pop edx
pop ecx
pop ecx
mov dword fs:[eax], edx
push 0x513adb
mov eax, dword [ebp - 0xc]
push eax
call sub.wsock32.dll_closesocket
ret
xor eax, eax
pop edx
pop ecx
pop ecx
mov dword fs:[eax], edx
push 0x513b37
lea eax, [ebp - 0x1b4]
call fcn.00405748
lea eax, [ebp - 4]
call fcn.00405748
ret