Skip to content

Instantly share code, notes, and snippets.

@dedmen
Created October 31, 2016 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dedmen/fbfd42c0ce0b1f1f800163141838e22e to your computer and use it in GitHub Desktop.
Save dedmen/fbfd42c0ce0b1f1f800163141838e22e to your computer and use it in GitHub Desktop.
Old:
void __usercall Clunk::process(Clunk *this@<rcx>, __int16 *samples@<rdx>, int channels@<r8d>, int sampleCount@<r9d>, __int128 _XMM0@<xmm0>, __int128 _XMM1@<xmm1>, __int128 _XMM2@<xmm2>, __int128 _XMM6@<xmm6>, __int128 _XMM7@<xmm7>, __int128 _XMM8@<xmm8>, __int128 _XMM9@<xmm9>, __int128 _XMM10@<xmm10>, dataType::Position3D *pos, float direction)
{
void **_RAX; // rax@1
__int64 _RBP; // rbp@1
dataType::Position3D *_RAX; // rax@1
__int128 _XMM0; // xmm0@1
__int128 _XMM0; // xmm0@1
int v35; // er13@1
const __int16 *v36; // rbx@2
__int64 v37; // rsi@2
unsigned __int64 v38; // r15@4
int v39; // er12@4
void *v40; // rsi@5
const bool v41; // r9@5
signed __int64 v42; // r10@6
std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *v43; // rax@8
__int64 v44; // r8@8
std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *v45; // rax@8
__int64 v46; // r11@8
std::_Container_base12 *v47; // r8@9
bool v48; // zf@11
unsigned int v49; // er12@17
void *v50; // rsi@17
const bool v51; // r9@17
unsigned int v52; // edx@17
unsigned int v53; // eax@17
const __int16 *v54; // rbx@18
__int64 v55; // r15@18
__int64 v56; // rbx@22
int v57; // er11@29
std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *v58; // rax@32
__int64 v59; // r8@32
std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *v60; // rax@32
__int64 v61; // r10@32
std::_Container_base12 *v62; // r8@33
char *_R11; // r11@42
float v69; // [sp+38h] [bp-100h]@0
clunk::v3<float> v70; // [sp+40h] [bp-F8h]@4
std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > result; // [sp+50h] [bp-E8h]@8
clunk::Buffer v72; // [sp+68h] [bp-D0h]@5
void *v73; // [sp+80h] [bp-B8h]@5
signed __int64 v74; // [sp+88h] [bp-B0h]@1
__int64 v75; // [sp+90h] [bp-A8h]@8
_BYTE v76[7]; // [sp+E9h] [bp-4Fh]@1
char v77; // [sp+100h] [bp-38h]@42
void *retaddr; // [sp+138h] [bp+0h]@1
int v79; // [sp+150h] [bp+18h]@1
unsigned int v80; // [sp+168h] [bp+30h]@17
_RAX = &retaddr;
v79 = channels;
_RBP = (__int64)v76;
v74 = -2i64;
__asm
{
vmovaps xmmword ptr [rax-48h], xmm6
vmovaps xmmword ptr [rax-58h], xmm7
vmovaps xmmword ptr [rax-68h], xmm8
vmovaps xmmword ptr [rax-78h], xmm9
vmovaps xmmword ptr [rax-88h], xmm10
}
_RAX = pos;
__asm
{
vmovss xmm10, dword ptr [rax+8]
vmovss xmm9, dword ptr [rax+4]
vmovss xmm8, dword ptr [rax]
vmovss dword ptr [rbp+6Fh], xmm8
vmovss dword ptr [rbp+77h], xmm9
vmovss dword ptr [rbp+57h], xmm10
vmovss xmm0, dword ptr [rbp+7Fh]
vmulss xmm6, xmm0, cs:__real@3c8efa35
vmovaps xmm0, xmm6 ; X
}
LODWORD(_XMM0) = cosf(*(float *)&_XMM0);
__asm
{
vmovaps xmm7, xmm0
vmovaps xmm0, xmm6 ; X
}
LODWORD(_XMM0) = sinf(*(float *)&_XMM0);
__asm
{
vmulss xmm2, xmm7, xmm8
vmulss xmm1, xmm0, xmm9
vsubss xmm6, xmm2, xmm1
vmulss xmm1, xmm0, xmm8
vmulss xmm0, xmm7, xmm9
vaddss xmm7, xmm1, xmm0
}
v35 = sampleCount * channels;
if ( sampleCount * channels > 0 )
{
v36 = samples;
v37 = (unsigned int)v35;
do
{
std::deque<short,std::allocator<short>>::push_back(&this->input_buffer, v36);
++v36;
--v37;
}
while ( v37 );
}
v38 = this->input_buffer._Mypair._Myval2._Mysize;
*(_QWORD *)&v70.x = (unsigned int)(channels << 10);
v39 = 0;
if ( v38 > *(_QWORD *)&v70 )
{
v72.ptr = 0i64;
v72.size = 0i64;
clunk::Buffer::set_size(&v72, 2 * (signed int)v38);
v40 = operator new[](saturated_mul(2ui64, this->input_buffer._Mypair._Myval2._Mysize));
v73 = v40;
if ( (signed int)v38 > 0 )
{
v42 = (signed __int64)&this->input_buffer;
do
{
if ( !*(_QWORD *)(v42 + 32) )
std::_Xout_of_range("invalid deque<T> subscript");
v43 = std::deque<short,std::allocator<short>>::begin((std::deque<short,std::allocator<short> > *)v42, &result);
v45 = std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short>>>::operator+(
v43,
(std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *)&v75,
v44);
if ( v45->_Myproxy )
v47 = v45->_Myproxy->_Mycont;
else
v47 = 0i64;
*((_WORD *)v40 + v46) = *((_WORD *)&(&v47[1]._Myproxy->_Mycont)[(v45->_Myoff >> 3) & (unsigned int)((char *)&v47[2]._Myproxy[-1]._Myfirstiter + 7)]->_Myproxy
+ (v45->_Myoff & 7));
v48 = (*(_QWORD *)(v42 + 32))-- == 1i64;
if ( v48 )
*(_QWORD *)(v42 + 24) = 0i64;
else
++*(_QWORD *)(v42 + 24);
}
while ( v46 + 1 < (signed int)v38 );
}
clunk::Buffer::set_data(&v72, v40, 2i64 * (signed int)v38, v41);
v49 = v38 - (_DWORD)v70.x;
v80 = v38 - (_DWORD)v70.x;
v50 = operator new[](saturated_mul(2ui64, (signed int)v38 - (signed int)v70.x));
memset(v50, 0, 2i64 * ((signed int)v38 - (signed int)v70.x));
result._Myproxy = 0i64;
result._Mynextiter = 0i64;
clunk::Buffer::set_size((clunk::Buffer *)&result, 2 * ((signed int)v38 - (signed int)v70.x));
clunk::Buffer::set_data((clunk::Buffer *)&result, v50, 2i64 * ((signed int)v38 - (signed int)v70.x), v51);
__asm
{
vmovss [rsp+138h+var_F8.x], xmm6
vmovss [rsp+138h+var_F8.y], xmm7
vmovss [rsp+138h+var_F8.z], xmm10
}
v53 = v79 * clunk::Hrtf::process(&this->hrft, v52, (clunk::Buffer *)&result, v79, &v72, v79, &v70, v69);
if ( (signed int)v53 < (signed int)v38 )
{
v54 = (const __int16 *)((char *)v73 + 2 * (signed int)v53);
v55 = (unsigned int)v38 - v53;
do
{
std::deque<short,std::allocator<short>>::push_back(&this->input_buffer, v54);
++v54;
--v55;
}
while ( v55 );
v49 = v80;
}
if ( (signed int)v49 > 0 )
{
v56 = v49;
do
{
std::deque<short,std::allocator<short>>::push_back(&this->output_buffer, (const __int16 *)v50);
v50 = (char *)v50 + 2;
--v56;
}
while ( v56 );
}
if ( (_QWORD)result._Myproxy )
free(result._Myproxy);
if ( (_QWORD)v72.ptr )
free(v72.ptr);
v39 = 0;
}
v57 = v39;
if ( v35 > 0 )
{
do
{
if ( this->output_buffer._Mypair._Myval2._Mysize )
{
if ( !this->output_buffer._Mypair._Myval2._Mysize )
std::_Xout_of_range("invalid deque<T> subscript");
v58 = std::deque<short,std::allocator<short>>::begin(
&this->output_buffer,
(std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *)&v75);
v60 = std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short>>>::operator+(
v58,
(std::_Deque_iterator<std::_Deque_val<std::_Deque_simple_types<short> > > *)&v72,
v59);
if ( v60->_Myproxy )
v62 = v60->_Myproxy->_Mycont;
else
v62 = 0i64;
*samples = *((_WORD *)&(&v62[1]._Myproxy->_Mycont)[(v60->_Myoff >> 3) & (unsigned int)((char *)&v62[2]._Myproxy[-1]._Myfirstiter
+ 7)]->_Myproxy
+ (v60->_Myoff & 7));
v48 = (*(_QWORD *)(v61 + 32))-- == 1i64;
if ( v48 )
*(_QWORD *)(v61 + 24) = 0i64;
else
++*(_QWORD *)(v61 + 24);
}
else
{
*samples = v39;
}
++v57;
++samples;
}
while ( v57 < v35 );
}
_R11 = &v77;
__asm
{
vmovaps xmm6, xmmword ptr [r11-10h]
vmovaps xmm7, xmmword ptr [r11-20h]
vmovaps xmm8, xmmword ptr [r11-30h]
vmovaps xmm9, xmmword ptr [r11-40h]
vmovaps xmm10, xmmword ptr [r11-50h]
}
}
New
void __usercall Clunk::process(Clunk *this@<rcx>, __int16 *samples@<rdx>, int channels@<r8d>, int sampleCount@<r9d>, __int128 _XMM0@<xmm0>, __int128 _XMM1@<xmm1>, __int128 _XMM2@<xmm2>, __int128 _XMM6@<xmm6>, __int128 _XMM7@<xmm7>, __int128 _XMM8@<xmm8>, __int128 _XMM9@<xmm9>, __int128 _XMM10@<xmm10>, dataType::Direction3D *pos, dataType::AngleRadians direction)
{
void **_R11; // r11@1
dataType::Direction3D *_RAX; // rax@1
__int128 _XMM0; // xmm0@1
__int128 _XMM0; // xmm0@1
void **v32; // r14@1
unsigned __int64 v33; // r13@1
signed __int64 v34; // r15@1
int v35; // ebx@1
signed __int64 v36; // rdi@2
void *v37; // r12@2
unsigned int v38; // edx@2
unsigned int v39; // eax@2
void *v40; // rcx@2
const void *v41; // rdx@2
void *v42; // rbx@2
size_t v43; // rdi@5
size_t v44; // r8@10
__int16 *v45; // rbx@12
const void *v46; // rdx@12
size_t v47; // rdi@15
char *_R11; // r11@16
std::forward_iterator_tag src_buf; // [sp+20h] [bp-F8h]@0
std::forward_iterator_tag src_bufa; // [sp+20h] [bp-F8h]@2
float v56; // [sp+38h] [bp-E0h]@0
clunk::v3<float> v57; // [sp+48h] [bp-D0h]@2
clunk::Buffer dst_buf; // [sp+58h] [bp-C0h]@2
clunk::Buffer v59; // [sp+68h] [bp-B0h]@2
char v60; // [sp+D8h] [bp-40h]@16
void *retaddr; // [sp+118h] [bp+0h]@1
signed __int64 v62; // [sp+128h] [bp+10h]@2
int dst_ch; // [sp+130h] [bp+18h]@1
_R11 = &retaddr;
dst_ch = channels;
__asm
{
vmovaps xmmword ptr [r11-58h], xmm6
vmovaps xmmword ptr [r11-68h], xmm7
vmovaps xmmword ptr [r11-78h], xmm8
vmovaps xmmword ptr [r11-88h], xmm9
vmovaps xmmword ptr [r11-98h], xmm10
}
_RAX = pos;
__asm
{
vmovss xmm10, dword ptr [rax+8]
vmovss xmm9, dword ptr [rax+4]
vmovss xmm8, dword ptr [rax]
vmovss dword ptr [r11+20h], xmm8
vmovss dword ptr [r11+28h], xmm9
vmovss dword ptr [r11+8], xmm10
vmovss xmm0, dword ptr [r11+30h]; X
}
LODWORD(_XMM0) = cosf(*(float *)&_XMM0);
__asm
{
vmovaps xmm7, xmm0
vmovss xmm0, [rsp+118h+arg_28]; X
}
LODWORD(_XMM0) = sinf(*(float *)&_XMM0);
__asm
{
vmulss xmm2, xmm8, xmm7
vmulss xmm1, xmm9, xmm0
vsubss xmm6, xmm2, xmm1
vmulss xmm1, xmm8, xmm0
vmulss xmm0, xmm9, xmm7
vaddss xmm7, xmm1, xmm0
}
v32 = (void **)&this->input_buffer._Mypair._Myval2._Myfirst;
v33 = sampleCount * channels;
v34 = v33;
std::vector<short,std::allocator<short>>::_Insert<short const *>(
&this->input_buffer,
(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<short> > >)this->input_buffer._Mypair._Myval2._Mylast,
samples,
&samples[v33],
src_buf);
v35 = channels << 10;
if ( this->input_buffer._Mypair._Myval2._Mylast - this->input_buffer._Mypair._Myval2._Myfirst > (unsigned __int64)(channels << 10) )
{
v36 = this->input_buffer._Mypair._Myval2._Mylast - this->input_buffer._Mypair._Myval2._Myfirst;
v59.ptr = 0i64;
v59.size = 0i64;
clunk::Buffer::set_size(&v59, 2 * (signed int)v36);
clunk::Buffer::set_data(&v59, *v32, 2i64 * (signed int)v36, 0);
LODWORD(v36) = v36 - v35;
v37 = operator new[](saturated_mul(2ui64, (signed int)v36));
v62 = 2i64 * (signed int)v36;
memset(v37, 0, 2i64 * (signed int)v36);
dst_buf.ptr = 0i64;
dst_buf.size = 0i64;
clunk::Buffer::set_size(&dst_buf, 2 * (signed int)v36);
clunk::Buffer::set_data(&dst_buf, v37, 2i64 * (signed int)v36, 1);
__asm
{
vmovss [rsp+118h+var_D0.x], xmm6
vmovss [rsp+118h+var_D0.y], xmm7
vmovss [rsp+118h+var_D0.z], xmm10
}
v39 = clunk::Hrtf::process(&this->hrft, v38, &dst_buf, dst_ch, &v59, dst_ch, &v57, v56);
v40 = *v32;
v41 = (char *)*v32 + 2 * (signed int)(dst_ch * v39);
v42 = *v32;
if ( v41 == (const void *)this->input_buffer._Mypair._Myval2._Mylast )
{
this->input_buffer._Mypair._Myval2._Mylast = (__int16 *)v40;
}
else if ( v42 != v41 )
{
v43 = (char *)this->input_buffer._Mypair._Myval2._Mylast - (char *)v41;
memmove(v40, v41, v43);
this->input_buffer._Mypair._Myval2._Mylast = (__int16 *)((char *)v42 + v43);
}
std::vector<short,std::allocator<short>>::_Insert<short const *>(
&this->output_buffer,
(std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<short> > >)this->output_buffer._Mypair._Myval2._Mylast,
(const __int16 *)v37,
(const __int16 *)((char *)v37 + v62),
src_bufa);
if ( (_QWORD)dst_buf.ptr )
free(dst_buf.ptr);
if ( (_QWORD)v59.ptr )
free(v59.ptr);
}
v44 = 2 * v33;
if ( this->output_buffer._Mypair._Myval2._Mylast - this->output_buffer._Mypair._Myval2._Myfirst >= v33 )
{
memmove(samples, this->output_buffer._Mypair._Myval2._Myfirst, v44);
v45 = this->output_buffer._Mypair._Myval2._Myfirst;
v46 = &v45[v34];
if ( &v45[v34] == this->output_buffer._Mypair._Myval2._Mylast )
{
this->output_buffer._Mypair._Myval2._Mylast = v45;
}
else if ( v45 != v46 )
{
v47 = (char *)this->output_buffer._Mypair._Myval2._Mylast - (char *)v46;
memmove(this->output_buffer._Mypair._Myval2._Myfirst, v46, v47);
this->output_buffer._Mypair._Myval2._Mylast = (__int16 *)((char *)v45 + v47);
}
}
else
{
memset(samples, 0, v44);
}
_R11 = &v60;
__asm
{
vmovaps xmm6, xmmword ptr [r11-18h]
vmovaps xmm7, xmmword ptr [r11-28h]
vmovaps xmm8, xmmword ptr [r11-38h]
vmovaps xmm9, xmmword ptr [r11-48h]
vmovaps xmm10, xmmword ptr [r11-58h]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment