c - Analyzing optimizations made in assembly code -



c - Analyzing optimizations made in assembly code -

i trying understand how assembly optimization performed on next c code:

void rgbtocmyk(int r, int g, int b, int ret[]) { int c = 255 - r; int m = 255 - g; int y = 255 - b; int k = (c < m) ? (c < y ? c : y) : (m < y ? m : y); c -= k; m -= k; y -= k; ret[0] = c; ret[1] = m; ret[2] = y; ret[3] = k;

this generates next assembly code (limited text portion), no optimization on left column , optimization level -o1 on right:

i looking guidance on how navigate through obscure code. new assembly, , i've been wracking brain trying understand differences. more compact code -o1 optimization, bulk of compactness beingness result of less movl statements.

note: homework. instructor has asked precise possible in comparing 2 versions.

c assembly

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -