Reverse Engineering challenge #59.

Tags: X86 ARM MIPS ARM64 ASM L1 .

What does this code do?

Optimizing MSVC 2010


_a$ = 8
_f	PROC
	mov	ecx, DWORD PTR _a$[esp-4]
	lea	eax, DWORD PTR [ecx*8]
	sub	eax, ecx
	ret	0
_f	ENDP

Non-Optimizing Keil 6 (ARM Mode)


f PROC
        RSB      r0,r0,r0,LSL #3
        BX       lr
        ENDP

Non-Optimizing Keil 6 (Thumb Mode)


f PROC
        LSLS     r1,r0,#3
        SUBS     r0,r1,r0
        BX       lr
        ENDP

Optimizing GCC 4.9 (ARM64)


f:
	lsl	w1, w0, 3
	sub	w0, w1, w0
	ret

Optimizing GCC 4.4.5 (MIPS) (IDA)


f:
                sll     $v0, $a0, 3
                jr      $ra
                subu    $v0, $a0

More challenges: challenges.re; about solutions: challenges.re/#Solutions.