// leaf.s -
// Subtract 1st, last elements of array
// Expects:
//      x0: long int *array
//      x1: long int length
// Returns:
//      x0: long int answer
.equ FrameSize, 16
    .text
    .global leaf
leaf:
    stp  x29, x30, [sp, -FrameSize] !   // set up frame
    mov  x29, sp                        // set fp

    ldr  x2, [x0]               // 1st array element
    sub  x1, x1, 1              // last index
    ldr  x3, [x0, x1, lsl #3]   // last array element
    sub  x0, x2, x3
done:
    mov  sp, x29                        // restore sp
    ldp  x29, x30, [sp], FrameSize      // tear down frame
    ret
#--------