// File: /workspace/github_c_makefile_star2_O1/mahrr[P]raven/src/compiler.c
// Function: string_interpolated
static void string_interpolated(Parser *parser) {
    Debug_Log(parser);

    Allocator *allocator = &parser->vm->allocator;
    RavString *begin = object_string(
        allocator,
        parser->previous.lexeme + 1, // +1 advances the double quote
        parser->previous.length - 3  // -3 for the delimiters count
    );
    emit_constant(parser, Obj_Value(begin));

    while (parser->previous.type != TOKEN_STRING_END) {
        expression(parser);
        emit_byte(parser, OP_CONCAT);

        bool string_part = consume_if(parser, TOKEN_STRING_PART);
        bool string_end = consume_if(parser, TOKEN_STRING_END);

        if (string_part || string_end) {
            const char *chars = parser->previous.lexeme + 2; // +2 advances '}}'
            int length = 0;

            // enclosed between '}}' and '{{'
            if (string_part) {
                length = parser->previous.length - 4;
            }
            // enclosed between '}}' and '"'
            else if (string_end) {
                length = parser->previous.length - 3;
            }

            if (length != 0) {
                RavString *part = object_string(allocator, chars, length);
                emit_constant(parser, Obj_Value(part));
                emit_byte(parser, OP_CONCAT);
            }
        } else {
            error_current(parser, "ill-formed interpolated string");
            break;
        }
    }

    Debug_Exit(parser);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movabsq $-0x4000000000000, %r14 # imm = 0xFFFC000000000000
movq 0x10(%rdi), %rdi
movq 0x38(%rbx), %rsi
incq %rsi
movl 0x40(%rbx), %edx
addl $-0x3, %edx
movq %rdi, 0x8(%rsp)
callq 0x52a0
orq %r14, %rax
movq 0x8(%rbx), %rcx
movq 0x8(%rcx), %rdi
addq $0x20, %rdi
movq %rax, %rsi
callq 0x4db9
cmpl $0x100, %eax            # imm = 0x100
jl 0x865e
leaq 0x3270(%rip), %rsi      # 0xb8ab
movq %rbx, %rdi
movl $0x100, %edx            # imm = 0x100
callq 0x6518
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movl $0x0, 0x848(%rax)
xorl %ebp, %ebp
jmp 0x8660
movl %eax, %ebp
leaq 0x30(%rbx), %rax
movq %rax, (%rsp)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x3, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movzbl %bpl, %esi
callq 0x4d19
leaq 0x18(%rbx), %r15
leaq 0x10(%rsp), %r12
movq (%rsp), %rax
cmpl $0x34, (%rax)
je 0x886a
movq %rbx, %rdi
movl $0x1, %esi
callq 0x6ab6
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x24, %esi
callq 0x4d19
movl 0x18(%rbx), %r13d
cmpl $0x33, %r13d
jne 0x8715
movq 0x10(%r15), %rax
movq (%rsp), %rcx
movq %rax, 0x10(%rcx)
movups (%r15), %xmm0
movups %xmm0, (%rcx)
movq (%rbx), %rsi
movq %r12, %rdi
callq 0x97fb
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r15)
movups 0x10(%rsp), %xmm0
movups %xmm0, (%r15)
cmpl $0x35, 0x18(%rbx)
je 0x86f2
movl (%r15), %r14d
cmpl $0x34, %r14d
jne 0x8754
movq 0x10(%r15), %rax
movq (%rsp), %rcx
movq %rax, 0x10(%rcx)
movups (%r15), %xmm0
movups %xmm0, (%rcx)
movq (%rbx), %rsi
movq %r12, %rdi
callq 0x97fb
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r15)
movups 0x10(%rsp), %xmm0
movups %xmm0, (%r15)
cmpl $0x35, 0x18(%rbx)
je 0x8731
cmpl $0x34, %r14d
sete %al
cmpl $0x33, %r13d
sete %bpl
orb %al, %bpl
cmpb $0x1, %bpl
jne 0x8800
cmpl $0x34, %r14d
setne %al
cmpl $0x33, %r13d
setne %cl
xorl %edx, %edx
testb %al, %cl
jne 0x8793
xorl %edx, %edx
cmpl $0x33, %r13d
sete %dl
xorl $-0x3, %edx
addl 0x40(%rbx), %edx
testl %edx, %edx
je 0x8861
movq 0x38(%rbx), %rsi
addq $0x2, %rsi
movq 0x8(%rsp), %rdi
callq 0x52a0
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
orq %rcx, %rax
movq 0x8(%rbx), %rcx
movq 0x8(%rcx), %rdi
addq $0x20, %rdi
movq %rax, %rsi
callq 0x4db9
cmpl $0x100, %eax            # imm = 0x100
jl 0x8814
movq %rbx, %rdi
leaq 0x30cc(%rip), %rsi      # 0xb8ab
movl $0x100, %edx            # imm = 0x100
callq 0x6518
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
movl $0x0, 0x848(%rax)
xorl %r13d, %r13d
jmp 0x8817
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x350d(%rip), %rdx      # 0xbd1a
callq 0x64ec
jmp 0x8861
movl %eax, %r13d
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x3, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movzbl %r13b, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x24, %esi
callq 0x4d19
testb %bpl, %bpl
jne 0x86a2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq