// vim: set syntax=asm :

{{L}}non_linear:

{{L}}non_linear_loop_enter:
    sub     rdi,    40
{{L}}non_linear_loop:
    add     rdi,    40
    mov     rax,    [rdi]

    mov     r8, {{ jump_table | size }}
    cmp     rax, 0
    cmovl   rax, r8
    cmp     rax, {{ jump_table | size }}
    cmovg   rax, r8

{% if msvc %}
    lea     r8, [ offset {{L}}jmp_table ]
{% else %}
    lea     r8, [ rip + {{L}}jmp_table ]
{% endif %}
    movsxd  r9, dword ptr [ r8 + rax * 4 ]
    lea     r8, [ r8 + r9 ]
    jmp     r8

{{L}}jmp_table:
{% for j in jump_table %}
    {{long}}      {{L}}{{j}}-{{L}}jmp_table
{% endfor %}
    {{long}}      {{L}}unsupported-{{L}}jmp_table

{{L}}unsupported:
    mov     rax,    1
    jmp     {{L}}return


{{L}}done:
    mov     rax, 0
    jmp     {{L}}return

