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

    if (consume_if(parser, TOKEN_RIGHT_BRACE)) {
        emit_bytes(parser, OP_MAP_8, 0);
        Debug_Exit(parser);
        return;
    }

    size_t count = 0;
    do {
        consume(parser, TOKEN_IDENTIFIER, "expect a map key name");

        // key
        RavString *key = object_string(
            &parser->vm->allocator,
            parser->previous.lexeme,
            parser->previous.length
        );
        emit_constant(parser, Obj_Value(key));

        consume(parser, TOKEN_COLON, "expect ':' after map key");

        if (count == MAP_LIMIT) {
            error_limit(parser, "map literal elements", MAP_LIMIT);
            break;
        }

        // value
        expression(parser);

        count++;
    } while (consume_if(parser, TOKEN_COMMA));

    if (count > UINT8_MAX) {
        emit_byte(parser, OP_MAP_16);
        emit_bytes(parser, (count >> 8) & 0xff, count & 0xff);
    } else {
        emit_bytes(parser, OP_MAP_8, (uint8_t)count);
    }

    consume(parser, TOKEN_RIGHT_BRACE, "expect '}' after map elements");

    Debug_Exit(parser);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x18(%rdi), %r14
movl 0x18(%rdi), %ebp
cmpl $0x2b, %ebp
jne 0x7eb0
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 0x97fb
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x7e54
cmpl $0x2b, %ebp
jne 0x7eb0
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x28, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
xorl %esi, %esi
callq 0x4d19
jmp 0x812d
leaq 0x30(%rbx), %rax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0x8(%rsp), %r15
cmpl $0x2f, (%r14)
jne 0x7f00
movq 0x10(%r14), %rax
movq 0x20(%rsp), %rcx
movq %rax, 0x10(%rcx)
movups (%r14), %xmm0
movups %xmm0, (%rcx)
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x97fb
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x7edb
jmp 0x7f12
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x3d4a(%rip), %rdx      # 0xbc57
callq 0x64ec
movq 0x10(%rbx), %rdi
movq 0x38(%rbx), %rsi
movl 0x40(%rbx), %edx
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 0x7f75
movq %rbx, %rdi
leaq 0x3957(%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 0x7f78
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
cmpl $0x27, 0x18(%rbx)
jne 0x7fe8
movq 0x10(%r14), %rax
movq 0x20(%rsp), %rcx
movq %rax, 0x10(%rcx)
movups (%r14), %xmm0
movups %xmm0, (%rcx)
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x97fb
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x7fc3
jmp 0x7ffa
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x3c78(%rip), %rdx      # 0xbc6d
callq 0x64ec
movq %rbx, %rdi
cmpq $0x10000, %r12          # imm = 0x10000
jne 0x801f
leaq 0x3c79(%rip), %rsi      # 0xbc86
movl $0x10000, %edx          # imm = 0x10000
callq 0x6518
movl $0x10000, %r13d         # imm = 0x10000
jmp 0x802e
movl $0x1, %esi
callq 0x6ab6
leaq 0x1(%r12), %r13
cmpq $0x10000, %r12          # imm = 0x10000
je 0x8082
movl (%r14), %ebp
cmpl $0x25, %ebp
jne 0x8082
movq 0x10(%r14), %rax
movq 0x20(%rsp), %rcx
movq %rax, 0x10(%rcx)
movups (%r14), %xmm0
movups %xmm0, (%rcx)
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x97fb
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x8053
movq %r13, %r12
cmpl $0x25, %ebp
je 0x7ec1
movb $0x28, %al
cmpq $0x100, %r13            # imm = 0x100
jb 0x80ac
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movl $0x29, %esi
callq 0x4d19
movl %r13d, %eax
shrl $0x8, %eax
movq 0x8(%rbx), %rcx
movq 0x8(%rcx), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movzbl %al, %esi
callq 0x4d19
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
addq $0x20, %rdi
movl 0x44(%rbx), %edx
movzbl %r13b, %esi
callq 0x4d19
cmpl $0x2b, 0x18(%rbx)
jne 0x811b
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 0x97fb
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r14)
movups 0x8(%rsp), %xmm0
movups %xmm0, (%r14)
cmpl $0x35, 0x18(%rbx)
je 0x80f6
jmp 0x812d
leaq 0x3b79(%rip), %rdx      # 0xbc9b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x64ec
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq