//
// sub_768348 from 0x768348 to 0x768bc6 (2174 bytes)
//
// 4 xrefs:
// > sub_768348 @ 0x7685e0
// > sub_768348 @ 0x768794
// > sub_768BD8 @ 0x768c20
// > sub_768CD0 @ 0x768d18
//
// 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
//
_DWORD *__fastcall sub_768348(
_DWORD *a1,
int a2,
_DWORD *a3,
int a4,
_DWORD *a5,
int a6,
int a7,
_DWORD *a8,
int *a9,
const wchar_t *a10)
{
int v10; // r4
const wchar_t *v11; // r5
_DWORD *v12; // r8
int *v13; // r4
size_t v14; // r0
size_t v15; // r10
const char *v16; // r1
_DWORD *v17; // r3
size_t v18; // r6
_DWORD *v19; // r0
int v20; // r7
int v21; // r3
_BOOL4 v22; // r2
bool v23; // zf
int v24; // r1
_DWORD *v26; // r2
int v27; // r0
int *v28; // r2
int v29; // r0
_DWORD *v30; // r3
int v31; // r3
const wchar_t *v32; // r7
_DWORD *v33; // r0
wchar_t v34; // r7
size_t v35; // r9
int v36; // r0
bool v37; // zf
int *v38; // r2
int v39; // r0
unsigned int v40; // r3
int v41; // r0
_DWORD *v42; // r3
_DWORD *v43; // r0
int v44; // r1
_DWORD *v45; // r2
int v46; // r3
_DWORD *v47; // r1
_DWORD *v48; // r3
int v49; // r1
int v50; // r3
int v51; // r7
const char *v52; // r1
int *v53; // r0
void *v54; // r2
int v55; // r2
_DWORD *v56; // r0
int v57; // r1
int *v58; // lr
int v59; // r1
int v60; // r2
int v61; // r3
int v62; // r0
int v63; // r7
int v64; // r7
int v65; // r7
_DWORD *v66; // r3
_DWORD *v67; // r1
_DWORD *v68; // r0
int v69; // r1
int *v70; // r3
int v71; // r0
unsigned int v72; // r3
int v73; // r0
unsigned int v74; // r2
_DWORD *v75; // [sp+0h] [bp-50h]
int v76; // [sp+4h] [bp-4Ch]
int *v77; // [sp+8h] [bp-48h]
int v78; // [sp+Ch] [bp-44h]
int v79; // [sp+10h] [bp-40h]
unsigned int v80; // [sp+14h] [bp-3Ch]
int v81; // [sp+18h] [bp-38h]
_DWORD *v84; // [sp+48h] [bp-8h] BYREF
const char *v85; // [sp+4Ch] [bp-4h]
_DWORD *v86; // [sp+50h] [bp+0h] BYREF
int v87; // [sp+54h] [bp+4h]
int v88; // [sp+58h] [bp+8h] BYREF
int v89; // [sp+5Ch] [bp+Ch] BYREF
int v90; // [sp+60h] [bp+10h] BYREF
int v91; // [sp+64h] [bp+14h]
int v92; // [sp+68h] [bp+18h]
int v93; // [sp+6Ch] [bp+1Ch]
int v94; // [sp+70h] [bp+20h]
int v95; // [sp+74h] [bp+24h]
int v96; // [sp+78h] [bp+28h]
int v97; // [sp+7Ch] [bp+2Ch]
int v98; // [sp+80h] [bp+30h]
int v99; // [sp+84h] [bp+34h]
int v100; // [sp+88h] [bp+38h]
int v101; // [sp+8Ch] [bp+3Ch]
v10 = a7 + 108;
v86 = a3;
v87 = a4;
v11 = a10;
v12 = sub_765568(a7 + 108);
v13 = (int *)sub_764188(v10);
v14 = wcslen(v11);
v15 = 0;
v16 = "%m/%d/%y";
v88 = 0;
v17 = v86;
v18 = v14;
while ( 1 )
{
if ( !v17 )
goto LABEL_20;
if ( v87 != -1 )
goto LABEL_4;
v26 = (_DWORD *)v17[2];
v27 = (unsigned int)v26 >= v17[3] ? (*(int (__fastcall **)(_DWORD *))(*v17 + 36))(v17) : *v26;
v16 = (const char *)(v27 + 1);
if ( v27 != -1 )
break;
v86 = nullptr;
LABEL_20:
v19 = a5;
if ( !a5 )
goto LABEL_31;
v20 = 1;
if ( a6 == -1 )
goto LABEL_22;
LABEL_6:
if ( !v20 )
goto LABEL_31;
LABEL_7:
v21 = v88;
v22 = v15 < v18;
if ( v88 )
v22 = 0;
if ( !v22 )
goto LABEL_10;
v32 = &v11[v15];
if ( (*(int (__fastcall **)(int *, const wchar_t, _DWORD))(*v13 + 48))(v13, *v32, 0) == 37 )
{
v35 = v15 + 1;
v36 = (*(int (__fastcall **)(int *, const wchar_t, _DWORD))(*v13 + 48))(v13, v32[1], 0);
v89 = 0;
v37 = v36 == 69;
if ( v36 != 69 )
v37 = v36 == 79;
if ( v37 )
{
v35 = v15 + 2;
v36 = (*(int (__fastcall **)(int *, const wchar_t, _DWORD))(*v13 + 48))(v13, v32[2], 0);
}
switch ( v36 )
{
case 'A':
v42 = (_DWORD *)v12[2];
v43 = a5;
v44 = a6;
v90 = v42[11];
v91 = v42[12];
v45 = a9 + 6;
v92 = v42[13];
v93 = *(_DWORD *)(v12[2] + 56);
v94 = *(_DWORD *)(v12[2] + 60);
v95 = *(_DWORD *)(v12[2] + 64);
v46 = *(_DWORD *)(v12[2] + 68);
goto LABEL_64;
case 'B':
v47 = (_DWORD *)v12[2];
v48 = a9 + 4;
v90 = v47[25];
v91 = v47[26];
v92 = v47[27];
v93 = *(_DWORD *)(v12[2] + 112);
v94 = *(_DWORD *)(v12[2] + 116);
v95 = *(_DWORD *)(v12[2] + 120);
v96 = *(_DWORD *)(v12[2] + 124);
v97 = *(_DWORD *)(v12[2] + 128);
v98 = *(_DWORD *)(v12[2] + 132);
v99 = *(_DWORD *)(v12[2] + 136);
v100 = *(_DWORD *)(v12[2] + 140);
v49 = *(_DWORD *)(v12[2] + 144);
goto LABEL_66;
case 'C':
case 'Y':
case 'y':
sub_7642F0(&v84, a2, v86, v87, a5, a6, &v89, 0, 9999, 4u, a7, &v88);
v16 = v85;
v86 = v84;
v87 = (int)v85;
if ( v88 )
goto LABEL_92;
v15 = v35;
if ( v89 >= 0 )
v50 = v89 - 1900;
else
v50 = v89 + 100;
a9[5] = v50;
v17 = v86;
goto LABEL_37;
case 'D':
v51 = *v13;
v52 = "%m/%d/%y";
v53 = v13;
v54 = &unk_9BFE7D;
goto LABEL_73;
case 'H':
v55 = 23;
v56 = a5;
v57 = a6;
v78 = 0;
v58 = a9 + 2;
v81 = a7;
goto LABEL_75;
case 'I':
v60 = 1;
v75 = a5;
v76 = a6;
v81 = a7;
v77 = a9 + 2;
v61 = 12;
goto LABEL_79;
case 'M':
v55 = 59;
v56 = a5;
v57 = a6;
v78 = 0;
v58 = a9 + 1;
v81 = a7;
LABEL_75:
v75 = v56;
v76 = v57;
v77 = v58;
v79 = v55;
v80 = 2;
goto LABEL_76;
case 'R':
v51 = *v13;
v53 = v13;
v52 = "%H:%M";
v54 = &unk_9BFE86;
goto LABEL_73;
case 'S':
v81 = a7;
v75 = a5;
v76 = a6;
v77 = a9;
v79 = 61;
v78 = 0;
v59 = a2;
v80 = 2;
goto LABEL_77;
case 'T':
v51 = *v13;
v53 = v13;
v52 = "%H:%M:%S";
v54 = &unk_9BFE91;
LABEL_73:
(*(void (__fastcall **)(int *, const char *, void *, int *))(v51 + 44))(v53, v52, v54, &v90);
v15 = v35;
sub_768348(&v84, a2, v86, v87, a5, a6, a7, &v88, a9, &v90);
v16 = v85;
v86 = v84;
v87 = (int)v85;
v17 = v84;
goto LABEL_37;
case 'X':
sub_768348(&v84, a2, v86, v87, a5, a6, a7, &v88, a9, *(_DWORD *)(v12[2] + 16));
goto LABEL_62;
case 'Z':
v62 = sub_767AC4(&v86);
if ( !(*(int (__fastcall **)(int *, int, int))(*v13 + 8))(v13, 1, v62) )
goto LABEL_56;
sub_767AFC(&v84, a2, v86, v87, (int)a5, a6, &v90, (int)&off_ABD76C, 14, a7, &v88);
v86 = v84;
v87 = (int)v85;
v63 = sub_767AC4(&v86);
if ( (v63 == -1) != (sub_767AC4(&a5) == -1) && !v88 && !v90 )
{
v64 = sub_767AC4(&v86);
if ( v64 == (*(int (__fastcall **)(int *, int))(*v13 + 40))(v13, 45)
|| (v65 = sub_767AC4(&v86), v65 == (*(int (__fastcall **)(int *, int))(*v13 + 40))(v13, 43)) )
{
sub_7642F0(&v84, a2, v86, v87, a5, a6, &v90, 0, 23, 2u, a7, &v88);
v86 = v84;
v87 = (int)v85;
sub_7642F0(&v84, a2, v84, (int)v85, a5, a6, &v90, 0, 59, 2u, a7, &v88);
v16 = v85;
v86 = v84;
v87 = (int)v85;
}
}
LABEL_92:
v17 = v86;
v15 = v35;
goto LABEL_37;
case 'a':
v66 = (_DWORD *)v12[2];
v43 = a5;
v44 = a6;
v90 = v66[18];
v91 = v66[19];
v45 = a9 + 6;
v92 = v66[20];
v93 = *(_DWORD *)(v12[2] + 84);
v94 = *(_DWORD *)(v12[2] + 88);
v95 = *(_DWORD *)(v12[2] + 92);
v46 = *(_DWORD *)(v12[2] + 96);
LABEL_64:
v15 = v35;
v96 = v46;
sub_767AFC(&v84, a2, v86, v87, (int)v43, v44, v45, (int)&v90, 7, a7, &v88);
v16 = v85;
v86 = v84;
v87 = (int)v85;
v17 = v84;
goto LABEL_37;
case 'b':
case 'h':
v67 = (_DWORD *)v12[2];
v48 = a9 + 4;
v90 = v67[37];
v91 = v67[38];
v92 = v67[39];
v93 = *(_DWORD *)(v12[2] + 160);
v94 = *(_DWORD *)(v12[2] + 164);
v95 = *(_DWORD *)(v12[2] + 168);
v96 = *(_DWORD *)(v12[2] + 172);
v97 = *(_DWORD *)(v12[2] + 176);
v98 = *(_DWORD *)(v12[2] + 180);
v99 = *(_DWORD *)(v12[2] + 184);
v100 = *(_DWORD *)(v12[2] + 188);
v49 = *(_DWORD *)(v12[2] + 192);
LABEL_66:
v101 = v49;
v15 = v35;
sub_767AFC(&v84, a2, v86, v87, (int)a5, a6, v48, (int)&v90, 12, a7, &v88);
v16 = v85;
v86 = v84;
v87 = (int)v85;
v17 = v84;
goto LABEL_37;
case 'c':
sub_768348(&v84, a2, v86, v87, a5, a6, a7, &v88, a9, *(_DWORD *)(v12[2] + 24));
goto LABEL_62;
case 'd':
v60 = 1;
v68 = a5;
v69 = a6;
v81 = a7;
v70 = a9 + 3;
goto LABEL_97;
case 'e':
v71 = sub_767AC4(&v86);
if ( (*(int (__fastcall **)(int *, int, int))(*v13 + 8))(v13, 8, v71) )
{
if ( v86 )
{
v72 = v86[2];
if ( v72 >= v86[3] )
sub_762BE0((int)v86);
else
v86[2] = v72 + 4;
v87 = -1;
}
v75 = a5;
v76 = a6;
v81 = a7;
v77 = a9 + 3;
v78 = 1;
v80 = 1;
v79 = 9;
LABEL_76:
v59 = a2;
}
else
{
v60 = 10;
v68 = a5;
v69 = a6;
v81 = a7;
v70 = a9 + 3;
LABEL_97:
v77 = v70;
v61 = 31;
v75 = v68;
v76 = v69;
LABEL_79:
v79 = v61;
v78 = v60;
v80 = 2;
v59 = a2;
}
LABEL_77:
v15 = v35;
sub_7642F0(&v84, v59, v86, v87, v75, v76, v77, v78, v79, v80, v81, &v88);
v16 = v85;
v86 = v84;
v87 = (int)v85;
v17 = v84;
goto LABEL_37;
case 'm':
sub_7642F0(&v84, a2, v86, v87, a5, a6, &v89, 1, 12, 2u, a7, &v88);
v16 = v85;
v86 = v84;
v87 = (int)v85;
if ( v88 )
goto LABEL_92;
v16 = (const char *)a9;
v15 = v35;
v17 = v86;
a9[4] = v89 - 1;
goto LABEL_37;
case 'n':
v73 = sub_767AC4(&v86);
if ( (*(int (__fastcall **)(int *, int, _DWORD))(*v13 + 48))(v13, v73, 0) == 10 )
goto LABEL_107;
goto LABEL_56;
case 't':
v41 = sub_767AC4(&v86);
if ( (*(int (__fastcall **)(int *, int, _DWORD))(*v13 + 48))(v13, v41, 0) != 9 )
goto LABEL_56;
LABEL_107:
v17 = v86;
if ( !v86 )
goto LABEL_57;
v74 = v86[2];
v16 = (const char *)v86[3];
if ( v74 >= (unsigned int)v16 )
{
sub_762BE0((int)v86);
v17 = v86;
}
else
{
v86[2] = v74 + 4;
}
v15 = v35;
v87 = -1;
break;
case 'x':
sub_768348(&v84, a2, v86, v87, a5, a6, a7, &v88, a9, *(_DWORD *)(v12[2] + 8));
LABEL_62:
v16 = v85;
v15 = v35;
v86 = v84;
v87 = (int)v85;
v17 = v84;
goto LABEL_37;
default:
LABEL_56:
v17 = v86;
v88 |= 4u;
LABEL_57:
v15 = v35;
break;
}
goto LABEL_37;
}
v33 = v86;
v34 = v11[v15];
v17 = v86;
if ( !v86 )
goto LABEL_44;
v16 = (const char *)(v87 + 1);
if ( v87 != -1 )
{
if ( v34 != v87 )
goto LABEL_36;
LABEL_52:
v40 = v33[2];
if ( v40 >= v33[3] )
{
(*(void (__fastcall **)(_DWORD *, const char *))(*v33 + 40))(v33, v16);
v33 = v86;
}
else
{
v33[2] = v40 + 4;
}
v17 = v33;
v87 = -1;
goto LABEL_37;
}
v38 = (int *)v86[2];
if ( (unsigned int)v38 >= v86[3] )
v39 = (*(int (**)(void))(*v86 + 36))();
else
v39 = *v38;
if ( v39 == -1 )
{
v86 = nullptr;
LABEL_44:
v17 = nullptr;
if ( v34 != -1 )
goto LABEL_36;
goto LABEL_37;
}
v87 = v39;
if ( v34 != v39 )
{
v17 = v86;
LABEL_36:
v88 |= 4u;
goto LABEL_37;
}
v33 = v86;
v17 = v86;
if ( v86 )
goto LABEL_52;
LABEL_37:
++v15;
}
v87 = v27;
LABEL_4:
v19 = a5;
v20 = 0;
if ( !a5 )
goto LABEL_7;
if ( a6 != -1 )
goto LABEL_6;
LABEL_22:
v28 = (int *)v19[2];
if ( (unsigned int)v28 >= v19[3] )
v29 = (*(int (__fastcall **)(_DWORD *, const char *))(*v19 + 36))(v19, v16);
else
v29 = *v28;
v30 = (_DWORD *)(v29 + 1);
if ( v29 == -1 )
v30 = nullptr;
else
a6 = v29;
if ( v29 == -1 )
{
a5 = v30;
v31 = 1;
}
else
{
v31 = 0;
}
if ( v20 != v31 )
goto LABEL_7;
LABEL_31:
v21 = v88;
LABEL_10:
v23 = v15 == v18;
if ( v15 == v18 )
v23 = v21 == 0;
if ( !v23 )
*a8 |= 4u;
v24 = v87;
*a1 = v86;
a1[1] = v24;
return a1;
}