Function at 0x100ed450
Capabilities:
Reference sql statements

Disassembly:
push ebp
mov ebp, esp
and esp, 0xfffffff8
sub esp, 0x14
mov eax, dword [ebp + 0xc]
push ebx
push esi
mov esi, dword [ebp + 0x14]
and eax, 8
push edi
push 0x5c
mov dword [esp + 0x1c], eax
mov edi, ecx
lea eax, [esi + 4]
mov dword [esp + 0x10], edx
push 0
push eax
mov dword [esp + 0x1c], 1
mov dword [esp + 0x20], 0
call sub.VCRUNTIME140.dll_memset
mov ecx, dword [ebp + 0x10]
add esp, 0xc
mov dword [esi], ecx
mov ebx, dword [edi + 0x3c]
test ebx, ebx
jne 0x100ed4c4
mov eax, dword [edi]
push dword [eax + 8]
push dword [eax + 4]
push str.SELECT_pgno_FROM__q._q_idx_WHERE_segid__AND_term___ORDER_BY_term_DESC_LIMIT_1
call sym.sqlite3.dll_sqlite3_mprintf
add esp, 0xc
lea edx, [edi + 0x3c]
mov ecx, edi
push eax
call fcn.100e9710
mov ebx, dword [edi + 0x3c]
add esp, 4
mov ecx, dword [ebp + 0x10]
cmp dword [edi + 0x24], 0
jne 0x100ed670
mov eax, dword [ecx]
cdq
push edx
push eax
push 1
push ebx
call sym.sqlite3.dll_sqlite3_bind_int64
add esp, 0x10
mov edx, 2
mov ecx, ebx
call fcn.10031340
test eax, eax
jne 0x100ed540
cmp dword [esp + 0xc], eax
je 0x100ed52d
mov ecx, dword [ebx + 0x6c]
push eax
push eax
mov eax, dword [ebp + 8]
add ecx, 0x28
cdq
push edx
mov edx, dword [esp + 0x18]
push eax
call fcn.10028550
add esp, 0x10
mov dword [esp + 0x1c], eax
test eax, eax
je 0x100ed52d
mov ecx, dword [ebx]
mov edx, eax
mov dword [ecx + 0x40], eax
call fcn.10008a20
mov edx, dword [esp + 0x1c]
mov ecx, dword [ebx]
call fcn.10005460
mov eax, dword [ebx]
mov eax, dword [eax + 0xc]
test eax, eax
je 0x100ed540
push eax
call dword [0x1011d150]
add esp, 4
push ebx
call sym.sqlite3.dll_sqlite3_step
add esp, 4
cmp eax, 0x64
jne 0x100ed56b
push 0
push ebx
call sym.sqlite3.dll_sqlite3_column_int
cdq
add esp, 8
mov ecx, eax
shrd eax, edx, 1
and ecx, 1
mov dword [esp + 0x10], eax
mov dword [esp + 0x14], ecx
push ebx
call sym.sqlite3.dll_sqlite3_reset
add esp, 4
mov dword [edi + 0x24], eax
mov edx, 2
mov ecx, ebx
call fcn.10031340
test eax, eax
jne 0x100ed59a
mov eax, dword [ebx]
mov eax, dword [eax + 0xc]
test eax, eax
je 0x100ed59a
push eax
call dword [0x1011d150]
add esp, 4
mov eax, dword [ebp + 0x10]
xor ecx, ecx
mov edx, esi
mov eax, dword [eax + 4]
cmp dword [esp + 0x10], eax
cmovge ecx, dword [esp + 0x14]
cmovge eax, dword [esp + 0x10]
mov dword [esp + 0x1c], ecx
dec eax
mov ecx, edi
mov dword [esi + 8], eax
call fcn.100ebed0
cmp dword [esi + 0xc], 0
mov ebx, dword [esp + 0x18]
je 0x100ed5df
push dword [ebp + 8]
mov edx, ebx
mov ecx, edi
push dword [esp + 0x10]
push esi
call fcn.100ecfa0
add esp, 0xc
cmp dword [edi + 0x24], 0
jne 0x100ed646
test ebx, ebx
jne 0x100ed646
mov edx, dword [esi + 4]
mov ebx, dword [esi + 0xc]
or edx, 1
mov dword [esi + 4], edx
test ebx, ebx
je 0x100ed646
mov eax, dword [ebp + 0xc]
and eax, 2
mov dword [ebp + 0xc], eax
je 0x100ed60a
or edx, 2
mov dword [esi + 4], edx
cmp dword [esp + 0x1c], 0
je 0x100ed639
mov ecx, dword [esi + 0x24]
and edx, 2
cmp ecx, dword [esi + 8]
jne 0x100ed624
mov eax, dword [esi + 0x30]
cmp eax, dword [ebx + 8]
jl 0x100ed636
mov eax, dword [esi]
push ecx
mov ecx, edi
push dword [eax]
call fcn.100eb290
add esp, 8
mov dword [esi + 0x40], eax
mov eax, dword [ebp + 0xc]
test eax, eax
je 0x100ed646
mov edx, esi
mov ecx, edi
call fcn.100ecd10
test byte [esi + 4], 2
je 0x100ed65a
mov dword [esi + 0x20], 0x100ec6a0
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
mov eax, dword [edi]
mov ecx, 0x100ec940
mov edx, 0x100ec720
cmp dword [eax + 0x30], 1
cmove ecx, edx
mov dword [esi + 0x20], ecx
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret