// // ConvertUTF16toUTF8 from 0xb1c20c to 0xb1c3e8 (476 bytes) // // 2 xrefs: // > llvm::convertUTF16ToUTF8String @ 0xb1d8f0 // > @ 0x9c390 // // 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 // __int64 __fastcall ConvertUTF16toUTF8( unsigned __int64 *a1, unsigned __int64 a2, __int64 *a3, unsigned __int64 a4, int a5) { unsigned __int16 *v5; // x8 __int64 v6; // x7 int v7; // w6 unsigned __int16 *v8; // x9 unsigned int v9; // w5 __int64 v10; // x6 char v11; // w8 int v12; // w11 __int64 v13; // x7 __int64 v14; // x12 char v15; // w10 bool v16; // cc char v17; // w9 __int64 v19; // x7 v5 = (unsigned __int16 *)*a1; v6 = *a3; if ( *a1 >= a2 ) { LABEL_18: *a1 = (unsigned __int64)v5; *a3 = v6; return 0; } while ( 1 ) { v9 = *v5; v8 = v5 + 1; if ( v9 - 55296 <= 0x3FF ) break; if ( !a5 && v9 - 56320 <= 0x3FF ) { LABEL_20: *a1 = (unsigned __int64)v5; *a3 = v6; return 3; } if ( v9 > 0x7F ) { if ( v9 > 0x7FF ) goto LABEL_21; v14 = v6 + 2; if ( a4 < v6 + 2 ) { v10 = v6 + 2; v19 = -2; goto LABEL_25; } ++v5; v13 = 1; v12 = 2; LABEL_10: v16 = a2 > (unsigned __int64)v8; v17 = *((_BYTE *)&unk_F1C6E0 + v12); v6 = v14 - 1 + v13; *(_BYTE *)(v14 - 1) = v9 & 0x3F | 0x80; *(_BYTE *)(v14 - 2) = (v9 >> 6) | v17; if ( !v16 ) goto LABEL_18; } else { v10 = v6 + 1; if ( a4 < v6 + 1 ) { v19 = -1; goto LABEL_25; } ++v5; ++v6; *(_BYTE *)(v10 - 1) = v9; if ( a2 <= (unsigned __int64)v8 ) goto LABEL_18; } } if ( a2 <= (unsigned __int64)v8 ) { *a1 = (unsigned __int64)v5; *a3 = v6; return 1; } v7 = v5[1]; if ( (unsigned int)(v7 - 56320) > 0x3FF ) { if ( !a5 ) goto LABEL_20; } else { v8 = v5 + 2; v9 = v7 + 9216 + ((v9 - 55296) << 10); } if ( v9 <= 0xFFFF ) { LABEL_21: v10 = v6 + 3; if ( a4 < v6 + 3 ) { v19 = -3; goto LABEL_25; } v5 = v8; v13 = 2; v12 = 3; goto LABEL_9; } v10 = v6 + 4; if ( a4 >= v6 + 4 ) { v10 = v6 + 3; v11 = v9 & 0x3F | 0x80; v9 >>= 6; *(_BYTE *)(v6 + 3) = v11; v12 = 4; v5 = v8; v13 = 3; LABEL_9: v14 = v10 - 1; v15 = v9 & 0x3F | 0x80; v9 >>= 6; *(_BYTE *)(v10 - 1) = v15; goto LABEL_10; } v19 = -4; LABEL_25: *a1 = (unsigned __int64)v5; *a3 = v10 + v19; return 2; }