//
// DS_Dictionary::copyFile from 0x180019450 to 0x180019a1b (1483 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801438a8
// > ??> @ 0x1801ae968
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=5
void __fastcall DS_Dictionary::copyFile(const char *Src, const char *a2)
{
unsigned __int64 v4; // rsi
unsigned __int64 Size; // rdi
__int64 v6; // rcx
void **v7; // rbx
char *v8; // rbx
void **v9; // r12
void **v10; // r14
unsigned __int64 v11; // rdi
__int64 v12; // rbx
unsigned __int64 v13; // rcx
size_t v14; // rax
void *v15; // rax
void *v16; // rcx
_QWORD *v17; // rax
void **v18; // rbx
char *v19; // rbx
void **v20; // rbx
__int64 v21; // r12
unsigned __int8 v22; // r14
__int64 v23; // rbx
int v24; // eax
void *v25; // rcx
void *v26; // rcx
void *v27; // rcx
__int64 v28; // [rsp+30h] [rbp-D0h]
__int128 v29; // [rsp+40h] [rbp-C0h]
__int64 v30; // [rsp+50h] [rbp-B0h] BYREF
_BYTE v31[8]; // [rsp+58h] [rbp-A8h] BYREF
_BYTE v32[152]; // [rsp+60h] [rbp-A0h] BYREF
_BYTE v33[104]; // [rsp+F8h] [rbp-8h] BYREF
_QWORD v34[2]; // [rsp+160h] [rbp+60h] BYREF
_BYTE v35[8]; // [rsp+170h] [rbp+70h] BYREF
_BYTE v36[152]; // [rsp+178h] [rbp+78h] BYREF
_BYTE v37[96]; // [rsp+210h] [rbp+110h] BYREF
void *Block[2]; // [rsp+270h] [rbp+170h] BYREF
unsigned __int64 v39; // [rsp+280h] [rbp+180h]
unsigned __int64 v40; // [rsp+288h] [rbp+188h]
void *v41[2]; // [rsp+290h] [rbp+190h] BYREF
__int64 v42; // [rsp+2A0h] [rbp+1A0h]
unsigned __int64 v43; // [rsp+2A8h] [rbp+1A8h]
void *Srca[2]; // [rsp+2B0h] [rbp+1B0h] BYREF
unsigned __int64 v45; // [rsp+2C0h] [rbp+1C0h]
unsigned __int64 v46; // [rsp+2C8h] [rbp+1C8h]
sub_18003D240(Srca);
sub_180016C80((__int64)v41, (__int64)Srca);
v4 = -1;
Size = -1;
do
++Size;
while ( Src[Size] );
v6 = v42;
if ( Size > v43 - v42 )
{
sub_180007900(v41, Size, 0, Src, Size);
}
else
{
v42 += Size;
v7 = v41;
if ( v43 > 0xF )
v7 = (void **)v41[0];
v8 = (char *)v7 + v6;
memmove(v8, Src, Size);
v8[Size] = 0;
}
v9 = v41;
if ( v43 > 0xF )
v9 = (void **)v41[0];
*(_OWORD *)Block = 0;
v39 = 0;
v40 = 0;
v10 = Srca;
if ( v46 > 0xF )
v10 = (void **)Srca[0];
v11 = v45;
v12 = 0x7FFFFFFFFFFFFFFFLL;
if ( v45 > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
if ( v45 <= 0xF )
{
v39 = v45;
v13 = 15;
v40 = 15;
*(_OWORD *)Block = *(_OWORD *)v10;
goto LABEL_28;
}
v40 = 15;
if ( (v45 | 0xF) > 0x7FFFFFFFFFFFFFFFLL )
{
v14 = 0x8000000000000027uLL;
LABEL_17:
v15 = operator new(v14);
v16 = v15;
if ( !v15 )
goto LABEL_45;
v17 = (_QWORD *)(((unsigned __int64)v15 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*(v17 - 1) = v16;
goto LABEL_27;
}
v12 = v45 | 0xF;
if ( (v45 | 0xF) < 0x16 )
v12 = 22;
if ( (unsigned __int64)(v12 + 1) >= 0x1000 )
{
v14 = v12 + 40;
if ( v12 + 40 < (unsigned __int64)(v12 + 1) )
Concurrency::cancel_current_task();
goto LABEL_17;
}
if ( v12 == -1 )
v17 = nullptr;
else
v17 = operator new(v12 + 1);
LABEL_27:
Block[0] = v17;
v39 = v11;
v40 = v12;
memcpy(v17, v10, v11 + 1);
v13 = v12;
do
LABEL_28:
++v4;
while ( a2[v4] );
if ( v4 > v13 - v11 )
{
sub_180007900(Block, v4, 0, a2, v4);
}
else
{
v39 = v4 + v11;
v18 = Block;
if ( v13 > 0xF )
v18 = (void **)Block[0];
v19 = (char *)v18 + v11;
memmove(v19, a2, v4);
v19[v4] = 0;
}
v20 = Block;
if ( v40 > 0xF )
v20 = (void **)Block[0];
sub_180016A40((__int64)v34, (__int64)v9, 1, 0x40u, 1);
sub_180016B60((__int64)&v30, (__int64)v20, 2, 0x40u, 1);
v28 = std::ios::rdbuf((char *)v34 + *(int *)(v34[0] + 4LL));
v21 = std::ios::rdbuf(&v31[*(int *)(v30 + 4) - 8]);
v22 = 0;
v23 = v28;
if ( v28 )
goto LABEL_37;
while ( v23 )
{
if ( v21 )
std::streambuf::sputc(v21, v22);
if ( (unsigned int)std::streambuf::sbumpc(v23) == -1 )
{
LABEL_40:
v23 = 0;
}
else
{
LABEL_37:
if ( !v23 )
goto LABEL_40;
v24 = std::streambuf::sgetc(v23);
if ( v24 == -1 )
goto LABEL_40;
v22 = v24;
}
}
*(_QWORD *)&v31[*(int *)(v30 + 4) - 8] = &std::ofstream::`vftable';
*(_DWORD *)((char *)&v29 + *(int *)(v30 + 4) + 12) = *(_DWORD *)(v30 + 4) - 168;
sub_1800178D0((__int64)v31);
std::ostream::~ostream>(v32);
std::ios::~ios>(v33);
*(_QWORD *)((char *)v34 + *(int *)(v34[0] + 4LL)) = &std::ifstream::`vftable';
*(_DWORD *)&v33[*(int *)(v34[0] + 4LL) + 100] = *(_DWORD *)(v34[0] + 4LL) - 176;
sub_1800178D0((__int64)v35);
std::istream::~istream>(v36);
std::ios::~ios>(v37);
if ( v40 > 0xF )
{
v25 = Block[0];
if ( v40 + 1 >= 0x1000 )
{
v25 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v25 - 8) > 0x1F )
LABEL_45:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v25);
}
v39 = 0;
v40 = 15;
LOBYTE(Block[0]) = 0;
if ( v43 > 0xF )
{
v26 = v41[0];
if ( v43 + 1 >= 0x1000 )
{
v26 = *((void **)v41[0] - 1);
if ( (unsigned __int64)((char *)v41[0] - (char *)v26 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v26);
}
v42 = 0;
v43 = 15;
LOBYTE(v41[0]) = 0;
if ( v46 > 0xF )
{
v27 = Srca[0];
if ( v46 + 1 >= 0x1000 )
{
v27 = *((void **)Srca[0] - 1);
if ( (unsigned __int64)((char *)Srca[0] - (char *)v27 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v27);
}
}