// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdi, %rbx
movl 0x4c(%rdi), %r13d
movl 0x50(%rdi), %ebp
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 0x6ab6
leaq 0x18(%rbx), %r14
cmpl $0x22, 0x18(%rbx)
jne 0x7586
movq 0x10(%r14), %rax
movq %rax, 0x40(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x30(%rbx)
leaq 0x10(%rsp), %r15
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x97fb
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x10(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x7561
jmp 0x7598
leaq 0x45ae(%rip), %rdx      # 0xbb3b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x64ec
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x21, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0xff, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0xff, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movslq 0x20(%rcx), %rcx
addq $-0x2, %rcx
movq %rcx, 0x8(%rsp)
incl 0x221c(%rax)
movl %ebp, 0x4(%rsp)
movl (%r14), %eax
cmpl $0x23, %eax
je 0x762d
cmpl $0x36, %eax
je 0x7619
movq %rbx, %rdi
callq 0x5eca
jmp 0x7602
leaq 0x453d(%rip), %rdx      # 0xbb5d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x64ec
jmp 0x7665
movq 0x10(%r14), %rax
movq %rax, 0x40(%rbx)
movups (%r14), %xmm0
movups %xmm0, 0x30(%rbx)
leaq 0x10(%rsp), %r15
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x97fb
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x10(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x7642
movq 0x8(%rbx), %rax
movl 0x221c(%rax), %esi
movq %rbx, %rdi
callq 0x69c6
movq 0x8(%rbx), %rax
decl 0x221c(%rax)
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x1f, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movl 0x20(%rax), %ebp
subl %r12d, %ebp
cmpl $0xfffe, %ebp           # imm = 0xFFFE
jl 0x76be
leaq 0x4243(%rip), %rdx      # 0xb8f6
movq %rbx, %rdi
movq %r14, %rsi
callq 0x64ec
addl $0x2, %ebp
movl %ebp, %esi
shrl $0x8, %esi
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0xff, %r15d
andl %r15d, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
andl %r15d, %ebp
movl %ebp, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %r15
movl 0x20(%r15), %ecx
movq 0x8(%rsp), %rbp
subl %ebp, %ecx
cmpl $0x10002, %ecx          # imm = 0x10002
jl 0x772f
leaq 0x425b(%rip), %rdx      # 0xb979
movq %rbx, %rdi
movq %r14, %rsi
movl %ecx, %r14d
callq 0x64ec
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
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x2, %esi
callq 0x4d19
movl %r13d, 0x4c(%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x50(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq