// File: /workspace/github_c_makefile_star2_O3/mahrr[P]raven/src/compiler.c
// Function: while_
static void while_(Parser *parser) {
    // While Control Flow
    //
    // Condition       <----------.
    // OP_JMP_POP_FALSE   -----.  |
    //                         |  |
    // [continue]              |  |
    // OP_JMP_BACK        --------|
    //                         |  |
    // Loop Body               |  |
    // OP_JMP_BACK        ---------
    //                         |
    // ....            <--------

    Debug_Log(parser);

    // Register the surrounding loop state.
    int previous_inner_loop_start = parser->inner_loop_start;
    int previous_inner_loop_depth = parser->inner_loop_depth;

    int loop_start = parser_chunk(parser)->count;             // <-----.
                                                              //       |
    // Push the current loop state                            //       |
    parser->inner_loop_start = loop_start;                    //       |
    parser->inner_loop_depth = parser->context->scope_depth;  //       |
                                                              //       |
    expression(parser); // Condition                          //       |
                                                              //       |
    consume(parser, TOKEN_DO, "expect 'do' after while condition"); // |
                                                              //       |
    int exit_jump = emit_jump(parser, OP_JMP_POP_FALSE);      // ---.  |
                                                              //    |  |
    loop_block(parser);                                       //    |  |
                                                              //    |  |
    emit_loop(parser, loop_start);                            // -------
                                                              //    |
    patch_jump(parser, exit_jump);                            // <---

    // The resulting expression of a loop is always nil.
    emit_byte(parser, OP_PUSH_NIL);

    // Pop the current loop state.
    parser->inner_loop_start = previous_inner_loop_start;
    parser->inner_loop_depth = previous_inner_loop_depth;

    Debug_Exit(parser);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movsd 0x4c(%rdi), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rcx
movl 0x20(%rcx), %r12d
movl %r12d, 0x4c(%rdi)
movl 0x221c(%rax), %eax
movl %eax, 0x50(%rdi)
movl $0x1, %esi
callq 0x679e
leaq 0x18(%rbx), %r14
cmpl $0x22, 0x18(%rbx)
jne 0x725a
movq 0x10(%r14), %rax
movq %rax, 0x40(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x30(%rbx)
leaq 0x8(%rsp), %r15
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x941f
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x7235
jmp 0x726c
leaq 0x491a(%rip), %rdx      # 0xbb7b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61ef
movq 0x8(%rbx), %rax
movl 0x44(%rbx), %edx
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl $0x21, %esi
callq 0x4af1
movq 0x8(%rbx), %rax
movl 0x44(%rbx), %edx
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl $0xff, %esi
callq 0x4af1
movq 0x8(%rbx), %rax
movl 0x44(%rbx), %edx
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl $0xff, %esi
callq 0x4af1
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movslq 0x20(%rcx), %r13
addq $-0x2, %r13
incl 0x221c(%rax)
movl (%r14), %eax
cmpl $0x23, %eax
je 0x72f8
cmpl $0x36, %eax
je 0x72e4
movq %rbx, %rdi
callq 0x5bb5
jmp 0x72cd
leaq 0x48b2(%rip), %rdx      # 0xbb9d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61ef
jmp 0x7330
movq 0x10(%r14), %rax
movq %rax, 0x40(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x30(%rbx)
leaq 0x8(%rsp), %r15
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x941f
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x730d
movq 0x8(%rbx), %rax
movl 0x221c(%rax), %esi
movq %rbx, %rdi
callq 0x66bb
movq 0x8(%rbx), %rax
decl 0x221c(%rax)
movl 0x44(%rbx), %edx
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl $0x1f, %esi
callq 0x4af1
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
movl 0x20(%rdi), %ebp
subl %r12d, %ebp
cmpl $0xfffe, %ebp           # imm = 0xFFFE
jl 0x7391
leaq 0x45b8(%rip), %rdx      # 0xb936
movq %rbx, %rdi
movq %r14, %rsi
callq 0x61ef
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addl $0x2, %ebp
movl %ebp, %esi
shrl $0x8, %esi
movl 0x44(%rbx), %edx
addq $0x20, %rdi
movl $0xff, %r15d
andl %r15d, %esi
callq 0x4af1
movq 0x8(%rbx), %rax
movl 0x44(%rbx), %edx
movq 0x8(%rax), %rdi
addq $0x20, %rdi
andl %r15d, %ebp
movl %ebp, %esi
callq 0x4af1
movq 0x8(%rbx), %rax
movq 0x8(%rax), %r15
movl 0x20(%r15), %ecx
movq %r13, %rbp
subl %ebp, %ecx
cmpl $0x10002, %ecx          # imm = 0x10002
jl 0x73f8
leaq 0x45d2(%rip), %rdx      # 0xb9b9
movq %rbx, %rdi
movq %r14, %rsi
movl %ecx, %r14d
callq 0x61ef
movl %r14d, %ecx
addl $-0x2, %ecx
movq 0x28(%r15), %rax
movb %ch, (%rax,%rbp)
movq 0x28(%r15), %rax
movb %cl, 0x1(%rax,%rbp)
movq 0x8(%rbx), %rax
movl 0x44(%rbx), %edx
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl $0x2, %esi
callq 0x4af1
movaps 0x20(%rsp), %xmm0
movlps %xmm0, 0x4c(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq