// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x2100
movabsq $0x7ffc000000000001, %rax # imm = 0x7FFC000000000001
cmpq %rax, -0x10(%rbp)
jne 0x8311
leaq 0x5ea2(%rip), %rax      # 0xe19e
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movl %eax, -0x1c(%rbp)
jmp 0x8699
movabsq $0x7ffc000000000002, %rax # imm = 0x7FFC000000000002
andq -0x10(%rbp), %rax
movabsq $0x7ffc000000000002, %rcx # imm = 0x7FFC000000000002
cmpq %rcx, %rax
jne 0x8366
movq -0x10(%rbp), %rdx
movabsq $0x7ffc000000000003, %rsi # imm = 0x7FFC000000000003
leaq 0x6334(%rip), %rax      # 0xe677
leaq 0x6328(%rip), %rcx      # 0xe672
cmpq %rsi, %rdx
cmoveq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movl %eax, -0x1c(%rbp)
jmp 0x8697
movabsq $0x7ffc000000000000, %rax # imm = 0x7FFC000000000000
andq -0x10(%rbp), %rax
movabsq $0x7ffc000000000000, %rcx # imm = 0x7FFC000000000000
cmpq %rcx, %rax
je 0x83fd
leaq -0xa0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8790
movq -0xd0(%rbp), %rdi
movl $0x80, %esi
leaq 0x62d0(%rip), %rdx      # 0xe67d
movb $0x1, %al
callq 0x20d0
movl %eax, -0xa4(%rbp)
cmpl $0x0, -0xa4(%rbp)
jle 0x83c5
jmp 0x83e4
leaq 0x62b4(%rip), %rdi      # 0xe680
leaq 0x6279(%rip), %rsi      # 0xe64c
movl $0x128, %edx            # imm = 0x128
leaq 0x62ad(%rip), %rcx      # 0xe68c
callq 0x20e0
leaq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x8695
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x87b0
testb $0x1, %al
jne 0x840e
jmp 0x8444
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0xb0(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x8693
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x87b0
testb $0x1, %al
jne 0x8458
jmp 0x8474
leaq 0x6259(%rip), %rax      # 0xe6b8
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movl %eax, -0x1c(%rbp)
jmp 0x8691
movq -0x10(%rbp), %rdi
movl $0x2, %esi
callq 0x87b0
testb $0x1, %al
jne 0x8488
jmp 0x84a4
leaq 0x6230(%rip), %rax      # 0xe6bf
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movl %eax, -0x1c(%rbp)
jmp 0x868f
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x87b0
testb $0x1, %al
jne 0x84b8
jmp 0x84d4
leaq 0x6208(%rip), %rax      # 0xe6c7
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movl %eax, -0x1c(%rbp)
jmp 0x868d
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x87b0
testb $0x1, %al
jne 0x84e8
jmp 0x8561
leaq -0xa0(%rbp), %rdi
movabsq $0x3ffffffffffff, %rax  # imm = 0x3FFFFFFFFFFFF
andq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rcx
movl $0x80, %esi
leaq 0x61bc(%rip), %rdx      # 0xe6cd
movb $0x0, %al
callq 0x20d0
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
jle 0x8529
jmp 0x8548
leaq 0x6150(%rip), %rdi      # 0xe680
leaq 0x6115(%rip), %rsi      # 0xe64c
movl $0x13d, %edx            # imm = 0x13D
leaq 0x6149(%rip), %rcx      # 0xe68c
callq 0x20e0
leaq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xb4(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x868b
movq -0x10(%rbp), %rdi
movl $0x6, %esi
callq 0x87b0
testb $0x1, %al
jne 0x8575
jmp 0x85e6
leaq -0xa0(%rbp), %rdi
movabsq $0x3ffffffffffff, %rcx  # imm = 0x3FFFFFFFFFFFF
andq -0x10(%rbp), %rcx
movl $0x80, %esi
leaq 0x613f(%rip), %rdx      # 0xe6d5
movb $0x0, %al
callq 0x20d0
movl %eax, -0xb8(%rbp)
cmpl $0x0, -0xb8(%rbp)
jle 0x85ae
jmp 0x85cd
leaq 0x60cb(%rip), %rdi      # 0xe680
leaq 0x6090(%rip), %rsi      # 0xe64c
movl $0x142, %edx            # imm = 0x142
leaq 0x60c4(%rip), %rcx      # 0xe68c
callq 0x20e0
leaq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x8689
movq -0x10(%rbp), %rdi
movl $0x7, %esi
callq 0x87b0
testb $0x1, %al
jne 0x85fa
jmp 0x8668
leaq -0xa0(%rbp), %rdi
movabsq $0x3ffffffffffff, %rcx  # imm = 0x3FFFFFFFFFFFF
andq -0x10(%rbp), %rcx
movl $0x80, %esi
leaq 0x600c(%rip), %rdx      # 0xe627
movb $0x0, %al
callq 0x20d0
movl %eax, -0xbc(%rbp)
cmpl $0x0, -0xbc(%rbp)
jle 0x8633
jmp 0x8652
leaq 0x6046(%rip), %rdi      # 0xe680
leaq 0x600b(%rip), %rsi      # 0xe64c
movl $0x147, %edx            # imm = 0x147
leaq 0x603f(%rip), %rcx      # 0xe68c
callq 0x20e0
leaq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x8687
leaq 0x5b5b(%rip), %rdi      # 0xe1ca
leaq 0x5fd6(%rip), %rsi      # 0xe64c
movl $0x14b, %edx            # imm = 0x14B
leaq 0x600a(%rip), %rcx      # 0xe68c
callq 0x20e0
jmp 0x8689
jmp 0x868b
jmp 0x868d
jmp 0x868f
jmp 0x8691
jmp 0x8693
jmp 0x8695
jmp 0x8697
jmp 0x8699
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
addl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jle 0x874e
movq -0x8(%rbp), %rax
cmpl $0x8, 0xc(%rax)
jge 0x86c7
movl $0x8, %eax
movl %eax, -0xd4(%rbp)
jmp 0x86d6
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cltq
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
ja 0x8710
movslq -0x1c(%rbp), %rax
addq -0xc8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x8(%rbp), %rax
movslq 0xc(%rax), %rdx
movq -0xc8(%rbp), %rcx
callq 0xd7a0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movslq 0x8(%rax), %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rdx
callq 0x2180
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)