// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
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 0x5a0a
leaq 0x579e(%rip), %r14      # 0xb19e
movl $0x3, %ebp
jmp 0x5af7
movq %rsi, %rcx
leaq 0x2(%rax), %rsi
movq %rcx, %rdx
notq %rdx
testq %rdx, %rsi
jne 0x5a43
addq $0x3, %rax
xorl %ebp, %ebp
cmpq %rax, %rcx
sete %bpl
leaq 0x5c42(%rip), %rax      # 0xb672
leaq 0x5c40(%rip), %r14      # 0xb677
cmoveq %rax, %r14
xorl $0x5, %ebp
jmp 0x5af7
testq %rdx, %rax
jne 0x5a8a
movq %rcx, %rax
shrq $0x32, %rax
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
movabsq $0x3ffffffffffff, %rdx  # imm = 0x3FFFFFFFFFFFF
andq %rdx, %rcx
cmpl $0x0, (%rcx)
je 0x5ab4
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
cmpl $0x1, (%rcx)
jne 0x5abd
leaq 0x5c35(%rip), %r14      # 0xb6b8
movl $0x6, %ebp
jmp 0x5af7
movq %rcx, %xmm0
leaq 0x5be7(%rip), %rdx      # 0xb67d
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
movb $0x1, %al
callq 0x20d0
testl %eax, %eax
jle 0x5c6d
movl %eax, %ebp
jmp 0x5af7
movq 0x18(%rcx), %r14
movl 0x10(%rcx), %ebp
jmp 0x5af7
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
cmpl $0x2, (%rcx)
jne 0x5adb
leaq 0x5beb(%rip), %r14      # 0xb6bf
movl $0x7, %ebp
jmp 0x5af7
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
cmpl $0x3, (%rcx)
jne 0x5b5a
leaq 0x5bd5(%rip), %r14      # 0xb6c7
movl $0x5, %ebp
movl 0x8(%rbx), %eax
addl %ebp, %eax
movslq 0xc(%rbx), %rdx
cmpl %edx, %eax
jle 0x5b36
leal (%rdx,%rdx), %ecx
cmpl $0x8, %edx
movl $0x8, %esi
cmovgel %ecx, %esi
xorl %ecx, %ecx
cmpl %eax, %esi
cmovbel %ebp, %ecx
movslq %ecx, %r15
addq %rsi, %r15
movq (%rbx), %rdi
movq 0x10(%rbx), %rsi
movq %r15, %rcx
callq 0xa91c
movq %rax, 0x10(%rbx)
movl %r15d, 0xc(%rbx)
movslq 0x8(%rbx), %rdi
addq 0x10(%rbx), %rdi
movslq %ebp, %rdx
movq %r14, %rsi
callq 0x2170
addl %ebp, 0x8(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
cmpl $0x4, (%rcx)
jne 0x5bb2
movq 0x10(%rcx), %rax
movq 0x18(%rax), %rcx
leaq 0x5b54(%rip), %rdx      # 0xb6cd
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x5ab0
leaq 0x5ae6(%rip), %rdi      # 0xb680
leaq 0x5aab(%rip), %rsi      # 0xb64c
leaq 0x5ae4(%rip), %rcx      # 0xb68c
movl $0x13d, %edx            # imm = 0x13D
callq 0x20e0
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
cmpl $0x6, (%rcx)
jne 0x5c02
leaq 0x5b0c(%rip), %rdx      # 0xb6d5
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x5ab0
leaq 0x5a96(%rip), %rdi      # 0xb680
leaq 0x5a5b(%rip), %rsi      # 0xb64c
leaq 0x5a94(%rip), %rcx      # 0xb68c
movl $0x142, %edx            # imm = 0x142
callq 0x20e0
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5c4e
cmpl $0x7, (%rcx)
jne 0x5c4e
leaq 0x5a12(%rip), %rdx      # 0xb627
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x5ab0
leaq 0x5a4a(%rip), %rdi      # 0xb680
leaq 0x5a0f(%rip), %rsi      # 0xb64c
leaq 0x5a48(%rip), %rcx      # 0xb68c
movl $0x147, %edx            # imm = 0x147
callq 0x20e0
leaq 0x5575(%rip), %rdi      # 0xb1ca
leaq 0x59f0(%rip), %rsi      # 0xb64c
leaq 0x5a29(%rip), %rcx      # 0xb68c
movl $0x14b, %edx            # imm = 0x14B
callq 0x20e0
leaq 0x5a0c(%rip), %rdi      # 0xb680
leaq 0x59d1(%rip), %rsi      # 0xb64c
leaq 0x5a0a(%rip), %rcx      # 0xb68c
movl $0x128, %edx            # imm = 0x128
callq 0x20e0