//
// sub_612070 from 0x612070 to 0x612542 (1234 bytes)
//
// 2 xrefs:
// > sub_612598 @ 0x6125be
// > sub_6154B8 @ 0x61636c
//
// 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
//
int __fastcall sub_612070(int a1, void ***a2, int a3, const char *a4, double *a5)
{
int v6; // r10
_DWORD *v7; // r11
const char *v8; // r3
int v9; // r5
int v10; // r8
int v11; // r3
const char *v12; // r3
int v13; // r7
int v14; // r8
void *v15; // r10
int v16; // r11
_DWORD *v17; // r6
int v18; // r0
int v19; // r6
void **v20; // r4
void **v22; // r5
int v23; // r3
const char *v24; // r6
size_t v25; // r3
int v26; // r0
bool v27; // r3
int v28; // r3
int v29; // r3
char *v30; // r1
__int64 v31; // r0
const char *v32; // r6
__int64 v33; // r0
int v34; // r3
FILE *v35; // r0
_DWORD *v36; // r3
int *v37; // r10
char *v38; // [sp+1Ch] [bp-240h]
char *v39; // [sp+30h] [bp-22Ch]
void **v42; // [sp+44h] [bp-218h]
void **v43; // [sp+4Ch] [bp-210h] BYREF
double v44; // [sp+50h] [bp-20Ch] BYREF
_DWORD v45[129]; // [sp+58h] [bp-204h] BYREF
*a2 = nullptr;
v6 = a3;
v43 = nullptr;
v44 = 0.0;
if ( !a3 )
return 0;
v7 = v45;
if ( sub_63DF80(a1, v45, 2) )
return 27;
v39 = (char *)sub_626FC4("------------------------%08x%08x", v45[0], v45[1]);
if ( !v39 )
return 27;
v8 = a4;
if ( !a4 )
v8 = "Content-Type: multipart/form-data";
v9 = sub_611760(&v43, nullptr, (int)"%s; boundary=%s\r\n", v8, v39);
if ( v9 )
{
off_ABAEB0(v39);
return v9;
}
v38 = nullptr;
v42 = v43;
LABEL_8:
if ( *(_QWORD *)&v44 )
{
v10 = sub_611760(&v43, (int *)&v44, (int)&word_9B1DDC, HIDWORD(v44) | LODWORD(v44));
if ( v10 )
goto LABEL_83;
}
v10 = sub_611760(&v43, (int *)&v44, (int)"--%s\r\n", v39);
if ( v10 )
goto LABEL_83;
v10 = sub_611760(&v43, (int *)&v44, (int)"Content-Disposition: form-data; name=\"");
if ( v10 )
goto LABEL_83;
if ( *(int *)(v6 + 8) >> 31 < 0 || v44 < 0.0 )
{
LABEL_53:
v19 = 43;
goto LABEL_31;
}
v10 = sub_611638(&v43, 1u, *(const char **)(v6 + 4), SHIDWORD(v44), *(int *)(v6 + 8), &v44);
if ( v10 || (v10 = sub_611760(&v43, (int *)&v44, (int)"\"")) != 0 )
{
LABEL_83:
v19 = v10;
goto LABEL_31;
}
v11 = *(_DWORD *)(v6 + 36);
if ( !v11 )
goto LABEL_21;
off_ABAEB0(v38);
if ( !sub_63DF80(a1, v7, 2) )
{
v12 = (const char *)sub_626FC4("------------------------%08x%08x", *v7, v7[1]);
v38 = (char *)v12;
if ( !v12 )
{
v19 = 27;
goto LABEL_31;
}
v10 = sub_611760(&v43, (int *)&v44, (int)"\r\nContent-Type: multipart/mixed; boundary=%s\r\n", v12);
if ( !v10 )
{
v11 = *(_DWORD *)(v6 + 36);
LABEL_21:
v13 = v6;
v14 = v6;
v15 = v7;
if ( v11 )
{
LABEL_22:
v16 = sub_611760(&v43, (int *)&v44, (int)"\r\n--%s\r\nContent-Disposition: attachment", v38);
if ( !v16 )
{
v16 = sub_6117C8(*(const char **)(v13 + 12), *(char **)(v13 + 44), &v43, (int *)&v44);
if ( !v16 )
goto LABEL_24;
}
LABEL_52:
v19 = v16;
goto LABEL_31;
}
while ( 1 )
{
v29 = *(_DWORD *)(v14 + 40);
if ( (v29 & 0x51) != 0 )
{
v30 = *(char **)(v14 + 44);
if ( v30 || (v29 & 1) != 0 )
{
v16 = sub_6117C8(*(const char **)(v14 + 12), v30, &v43, (int *)&v44);
if ( v16 )
goto LABEL_52;
}
}
LABEL_24:
if ( *(_DWORD *)(v13 + 28) )
{
v16 = sub_611760(&v43, (int *)&v44, (int)"\r\nContent-Type: %s");
if ( v16 )
goto LABEL_52;
}
v17 = *(_DWORD **)(v13 + 32);
if ( v17 )
{
while ( 1 )
{
v18 = sub_611760(&v43, (int *)&v44, (int)"\r\n%s", *v17);
if ( v18 )
break;
v17 = (_DWORD *)v17[1];
if ( !v17 )
goto LABEL_36;
}
v19 = v18;
goto LABEL_31;
}
LABEL_36:
v16 = sub_611760(&v43, (int *)&v44, (int)"\r\n\r\n");
if ( v16 )
goto LABEL_52;
v23 = *(_DWORD *)(v14 + 40);
if ( v23 << 30 )
{
v24 = *(const char **)(v13 + 12);
if ( !strcmp("-", v24) )
goto LABEL_39;
v35 = fopen(v24, "rb");
if ( !v35 )
{
if ( a1 )
sub_6180F8(a1, "couldn't open file \"%s\"", *(const char **)(v13 + 12));
v19 = 26;
*a2 = nullptr;
goto LABEL_31;
}
if ( v35 == &_sF )
{
LABEL_39:
while ( 1 )
{
v25 = fread(v15, 1u, 0x200u, &_sF);
if ( !v25 )
break;
if ( v44 < 0.0 )
{
v27 = 0;
v16 = 43;
goto LABEL_44;
}
v26 = sub_611638(&v43, 2u, (const char *)v15, 0, v25, &v44);
if ( v26 )
{
v16 = v26;
v27 = 0;
goto LABEL_44;
}
}
v27 = 1;
}
else
{
fclose(v35);
if ( v44 < 0.0 )
goto LABEL_53;
v16 = sub_611638(&v43, 4u, *(const char **)(v13 + 12), SHIDWORD(v44), 0, &v44);
v27 = v16 == 0;
}
}
else
{
LODWORD(v31) = v23 << 27;
if ( (v23 & 0x10) != 0 )
{
v34 = *(_DWORD *)(v14 + 24);
v32 = *(const char **)(v14 + 20);
goto LABEL_70;
}
HIDWORD(v31) = v23 << 25;
if ( (v23 & 0x40) == 0 )
{
v32 = *(const char **)(v14 + 12);
if ( (v23 & 0x80) != 0 )
{
v33 = *(_QWORD *)(v14 + 56);
goto LABEL_66;
}
v34 = *(_DWORD *)(v14 + 16);
LABEL_70:
v33 = v34;
LABEL_66:
if ( v33 < 0 || v44 < 0.0 )
goto LABEL_53;
v16 = sub_611638(&v43, 2u, v32, SHIDWORD(v44), v33, &v44);
v27 = v16 == 0;
goto LABEL_44;
}
if ( (v23 & 0x80) != 0 )
v31 = *(_QWORD *)(v14 + 56);
else
v23 = *(_DWORD *)(v14 + 16);
if ( (*(_DWORD *)(v14 + 40) & 0x80) == 0 )
v31 = v23;
if ( v31 < 0 || v44 < 0.0 )
goto LABEL_53;
v16 = sub_611638(&v43, 3u, *(const char **)(v14 + 48), SHIDWORD(v44), v31, &v44);
v27 = v16 == 0;
}
LABEL_44:
v13 = *(_DWORD *)(v13 + 36);
if ( v13 )
v28 = v27;
else
v28 = 0;
if ( !v28 )
{
v36 = v15;
v37 = (int *)v14;
v10 = v16;
v7 = v36;
if ( v10 )
goto LABEL_83;
if ( v37[9] )
{
v10 = sub_611760(&v43, (int *)&v44, (int)"\r\n--%s--", v38);
if ( v10 )
goto LABEL_83;
}
v6 = *v37;
if ( v6 )
goto LABEL_8;
v19 = sub_611760(&v43, (int *)&v44, (int)"\r\n--%s--\r\n", v39);
if ( !v19 )
{
*a5 = v44;
off_ABAEB0(v38);
off_ABAEB0(v39);
*a2 = v42;
return 0;
}
goto LABEL_31;
}
if ( *(_DWORD *)(v14 + 36) )
goto LABEL_22;
}
}
goto LABEL_83;
}
v38 = nullptr;
v19 = 27;
LABEL_31:
v20 = v42;
if ( v42 )
{
do
{
v22 = (void **)*v20;
if ( (unsigned int)v20[1] <= 2 )
off_ABAEB0(v20[2]);
off_ABAEB0(v20);
v20 = v22;
}
while ( v22 );
}
off_ABAEB0(v38);
off_ABAEB0(v39);
return v19;
}