// File: /workspace/github_c_makefile_star2_O3/mahrr[P]raven/src/object.c
// Function: string_buf_push
void string_buf_push(StringBuffer *self, Value value) {
    const char *value_string = NULL;
    int value_length = 0;
    char buffer[128] = {0};

    if (Is_Nil(value)) {
        value_string = "nil";
        value_length = strlen(value_string);
    } else if (Is_Bool(value)) {
        value_string = As_Bool(value) ? "true" : "false";
        value_length = strlen(value_string);
    } else if (Is_Num(value)) {
        int written = snprintf(buffer, sizeof buffer, "%g", As_Num(value));
        assert(written > 0);
        value_string = buffer;
        value_length = written;
    } else if (Is_String(value)) {
        RavString *string = As_String(value);
        value_string = string->chars;
        value_length = string->length;
    } else if (Is_Pair(value)) {
        // TODO
        value_string = "<pair>";
        value_length = strlen(value_string);
    } else if (Is_Array(value)) {
        // TODO
        value_string = "<array>";
        value_length = strlen(value_string);
    } else if (Is_Map(value)) {
        // TODO
        value_string = "<map>";
        value_length = strlen(value_string);
    } else if (Is_Function(value)) {
        int written = snprintf(buffer, sizeof buffer, "<fn %s>", As_Function(value)->name->chars);
        assert(written > 0);
        value_string = buffer;
        value_length = written;
    } else if (Is_Closure(value)) {
        int written = snprintf(buffer, sizeof buffer, "<closure %p>", As_Closure(value));
        assert(written > 0);
        value_string = buffer;
        value_length = written;
    } else if (Is_CFunction(value)) {
        int written = snprintf(buffer, sizeof buffer, "<native @ %p>", As_Obj(value));
        assert(written > 0);
        value_string = buffer;
        value_length = written;
    } else {
        assert(!"unreachable: invalid value tag");
    }

    if (self->count + value_length > self->capacity) {
        size_t new_capacity = Grow_Capacity(self->capacity);
        if (new_capacity <= (size_t)(self->count + value_length)) {
            new_capacity += (size_t)value_length;
        }

        self->buffer = allocate(self->allocator, self->buffer, self->capacity, new_capacity);
        self->capacity = new_capacity;
    }

    memcpy(self->buffer + self->count, value_string, value_length);
    self->count += value_length;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movabsq $0x7ffc000000000000, %rax # imm = 0x7FFC000000000000
pxor %xmm0, %xmm0
movdqa %xmm0, 0x70(%rsp)
movdqa %xmm0, 0x60(%rsp)
movdqa %xmm0, 0x50(%rsp)
movdqa %xmm0, 0x40(%rsp)
movdqa %xmm0, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
movdqa %xmm0, 0x10(%rsp)
movdqa %xmm0, (%rsp)
leaq 0x1(%rax), %rdx
cmpq %rdx, %rsi
jne 0x5718
leaq 0x5a91(%rip), %r14      # 0xb19e
movl $0x3, %r15d
jmp 0x57c3
movq %rsi, %rcx
leaq 0x2(%rax), %rsi
movq %rcx, %rdx
notq %rdx
testq %rdx, %rsi
jne 0x5750
addq $0x3, %rax
xorl %r15d, %r15d
cmpq %rax, %rcx
sete %r15b
leaq 0x5f73(%rip), %rax      # 0xb6b2
leaq 0x5f71(%rip), %r14      # 0xb6b7
cmoveq %rax, %r14
xorl $0x5, %r15d
jmp 0x57c3
testq %rdx, %rax
jne 0x579a
movq %rcx, %rax
shrq $0x32, %rax
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5933
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq %rax, %rcx
movl (%rcx), %eax
cmpq $0x7, %rax
ja 0x5933
leaq 0x5eb1(%rip), %rdx      # 0xb638
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x18(%rcx), %r14
movl 0x10(%rcx), %r15d
jmp 0x57c3
movq %rcx, %xmm0
leaq 0x5f17(%rip), %rdx      # 0xb6bd
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
movb $0x1, %al
callq 0x20d0
testl %eax, %eax
jle 0x5952
movl %eax, %r15d
movl 0x8(%rbx), %ecx
leal (%rcx,%r15), %eax
movslq 0xc(%rbx), %rdx
cmpl %edx, %eax
jle 0x580a
leal (%rdx,%rdx), %ecx
cmpl $0x8, %edx
movl $0x8, %esi
cmovgel %ecx, %esi
xorl %ecx, %ecx
cmpl %eax, %esi
cmovbel %r15d, %ecx
movslq %ecx, %r12
addq %rsi, %r12
movq (%rbx), %rdi
movq 0x10(%rbx), %rsi
movq %r12, %rcx
callq 0xa554
movq %rax, 0x10(%rbx)
movl %r12d, 0xc(%rbx)
movl 0x8(%rbx), %ecx
jmp 0x580e
movq 0x10(%rbx), %rax
movslq %ecx, %rdi
addq %rax, %rdi
movslq %r15d, %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x2170
addl %r15d, 0x8(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x10(%rcx), %rax
movq 0x18(%rax), %rcx
leaq 0x5ec9(%rip), %rdx      # 0xb70d
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x57c0
leaq 0x5e5b(%rip), %rdi      # 0xb6c0
leaq 0x5e20(%rip), %rsi      # 0xb68c
leaq 0x5e59(%rip), %rcx      # 0xb6cc
movl $0x13d, %edx            # imm = 0x13D
callq 0x20e0
leaq 0x5e74(%rip), %r14      # 0xb6f8
movl $0x6, %r15d
jmp 0x57c3
leaq 0x5e7f(%rip), %rdx      # 0xb715
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x57c0
leaq 0x5e09(%rip), %rdi      # 0xb6c0
leaq 0x5dce(%rip), %rsi      # 0xb68c
leaq 0x5e07(%rip), %rcx      # 0xb6cc
movl $0x142, %edx            # imm = 0x142
callq 0x20e0
leaq 0x5e29(%rip), %r14      # 0xb6ff
movl $0x7, %r15d
jmp 0x57c3
leaq 0x5e1f(%rip), %r14      # 0xb707
movl $0x5, %r15d
jmp 0x57c3
leaq 0x5d6d(%rip), %rdx      # 0xb667
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x57c0
leaq 0x5da5(%rip), %rdi      # 0xb6c0
leaq 0x5d6a(%rip), %rsi      # 0xb68c
leaq 0x5da3(%rip), %rcx      # 0xb6cc
movl $0x147, %edx            # imm = 0x147
callq 0x20e0
leaq 0x5890(%rip), %rdi      # 0xb1ca
leaq 0x5d4b(%rip), %rsi      # 0xb68c
leaq 0x5d84(%rip), %rcx      # 0xb6cc
movl $0x14b, %edx            # imm = 0x14B
callq 0x20e0
leaq 0x5d67(%rip), %rdi      # 0xb6c0
leaq 0x5d2c(%rip), %rsi      # 0xb68c
leaq 0x5d65(%rip), %rcx      # 0xb6cc
movl $0x128, %edx            # imm = 0x128
callq 0x20e0