Two ways out of one loop
A break hands a loop a second door out. This is a plain linear search, so the counted part still rides mtctr/bdnz to its normal finish, but there's an extra beq- tucked inside that bolts the instant it spots k. Notice both exits funnel into the same mr r3, r6, the one that hands back the index i.
li r6, 0 # index = 0
mtctr r4 # CTR = n
cmpwi r4, 0
ble- done # n <= 0: skip loop entirely
body:
lwz r0, 0(r3) # load current element
cmpw r5, r0 # test condition
beq- done # early exit
addi r3, r3, 4 # advance pointer
addi r6, r6, 1 # increment index
bdnz+ body # otherwise keep counting
done:
mr r3, r6 # return index
blr
So the tell is simple. A CTR-driven bdnz plus a stray conditional branch leaping out of the middle? That middle branch is the break. Miss k entirely and the loop just runs out the normal way, leaving i == n.
Your task
Write find, returning the index of the first element of a equal to k, or n if there is none.