//
// jpeg_write_coefficients from 0x674030 to 0x6741b2 (386 bytes)
//
// 0 xrefs:
//
// 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 jpeg_write_coefficients(_DWORD *a1, int a2)
{
_DWORD *v4; // r5
char *v5; // r6
int v6; // r3
int v7; // r0
unsigned int v8; // r2
int v9; // r7
unsigned int v10; // r1
int v11; // lr
int32x4_t v12; // q9
int32x4_t v13; // q8
int32x4_t *v14; // r3
int32x4_t v15; // q10
int32x4_t v16; // q8
int32x4_t v17; // q11
int32x4_t v18; // q9
unsigned int v19; // r3
int v20; // r0
unsigned int v21; // r1
int result; // r0
if ( a1[5] != 100 )
{
*(_DWORD *)(*a1 + 20) = 21;
*(_DWORD *)(*a1 + 24) = a1[5];
(*(void (__fastcall **)(_DWORD *))*a1)(a1);
}
jpeg_suppress_tables(a1, 0);
(*(void (__fastcall **)(_DWORD *))(*a1 + 16))(a1);
(*(void (__fastcall **)(_DWORD *))(a1[6] + 8))(a1);
jinit_c_master_control(a1, 1);
if ( a1[53] )
jinit_arith_encoder((int)a1);
else
jinit_huff_encoder((int)a1);
v4 = (_DWORD *)(*(int (__fastcall **)(_DWORD *, int, int))a1[1])(a1, 1, 68);
a1[101] = v4;
*v4 = sub_673FDC;
v4[6] = a2;
v4[1] = sub_6739E0;
v5 = (char *)(*(int (__fastcall **)(_DWORD *, int, int))(a1[1] + 4))(a1, 1, 1280);
memset(v5, 0, 0x500u);
v6 = ((int)((_DWORD)(v4 + 7) << 29) >> 31) & 3;
if ( v6 )
{
v4[7] = v5;
if ( v6 == 1 )
{
v7 = 9;
v8 = 1;
}
else
{
v4[8] = v5 + 128;
if ( v6 == 3 )
{
v7 = 7;
v4[9] = v5 + 256;
v8 = 3;
}
else
{
v7 = 8;
v8 = 2;
}
}
v9 = 10 - v6;
v10 = ((unsigned int)(6 - v6) >> 2) + 1;
v11 = 4 * v10;
}
else
{
v9 = 10;
v11 = 8;
v7 = 10;
v10 = 2;
v8 = 0;
}
v12 = vdupq_n_s32(v8);
v13.n128_u64[0] = 0x100000000LL;
v13.n128_u64[1] = 0x300000002LL;
v14 = (int32x4_t *)&v4[v6 + 7];
v15 = vdupq_n_s32((unsigned int)v5);
v16 = vshlq_n_s32(vaddq_s32(v12, v13), 7u);
v17.n128_u64[0] = 0x500000004LL;
v17.n128_u64[1] = 0x700000006LL;
v18 = vaddq_s32(v12, v17);
*v14 = vaddq_s32(v15, v16);
if ( v10 == 2 )
v14[1] = vaddq_s32(v15, vshlq_n_s32(v18, 7u));
v19 = v8 + v11;
v20 = v7 - v11;
if ( v9 != v11 )
{
v21 = v19 << 7;
v4[v19 + 7] = &v5[128 * v19];
if ( v20 != 1 )
{
v4[v19 + 8] = &v5[v21 + 128];
if ( v20 != 2 )
v4[v19 + 9] = &v5[v21 + 256];
}
}
jinit_marker_writer((int)a1);
(*(void (__fastcall **)(_DWORD *))(a1[1] + 24))(a1);
result = (*(int (__fastcall **)(_DWORD *))a1[102])(a1);
a1[66] = 0;
a1[5] = 103;
return result;
}