Artöm
Ariana
Ariana
gcc automatically does xor
Artöm
uh no
I mean xor vs mov, not =0 vs ^=
Ariana
yes
Ariana
gcc does xor anyways
Artöm
Ariana
ik mov eax 0 is 5 bytes
cant rmb xor eax eax
Ariana
Artöm
afair 3
Ariana
oh its 2
Ariana
31c0
Ariana
thats nice to know
Ariana
no one memorises shellcodes actually
Ariana
But overtime if you do shellcoding for exploitation you’ll memorise some of them subconsciously
Ariana
anyways use var=0, basically all compilers would xor eax eax anyways
Ariana
try to avoid bitwise operations cuz it just makes the code more unreadable
Ariana
Unless theres a very specific purpose like fast inverse square root
Ariana
I said no one memorise them anyways.-.
Francisco
gcc does xor anyways
It does xor when optimization level is -O2 or higher. With -O1 it does the move
Ariana
(but overtime you’ll remember some common ones)
Ariana
Ariana
even for xmm
Mihail
Mihail
At least in GCC -O2 is minimum
Mihail
Weird but you should be using O2 anyways
Ariana
hmm thats weird
Ariana
anyways theres legit no reason tp not use O2
Anonymous
Francisco
Ariana
oh wait what
Ariana
It does for floats but not for ints
Ariana
my gcc is weird
Artöm
Mihail
For debugging there is Og
Artöm
Artöm
Ariana
i dont find debugging with assembly useful tbh, like it doesn’t tell you much unless your one line is like 50 operations
Ariana
tho i do occasionally miss -g and just debug in assembly from laziness
Francisco
Ariana
uh no?
Ariana
unless your code does nothing in O(n)
Ariana
Then might as well O(n^n) to O(1)
Ariana
im quite sure O(n) to O(1) isn’t possible
Mihail
Ariana
Eh do you consider them O(n)
Artöm
Clang transforms loop to n(n+1)/2
Ariana
Exactly
Ariana
The thing is O(1), just that it is implemented pretty poorly
Ariana
or by someone who doesn’t know Σn
Francisco
Eh do you consider them O(n)
No, the fact you program a summation with an O(n) algorithm and the compiler deduces the formula is quite amazing
Ariana
Isnt it like hardcoded?
Mihail
Ariana
oh
Mihail
It's pretty fucking smart tbh
Ariana
wait so if i sum like n^5 it can collapse it to like a sextic for me
Francisco
Ariana
that’s pretty impressive
Mihail
Because of the intermediate representation
Mihail
It's so verbose
Mihail
And things like this stand out
Francisco
https://kristerw.blogspot.com/2019/04/how-llvm-optimizes-geometric-sums.html
Francisco
The maths behind the compiler are quite impressive tbh
Ariana
insane
Ariana
automated solver for O(1) problems
Francisco
That's why sometimes you want no optimizations for debugging, because of this kind of stuff
Ariana
For me debugging i just add the -g and thats it
Mihail
Mihail
So might as well do that