# Puzzle 6
#
# NOTE: CA and CB are labels we added by hand to support this homework.
# The compiler created the .L1-.L6 and function1 labels.
#
# C structures used: TODO
#
# Possible order of labels (#1): TODO
# Possible order of labels (#2): TODO
# Possible order of labels (#3): TODO
#
# Registers and sizes for function1's parameters: TODO

function1:
    testq   %rdi, %rdi
    je      .L1
    movl    $1, %r9d
    jmp     .L3                       # Next: TODO
.L6:
    movl    %edx, (%rdi,%rcx,4)
    subl    $1, %eax
.L4:
    testl   %eax, %eax
    jle     .L5                       # Next: TODO
CA:
    movslq  %eax, %rcx
    movl    -4(%rdi,%rcx,4), %edx
    cmpl    %r8d, %edx
    jg      .L6                       # Next: TODO
.L5:
    cltq
    movl    %r8d, (%rdi,%rax,4)
    addl    $1, %r9d
.L3:
    cmpl    %esi, %r9d
    jge     .L1                       # Next: TODO
CB:
    movslq  %r9d, %rax
    movl    (%rdi,%rax,4), %r8d
    movl    %r9d, %eax
    jmp     .L4                       # Next: TODO
.L1:
    ret