// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_load_string
bool ce_buffer_load_string(CeBuffer_t* buffer, const char* string, const char* name){
     if(buffer->lines) ce_buffer_free(buffer);

     int64_t line_count = ce_util_count_string_lines(string);

     // allocate for the number of lines contained in the string
     buffer->lines = (char**)calloc(line_count, sizeof(*buffer->lines));
     if(!buffer->lines){
          ce_log("%s() failed to allocate %ld lines\n", __FUNCTION__, line_count);
          return false;
     }

     buffer->line_count = line_count;
     buffer->name = strdup(name);

     // loop over each line
     const char* newline = NULL;
     size_t line_len = 0;
     for(int64_t i = 0; i < line_count; i++){
          FindNewlineResult_t res = find_next_newline(string);
          if(res.status == FNS_INVALID){
               ce_log("%s() saw invalid utf-8 bytes\n");
               ce_buffer_free(buffer);
               return false;
          }

          // look for the newline
          newline = strchr(string, CE_NEWLINE);

          if(newline){
               // allocate space for the line, excluding the newline character
               line_len = newline - string;
               buffer->lines[i] = (char*)malloc(line_len + 1);
               buffer->lines[i] = strncpy(buffer->lines[i], string, line_len);
               buffer->lines[i][line_len] = 0;

               string = newline + 1;
          }else{
               // if this is the end, just dupe it
               buffer->lines[i] = strdup(string);
               break;
          }
     }

     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, (%rdi)
je 0xe121
movq %rbx, %rdi
callq 0xdea7
movq %r14, %rdi
callq 0xe2bc
movq %rax, %r12
movl $0x8, %esi
movq %rax, %rdi
callq 0xd380
movq %rax, (%rbx)
testq %rax, %rax
je 0xe28d
movq %r12, 0x8(%rbx)
movq %r15, %rdi
callq 0xd640
movq %rax, 0x10(%rbx)
testq %r12, %r12
jle 0xe2a9
movq %rbx, (%rsp)
xorl %ebx, %ebx
leaq 0x8(%rsp), %r13
movq %r14, %r15
movq %r12, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
xorl %r14d, %r14d
movq %r15, %rbp
cmpb $0x0, (%rbp)
je 0xe1b7
movq %rbp, %rdi
movq %r13, %rsi
callq 0xe649
cmpl $0xa, %eax
je 0xe1a3
cmpl $-0x1, %eax
jne 0xe1aa
movl $0x2, %r14d
jmp 0xe1a6
xorl %r14d, %r14d
xorl %eax, %eax
jmp 0xe1b1
addq 0x8(%rsp), %rbp
movb $0x1, %al
testb %al, %al
jne 0xe180
jmp 0xe1bd
movl $0x1, %r14d
cmpl $0x2, %r14d
jne 0xe1e6
xorl %ebp, %ebp
leaq 0x2042e(%rip), %rdi     # 0x2e5fa
xorl %eax, %eax
callq 0xd954
movq (%rsp), %rdi
callq 0xdea7
movl $0x1, %eax
jmp 0xe26f
movq %r15, %rdi
movl $0xa, %esi
callq 0xd230
movq %r15, %r14
testq %rax, %rax
je 0xe252
movq %rax, %r15
movq %rax, %rbp
subq %r14, %rbp
leaq 0x1(%rbp), %rdi
callq 0xd4c0
movq (%rsp), %r12
movq (%r12), %rcx
movq %rax, (%rcx,%rbx,8)
movq (%r12), %rax
movq %r14, %rsi
movq (%rax,%rbx,8), %r14
movq %r14, %rdi
movq %rbp, %rdx
callq 0xd0b0
movq (%r12), %rax
movq %r14, (%rax,%rbx,8)
movq (%r12), %rax
movq 0x10(%rsp), %r12
movq (%rax,%rbx,8), %rax
movb $0x0, (%rax,%rbp)
incq %r15
xorl %eax, %eax
movb $0x1, %bpl
jmp 0xe26f
movq %r14, %rdi
callq 0xd640
movq (%rsp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x2, %eax
xorl %ebp, %ebp
movq %r14, %r15
testb %bpl, %bpl
je 0xe285
incq %rbx
cmpq %r12, %rbx
jne 0xe171
movl $0x2, %eax
cmpl $0x2, %eax
sete %bl
jmp 0xe2ab
leaq 0x2032d(%rip), %rdi     # 0x2e5c1
leaq 0x20349(%rip), %rsi     # 0x2e5e4
xorl %ebx, %ebx
movq %r12, %rdx
xorl %eax, %eax
callq 0xd954
jmp 0xe2ab
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq