Function at 0x659700
Capabilities:
Encode data using xor

Disassembly:
sub esp, 0x98
push ebx
push ebp
mov ebx, 1
test byte [0xb2dda0], bl
push esi
push edi
mov dword [0xa038f0], ebx
jne 0x659735
or dword [0xb2dda0], ebx
call fcn.00590b60
push 0x681770
call fcn.004a9213
add esp, 4
test byte [0xb2ef5c], bl
mov dword [0x9cd8c8], 0
jne 0x65975f
or dword [0xb2ef5c], ebx
call fcn.005d24b0
push 0x681580
call fcn.004a9213
add esp, 4
cmp dword [0xb1fb1c], 0
je 0x659a12
test byte [0xb2ef5c], bl
jne 0x65978c
or dword [0xb2ef5c], ebx
call fcn.005d24b0
push 0x681580
call fcn.004a9213
add esp, 4
push 0xb1fc28
push 0xb1fb00
call fcn.005d2f50
push 0x3f
lea eax, [esp + 0x2d]
push 0
push eax
mov byte [esp + 0x34], 0
call fcn.004ae0b0
add esp, 0xc
push 0x3f
lea ecx, [esp + 0x6d]
push 0
push ecx
mov byte [esp + 0x74], 0
call fcn.004ae0b0
add esp, 0xc
test byte [0xb2ef5c], bl
jne 0x6597e7
or dword [0xb2ef5c], ebx
call fcn.005d24b0
push 0x681580
call fcn.004a9213
add esp, 4
mov esi, dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
push 0xb1fb00
call esi
push 0x40
lea edx, [esp + 0x2c]
push 0xb1fb44
push edx
call fcn.004a9840
mov eax, dword [0xb1fb84]
add esp, 0xc
mov edx, 0xb1fb88
mov dword [esp + 0x24], eax
call fcn.005d2710
mov edi, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov ebp, eax
push 0xb1fb00
mov dword [esp + 0x20], ebp
call edi
test byte [0xb2ef5c], bl
jne 0x65984e
or dword [0xb2ef5c], ebx
call fcn.005d24b0
push 0x681580
call fcn.004a9213
add esp, 4
push 0xb1fb00
call esi
push 0x40
lea ecx, [esp + 0x6c]
push 0xb1fba8
push ecx
call fcn.004a9840
add esp, 0xc
push 0xb1fb00
call edi
lea edx, [esp + 0x28]
push edx
call fcn.005d2950
mov ebx, eax
lea eax, [esp + 0x6c]
add esp, 4
push eax
mov dword [esp + 0x1c], ebx
call fcn.005d2a40
add esp, 4
cmp ebp, 0xffffffff
mov dword [esp + 0x20], eax
je 0x6598a3
mov dword [esp + 0x14], 1
jmp 0x6598cc
mov esi, ebx
mov edx, 0xb1763c
call fcn.00591310
xor ecx, ecx
test eax, eax
je 0x6598c8
cmp dword [eax + 0x24], ecx
je 0x6598bf
mov ecx, 1
cmp dword [eax + 0x28], 0
je 0x6598c8
add ecx, 1
mov dword [esp + 0x14], ecx
xor eax, eax
cmp dword [esp + 0x14], eax
mov dword [esp + 0x10], eax
jbe 0x6599ff
mov ebp, 0x9549d8
jmp 0x6598eb
mov ebx, dword [esp + 0x18]
mov eax, dword [esp + 0x10]
test eax, eax
jbe 0x6598fe
push 0
push 0
push eax
mov eax, 0x9540a8
call fcn.005affe0
lea ecx, [ebp + 0x678]
push ecx
mov eax, ebx
mov dword [ebp + 0x520], 0
call fcn.005921b0
mov eax, ebx
mov edi, ebp
call fcn.005aef10
mov eax, ebx
mov edx, 0xb17630
call fcn.005923a0
cmp dword [esp + 0x24], 0xffffffff
mov edi, eax
je 0x659956
test byte [0xb2dda0], 1
jne 0x659956
or dword [0xb2dda0], 1
call fcn.00590b60
push 0x681770
call fcn.004a9213
add esp, 4
mov ebx, dword [esp + 0x1c]
or esi, 0xffffffff
cmp ebx, esi
mov dword [ebp + 0xc], edi
jne 0x65998e
xor edi, edi
mov eax, dword [esp + 0x18]
push edi
mov ecx, 0xb17630
call fcn.00592490
test eax, eax
je 0x65997c
add esi, 1
cmp esi, dword [esp + 0x10]
je 0x65998c
add edi, 1
cmp edi, 5
jl 0x659966
jmp 0x65998e
mov ebx, edi
test byte [0xb2dda0], 1
mov dword [ebp + 4], ebx
jne 0x6599b3
or dword [0xb2dda0], 1
call fcn.00590b60
push 0x681770
call fcn.004a9213
add esp, 4
cmp ebx, 4
ja 0x6599c1
mov eax, dword [ebx*4 + 0x710d8c]
jmp 0x6599c6
mov eax, dword [0x710d9c]
push eax
push str.Player_Variant_Choice:__s_n
call fcn.00408d10
mov edi, dword [esp + 0x28]
add esp, 8
push ebp
mov dword [0x9cdca4], edi
call fcn.005ae130
mov eax, dword [esp + 0x10]
add eax, 1
add ebp, 0xec8
cmp eax, dword [esp + 0x14]
mov dword [esp + 0x10], eax
jb 0x6598e3
mov edx, dword [esp + 0xac]
mov eax, dword [esp + 0x14]
mov dword [edx + 8], eax
mov ebx, 1
mov ecx, 0x725550
call fcn.006531b0
xor edx, edx
test eax, eax
jbe 0x659a4a
mov ecx, 0x9555c8
jmp 0x659a30
lea esi, [edx*4]
xor esi, dword [ecx]
add edx, ebx
and esi, 0x3c
xor dword [ecx], esi
add ecx, 0xec8
cmp edx, eax
jb 0x659a30
pop edi
pop esi
pop ebp
mov eax, 0xc
pop ebx
add esp, 0x98
ret 4