//
// ASYNC_start_job from 0x7cb028 to 0x7cb444 (1052 bytes)
//
// 6 xrefs:
// > SSL_read @ 0x796f6c
// > SSL_peek @ 0x797148
// > SSL_write @ 0x797310
// > SSL_shutdown @ 0x7974f0
// > SSL_do_handshake @ 0x799360
// > ??> @ 0x5bccc
//
// 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 ASYNC_start_job(_DWORD *a1, int a2, _DWORD *a3, int a4, void *a5, size_t a6)
{
int ctx; // r6
_DWORD *v11; // r5
int v12; // r4
int v13; // r8
int v14; // r4
int *v15; // r9
int v16; // r0
_DWORD *v18; // r9
_DWORD *local; // r9
int v20; // r0
int v21; // r5
int v22; // r0
int v23; // r3
int v24; // r3
int v25; // r4
int *v26; // r8
int v27; // r0
int v28; // r0
unsigned int v29; // r3
int v30; // r0
int v31; // r5
int v32; // r0
int v33; // r4
_DWORD *v34; // r7
ctx = async_get_ctx();
if ( !ctx )
{
v28 = CRYPTO_malloc(12, "crypto/async/async.c", 39);
ctx = v28;
if ( v28 )
{
*(_DWORD *)(v28 + 4) = 0;
*(_DWORD *)(v28 + 8) = 0;
if ( CRYPTO_THREAD_set_local(&unk_AD2DE0, v28) )
goto LABEL_2;
}
else
{
ERR_put_error(51, 100, 65, "crypto/async/async.c", 41);
}
CRYPTO_free(ctx, "crypto/async/async.c", 53);
return 0;
}
LABEL_2:
v11 = (_DWORD *)*a1;
if ( !*a1 )
{
v11 = *(_DWORD **)(ctx + 4);
if ( v11 )
goto LABEL_5;
local = (_DWORD *)CRYPTO_THREAD_get_local(&unk_AD2DE4);
if ( !local )
{
if ( !ASYNC_init_thread(0, 0) )
goto LABEL_29;
local = (_DWORD *)CRYPTO_THREAD_get_local(&unk_AD2DE4);
}
v20 = OPENSSL_sk_pop(*local);
v21 = v20;
if ( v20 )
{
*(_DWORD *)(ctx + 4) = v20;
if ( a5 )
{
v22 = CRYPTO_malloc(a6, "crypto/async/async.c", 227);
v23 = *(_DWORD *)(ctx + 4);
*(_DWORD *)(v21 + 8) = v22;
if ( !*(_DWORD *)(v23 + 8) )
{
ERR_put_error(51, 105, 65, "crypto/async/async.c", 229);
v33 = *(_DWORD *)(ctx + 4);
v34 = (_DWORD *)CRYPTO_THREAD_get_local(&unk_AD2DE4);
CRYPTO_free(*(_DWORD *)(v33 + 8), "crypto/async/async.c", 141);
*(_DWORD *)(v33 + 8) = 0;
OPENSSL_sk_push(*v34, v33);
v14 = 0;
*(_DWORD *)(ctx + 4) = 0;
return v14;
}
memcpy(*(void **)(v23 + 8), a5, a6);
v24 = *(_DWORD *)(ctx + 4);
}
else
{
v24 = v20;
*(_DWORD *)(v20 + 8) = 0;
}
*(_DWORD *)(v24 + 4) = a4;
*(_DWORD *)(v24 + 20) = a2;
ERR_put_error(51, 105, 102, "crypto/async/async.c", 243);
goto LABEL_20;
}
v29 = local[2];
if ( !v29 || v29 > local[1] )
{
v30 = CRYPTO_zalloc(24, "crypto/async/async.c", 84);
v31 = v30;
if ( v30 )
{
v32 = *(_DWORD *)(v30 + 8);
*(_DWORD *)(v31 + 16) = 0;
CRYPTO_free(v32, "crypto/async/async.c", 98);
CRYPTO_free(v31, "crypto/async/async.c", 100);
}
else
{
ERR_put_error(51, 102, 65, "crypto/async/async.c", 86);
}
}
LABEL_29:
v14 = 1;
*(_DWORD *)(ctx + 4) = 0;
return v14;
}
*(_DWORD *)(ctx + 4) = v11;
LABEL_5:
v12 = v11[4];
if ( v12 == 3 )
{
*a3 = v11[3];
v11[5] = 0;
v18 = (_DWORD *)CRYPTO_THREAD_get_local(&unk_AD2DE4);
CRYPTO_free(v11[2], "crypto/async/async.c", 141);
v11[2] = 0;
OPENSSL_sk_push(*v18, v11);
*(_DWORD *)(ctx + 4) = 0;
*a1 = 0;
return 3;
}
if ( v12 == 1 )
{
*a1 = v11;
*(_DWORD *)(*(_DWORD *)(ctx + 4) + 16) = 2;
*(_DWORD *)(ctx + 4) = 0;
return 2;
}
if ( v12 != 2 )
{
ERR_put_error(51, 105, 68, "crypto/async/async.c", 214);
v13 = *(_DWORD *)(ctx + 4);
v14 = 0;
v15 = (int *)CRYPTO_THREAD_get_local(&unk_AD2DE4);
CRYPTO_free(*(_DWORD *)(v13 + 8), "crypto/async/async.c", 141);
v16 = *v15;
*(_DWORD *)(v13 + 8) = 0;
OPENSSL_sk_push(v16, v13);
*(_DWORD *)(ctx + 4) = 0;
*a1 = 0;
return v14;
}
*(_DWORD *)(ctx + 4) = *a1;
ERR_put_error(51, 105, 102, "crypto/async/async.c", 207);
LABEL_20:
v25 = *(_DWORD *)(ctx + 4);
v26 = (int *)CRYPTO_THREAD_get_local(&unk_AD2DE4);
CRYPTO_free(*(_DWORD *)(v25 + 8), "crypto/async/async.c", 141);
v27 = *v26;
*(_DWORD *)(v25 + 8) = 0;
OPENSSL_sk_push(v27, v25);
*(_DWORD *)(ctx + 4) = 0;
*a1 = 0;
return 0;
}