// File: /workspace/github_c_makefile_star2_O2/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 0x5417
leaq 0x3d90(%rip), %r14      # 0x919e
pushq $0x3
popq %r15
jmp 0x54c2
movq %rsi, %rcx
leaq 0x2(%rax), %rsi
movq %rcx, %rdx
notq %rdx
testq %rdx, %rsi
jne 0x544f
addq $0x3, %rax
xorl %r15d, %r15d
cmpq %rax, %rcx
sete %r15b
leaq 0x4274(%rip), %rax      # 0x96b2
leaq 0x4272(%rip), %r14      # 0x96b7
cmoveq %rax, %r14
xorl $0x5, %r15d
jmp 0x54c2
testq %rdx, %rax
jne 0x5499
movq %rcx, %rax
shrq $0x32, %rax
cmpl $0x3fff, %eax           # imm = 0x3FFF
jb 0x5624
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq %rax, %rcx
movl (%rcx), %eax
cmpq $0x7, %rax
ja 0x5624
leaq 0x41b2(%rip), %rdx      # 0x9638
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0x18(%rcx), %r14
movl 0x10(%rcx), %r15d
jmp 0x54c2
movq %rcx, %xmm0
leaq 0x4218(%rip), %rdx      # 0x96bd
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
movb $0x1, %al
callq 0x20d0
testl %eax, %eax
jle 0x5643
movl %eax, %r15d
movl 0x8(%rbx), %ecx
leal (%rcx,%r15), %eax
movslq 0xc(%rbx), %rdx
cmpl %edx, %eax
jle 0x5507
leal (%rdx,%rdx), %ecx
cmpl $0x8, %edx
pushq $0x8
popq %rsi
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 0x81a8
movq %rax, 0x10(%rbx)
movl %r12d, 0xc(%rbx)
movl 0x8(%rbx), %ecx
jmp 0x550b
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 0x41cc(%rip), %rdx      # 0x970d
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x54bf
leaq 0x415e(%rip), %rdi      # 0x96c0
leaq 0x4123(%rip), %rsi      # 0x968c
leaq 0x415c(%rip), %rcx      # 0x96cc
movl $0x13d, %edx            # imm = 0x13D
callq 0x20e0
leaq 0x4177(%rip), %r14      # 0x96f8
pushq $0x6
jmp 0x5410
leaq 0x4186(%rip), %rdx      # 0x9715
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x54bf
leaq 0x4110(%rip), %rdi      # 0x96c0
leaq 0x40d5(%rip), %rsi      # 0x968c
leaq 0x410e(%rip), %rcx      # 0x96cc
movl $0x142, %edx            # imm = 0x142
callq 0x20e0
leaq 0x4130(%rip), %r14      # 0x96ff
pushq $0x7
jmp 0x5410
leaq 0x412a(%rip), %r14      # 0x9707
pushq $0x5
jmp 0x5410
leaq 0x407c(%rip), %rdx      # 0x9667
movq %rsp, %r14
movl $0x80, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x20d0
testl %eax, %eax
jg 0x54bf
leaq 0x40b4(%rip), %rdi      # 0x96c0
leaq 0x4079(%rip), %rsi      # 0x968c
leaq 0x40b2(%rip), %rcx      # 0x96cc
movl $0x147, %edx            # imm = 0x147
callq 0x20e0
leaq 0x3b9f(%rip), %rdi      # 0x91ca
leaq 0x405a(%rip), %rsi      # 0x968c
leaq 0x4093(%rip), %rcx      # 0x96cc
movl $0x14b, %edx            # imm = 0x14B
callq 0x20e0
leaq 0x4076(%rip), %rdi      # 0x96c0
leaq 0x403b(%rip), %rsi      # 0x968c
leaq 0x4074(%rip), %rcx      # 0x96cc
movl $0x128, %edx            # imm = 0x128
callq 0x20e0