Function at 0x409660
Capabilities:
Allocate thread local storage
Get thread local storage value
Set thread local storage value
Write file on windows

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x82c
mov eax, dword [0x4ff004]
xor eax, ebp
mov dword [ebp - 4], eax
mov eax, dword [ebp + 8]
push ebx
mov dword [ebp - 0x810], eax
mov ebx, ecx
mov eax, dword [ebp + 0xc]
push esi
mov dword [ebp - 0x80c], eax
mov eax, dword [0x4ffde8]
push edi
mov edi, edx
cmp eax, 0xffffffff
jne 0x4096a1
call dword [sym.imp.KERNEL32.dll_TlsAlloc]
mov dword [0x4ffde8], eax
push eax
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
mov esi, eax
test esi, esi
jne 0x4096c9
mov esi, dword [0x4ffde4]
push esi
push dword [0x4ffde8]
lea eax, [esi + 1]
mov dword [0x4ffde4], eax
call dword [sym.imp.KERNEL32.dll_TlsSetValue]
push edi
push ebx
push esi
push str.__d__s:__4d:
lea eax, [ebp - 0x808]
push 0x800
push eax
call fcn.0041c830
add esp, 0x18
cmp eax, 0x7eb
ja 0x4098d9
push dword [ebp - 0x80c]
mov edx, 0x800
lea ecx, [ebp - 0x808]
push dword [ebp - 0x810]
sub edx, eax
add ecx, eax
call fcn.0041ca10
add esp, 8
test eax, eax
js 0x4098d9
lea edi, [ebp - 0x808]
lea ecx, [edi + 1]
mov al, byte [edi]
inc edi
test al, al
jne 0x409724
mov esi, dword [0x500b60]
sub edi, ecx
test esi, esi
je 0x409756
mov esi, dword [esi + 0x3e28]
test esi, esi
je 0x409756
push edi
lea eax, [ebp - 0x808]
mov ecx, esi
push eax
call dword [0x460280]
call esi
add esp, 8
cmp byte [0x500960], 0
je 0x4098c6
push 0x4f7908
lea eax, [ebp - 0x80c]
push 0x500960
push eax
call fcn.0044bf78
add esp, 0xc
test eax, eax
jne 0x409939
mov eax, dword [ebp - 0x80c]
mov dword [ebp - 0x81c], eax
lea eax, [ebp - 0x828]
push eax
call fcn.0044609b
mov esi, dword [ebp - 0x828]
add esp, 4
push 0
push 0x15180
push dword [ebp - 0x824]
push esi
call fcn.0045f380
mov ebx, eax
mov eax, 0x91a2b3c5
imul ecx, ebx, 0x15180
sub esi, ecx
mul esi
mov ecx, esi
mov eax, edx
shr eax, 0xb
mov dword [ebp - 0x818], eax
imul eax, eax, 0xe10
sub ecx, eax
mov eax, 0x88888889
mul ecx
mov eax, edx
shr eax, 5
mov dword [ebp - 0x814], eax
mov eax, 0x88888889
mul esi
shr edx, 5
mov eax, edx
shl eax, 4
sub eax, edx
shl eax, 2
sub esi, eax
mov eax, 0x6719f361
mul ebx
mov dword [ebp - 0x810], esi
mov esi, ebx
sub esi, edx
shr esi, 1
add esi, edx
shr esi, 8
imul eax, esi, 0x16d
lea ecx, [esi + 1]
shr ecx, 2
lea edx, [esi - 1]
add ecx, eax
cmp ecx, ebx
cmovbe edx, esi
imul eax, edx, 0xfffffe93
lea ecx, [edx + 1]
shr ecx, 2
sub eax, ecx
add ebx, eax
mov eax, edx
and al, 3
cmp al, 2
jne 0x409859
cmp ebx, 0x3b
jne 0x409856
lea eax, [ebx - 0x39]
jmp 0x409870
jb 0x409859
dec ebx
mov eax, 1
movzx ecx, bx
cmp dword [eax*4 + 0x4674b0], ecx
jg 0x409870
inc eax
cmp eax, 0xc
jb 0x409861
push dword [ebp - 0x810]
sub ebx, dword [eax*4 + 0x4674ac]
push dword [ebp - 0x814]
inc ebx
push dword [ebp - 0x818]
push ebx
push eax
lea eax, [edx + 0x7b2]
push eax
push str.__04d__02d__02d__02d:_02d:_02d_:
push dword [ebp - 0x81c]
call fcn.00409510
push dword [ebp - 0x80c]
lea eax, [ebp - 0x808]
push edi
push 1
push eax
call fcn.0044be5e
push dword [ebp - 0x80c]
call fcn.00449c65
add esp, 0x34
mov eax, edi
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004423fe
mov esp, ebp
pop ebp
ret
xor eax, eax
nop dword [eax + eax]
cmp eax, 0x800
jae 0x4098f1
inc eax
cmp byte [eax + str.dbglogf_failed_n], 0
jne 0x4098e0
lea ecx, [eax + 1]
cmp ecx, 0x800
jbe 0x409931
push 0x14a
push str.ymemory
push str.YPANIC:_s:_d_n
push 0x14a
push str.ymemory
call fcn.00409950
add esp, 0x14
or eax, 0xffffffff
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004423fe
mov esp, ebp
pop ebp
ret
mov byte [ebp + eax - 0x808], 0
mov ecx, dword [ebp - 4]
or eax, 0xffffffff
pop edi
pop esi
xor ecx, ebp
pop ebx
call fcn.004423fe
mov esp, ebp
pop ebp
ret