// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xe507
movq -0x10(%rbp), %rdi
callq 0xe160
movq -0x18(%rbp), %rdi
callq 0xe6c0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x8, %esi
callq 0xd360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xe558
movq -0x28(%rbp), %rdx
leaq 0x3401c(%rip), %rdi     # 0x4255d
leaq 0x34038(%rip), %rsi     # 0x42580
movb $0x0, %al
callq 0xd8f0
movb $0x0, -0x1(%rbp)
jmp 0xe6a6
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
callq 0xd620
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0xe6a2
movq -0x18(%rbp), %rdi
callq 0xe740
movq %rax, -0x50(%rbp)
movl %edx, -0x48(%rbp)
cmpl $0x2, -0x48(%rbp)
jne 0xe5d4
leaq 0x33fdb(%rip), %rdi     # 0x42596
movb $0x0, %al
callq 0xd8f0
movq -0x10(%rbp), %rdi
callq 0xe160
movb $0x0, -0x1(%rbp)
jmp 0xe6a6
movq -0x18(%rbp), %rdi
movl $0xa, %esi
callq 0xd220
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xe672
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
addq $0x1, %rdi
callq 0xd4a0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xd0b0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0xe68f
movq -0x18(%rbp), %rdi
callq 0xd620
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xe6a2
jmp 0xe691
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xe590
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)