I have this small subroutine (from Hopper, but IDA is similar):
sub_stringbegin:
000127b8 push {r11, lr}
000127bc add r11, sp, #0x4
000127c0 sub sp, sp, #0x8
000127c4 str r0, [r11, #-0x8]
000127c8 ldr r0, [r11, #-0x8]
000127cc bl _ZNSs5beginEv@PLT
000127d0 mov r3, r0
000127d4 mov r0, r3
000127d8 sub sp, r11, #0x4
000127dc pop {r11, pc}
; endp
The parameter is passed to this in r0.
Why is this stored into the stack frame then immediately read out? It seems wasteful.
I understand that r0-r3 aren't preserved in the ARM calling convention, but in that instance it would be sufficient to either just store it in the stack frame or pop it onto the stack.
Similarly, moving r0 into r3 and back again seems wasteful after the branch.
This is a ELF executable from a Busybox system.