LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_log
void ce_log(const char* fmt, ...){
     va_list args;
     va_start(args, fmt);
     size_t string_len = vsnprintf(g_log_string, BUFSIZ, fmt, args);
     va_end(args);

#if defined(PLATFORM_WINDOWS)
     printf("%s", g_log_string);
#else
     fwrite(g_log_string, string_len, 1, g_ce_log);
#endif
     CePoint_t end = ce_buffer_end_point(g_ce_log_buffer);
     g_ce_log_buffer->status = CE_BUFFER_STATUS_NONE;
     ce_buffer_insert_string(g_ce_log_buffer, g_log_string, end);
     g_ce_log_buffer->status = CE_BUFFER_STATUS_READONLY;
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0xd944
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rdi, 0x10(%rcx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
leaq 0x2c195(%rip), %rbx     # 0x39b00
movl $0x2000, %esi           # imm = 0x2000
movq %rbx, %rdi
movq %r10, %rdx
callq 0xd180
movslq %eax, %rsi
movq 0x2c16b(%rip), %rcx     # 0x39af0
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xd610
movq 0x2c161(%rip), %rdi     # 0x39af8
callq 0xd9cc
movq %rdx, %rcx
movq 0x2c152(%rip), %rdi     # 0x39af8
andl $0x0, 0x18(%rdi)
movq %rbx, %rsi
movq %rax, %rdx
callq 0xd9ef
movq 0x2c13c(%rip), %rax     # 0x39af8
movl $0x2, 0x18(%rax)
addq $0xd0, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_end_point
CePoint_t ce_buffer_end_point(CeBuffer_t* buffer){
     CePoint_t point = {0, buffer->line_count};
     if(point.y > 0){
          point.y--;
          point.x = ce_utf8_last_index(buffer->lines[point.y]);
     }
     return point;
}

// Assembly:
pushq %rbx
movq 0x8(%rdi), %rbx
testq %rbx, %rbx
jle 0xd9e8
movq (%rdi), %rax
movq -0x8(%rax,%rbx,8), %rdi
decq %rbx
callq 0xe784
jmp 0xd9ea
xorl %eax, %eax
movq %rbx, %rdx
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_alloc
bool ce_buffer_alloc(CeBuffer_t* buffer, int64_t line_count, const char* name){
     if(buffer->lines) ce_buffer_free(buffer);

     if(line_count <= 0){
          ce_log("%s() error: 0 line_count specified.\n", __FUNCTION__);
          return false;
     }

     buffer->lines = (char**)malloc(line_count * sizeof(*buffer->lines));
     if(!buffer->lines){
          ce_log("%s() failed to malloc() %ld lines.\n", __FUNCTION__, line_count);
          return false;
     }

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

     for(int64_t i = 0; i < line_count; i++){
          buffer->lines[i] = (char*)calloc(1, sizeof(buffer->lines[i]));
     }

     buffer->status = CE_BUFFER_STATUS_MODIFIED;
     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x0, (%rdi)
je 0xdd7a
movq %r14, %rdi
callq 0xde1c
testq %rbx, %rbx
jle 0xddd8
leaq (,%rbx,8), %rdi
callq 0xd4c0
movq %rax, (%r14)
testq %rax, %rax
je 0xddf1
movq %rbx, 0x8(%r14)
movq %r15, %rdi
callq 0xd640
movq %rax, 0x10(%r14)
xorl %r13d, %r13d
pushq $0x1
popq %r15
pushq $0x8
popq %r12
cmpq %r13, %rbx
je 0xddcb
movq %r15, %rdi
movq %r12, %rsi
callq 0xd380
movq (%r14), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0xddaf
movl $0x1, 0x18(%r14)
movb $0x1, %bpl
jmp 0xde0b
leaq 0x1c711(%rip), %rdi     # 0x2a4f0
leaq 0x1c72f(%rip), %rsi     # 0x2a515
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xd8e5
jmp 0xde0b
leaq 0x1c72d(%rip), %rdi     # 0x2a525
leaq 0x1c716(%rip), %rsi     # 0x2a515
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd8e5
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_free
void ce_buffer_free(CeBuffer_t* buffer){
     for(int64_t i = 0; i < buffer->line_count; i++){
          free(buffer->lines[i]);
     }

     free(buffer->lines);
     free(buffer->name);

     if(buffer->change_node){
          CeBufferChangeNode_t* head = buffer->change_node;
          while(head->prev) head = head->prev;
          ce_buffer_change_node_free(&head);
     }

     memset(buffer, 0, sizeof(*buffer));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r14d, %r14d
movq (%rbx), %rdi
cmpq 0x8(%rbx), %r14
jge 0xde3d
movq (%rdi,%r14,8), %rdi
callq 0xd090
incq %r14
jmp 0xde26
callq 0xd090
movq 0x10(%rbx), %rdi
callq 0xd090
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0xde6b
movq %rax, %rcx
movq 0x48(%rax), %rax
testq %rax, %rax
jne 0xde54
movq %rsp, %rdi
movq %rcx, (%rdi)
callq 0xde91
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_change_node_free
static void ce_buffer_change_node_free(CeBufferChangeNode_t** head){
     CeBufferChangeNode_t* itr = *head;
     while(itr){
          CeBufferChangeNode_t* tmp = itr;
          itr = itr->next;
          free(tmp->change.string);
          free(tmp);
     }

     *head = NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
testq %r14, %r14
je 0xdebb
movq 0x8(%r14), %rdi
movq 0x40(%r14), %r15
callq 0xd090
movq %r14, %rdi
callq 0xd090
movq %r15, %r14
jmp 0xde9c
andq $0x0, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_util_count_string_lines
int64_t ce_util_count_string_lines(const char* string){
     int64_t string_length = strlen(string);
     int64_t line_count = 0;
     for(int64_t i = 0; i <= string_length; ++i){
          if(string[i] == CE_NEWLINE || string[i] == 0) line_count++;
     }

     return line_count;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0xd210
movq %rax, %rcx
xorl %eax, %eax
xorl %edx, %edx
cmpq %rcx, %rdx
jg 0xe1f9
movzbl (%rbx,%rdx), %esi
cmpl $0xa, %esi
je 0xe1f1
testl %esi, %esi
jne 0xe1f4
incq %rax
incq %rdx
jmp 0xe1df
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_save
bool ce_buffer_save(CeBuffer_t* buffer){
     FILE* file = fopen(buffer->name, "wb");
     if(!file){
          ce_log("%s() fopen('%s', 'wb') failed: '%s'\n", __FUNCTION__, buffer->name, strerror(errno));
          return false;
     }

     char newline = CE_NEWLINE;
     for(int64_t i = 0; i < buffer->line_count; ++i){
          int64_t line_len = strlen(buffer->lines[i]);
          fwrite(buffer->lines[i], 1, line_len, file);
          fwrite(&newline, 1, 1, file);
     }

     fclose(file);
     if(buffer->status == CE_BUFFER_STATUS_MODIFIED) buffer->status = CE_BUFFER_STATUS_NONE;
     buffer->save_at_change_node = buffer->change_node;

     struct stat statbuf;
     if(stat(buffer->name, &statbuf) == 0){
          buffer->file_modified_time = statbuf.st_mtime;
     }

     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r14
movq 0x10(%rdi), %rdi
leaq 0x1c3fe(%rip), %rsi     # 0x2a618
callq 0xd5b0
movq %rax, %rbx
testq %rax, %rax
je 0xe29f
xorl %r13d, %r13d
pushq $0x1
popq %r15
pushq $0xa
popq %rbp
cmpq 0x8(%r14), %r13
jge 0xe266
movq (%r14), %rax
movq (%rax,%r13,8), %r12
movq %r12, %rdi
callq 0xd210
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %rbx, %rcx
callq 0xd610
movl %ebp, %edi
movq %rbx, %rsi
callq 0xd330
incq %r13
jmp 0xe231
movq %rbx, %rdi
callq 0xd1f0
cmpl $0x1, 0x18(%r14)
jne 0xe27a
andl $0x0, 0x18(%r14)
movq 0x40(%r14), %rax
movq %rax, 0x48(%r14)
movq 0x10(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0xd3f0
testl %eax, %eax
jne 0xe2ca
movq 0x60(%rsp), %rax
movq %rax, 0x68(%r14)
jmp 0xe2ca
movq 0x10(%r14), %r14
callq 0xd0a0
movl (%rax), %edi
callq 0xd650
leaq 0x1c365(%rip), %rdi     # 0x2a61b
leaq 0x1c383(%rip), %rsi     # 0x2a640
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xd8e5
testq %rbx, %rbx
setne %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_empty
bool ce_buffer_empty(CeBuffer_t* buffer){
     if(buffer->lines == NULL) return false;

     // free all lines after the first
     for(int64_t i = 0; i < buffer->line_count; ++i){
          free(buffer->lines[i]);
     }

     // re allocate it down to a single blank line
     buffer->lines = realloc(buffer->lines, sizeof(*buffer->lines));
     buffer->lines[0] = malloc(sizeof(buffer->lines[0]));
     buffer->lines[0][0] = 0;
     buffer->line_count = 1;
     buffer->status = CE_BUFFER_STATUS_NONE;

     return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r12
testq %r12, %r12
je 0xe33b
movq %rdi, %rbx
xorl %r14d, %r14d
movq (%rbx), %rdi
cmpq 0x8(%rbx), %r14
jge 0xe30f
movq (%rdi,%r14,8), %rdi
callq 0xd090
incq %r14
jmp 0xe2f8
pushq $0x8
popq %r14
movq %r14, %rsi
callq 0xd520
movq %rax, %r15
movq %rax, (%rbx)
movq %r14, %rdi
callq 0xd4c0
movq %rax, (%r15)
movb $0x0, (%rax)
movq $0x1, 0x8(%rbx)
andl $0x0, 0x18(%rbx)
testq %r12, %r12
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_contains_point
bool ce_buffer_contains_point(CeBuffer_t* buffer, CePoint_t point){
     if(point.y < 0 || point.y >= buffer->line_count || point.x < 0) return false;
     int64_t line_len = ce_utf8_strlen(buffer->lines[point.y]);
     if(point.x >= line_len){
          if(line_len == 0 && point.x == 0){
               return true;
          }
          return false;
     }

     return true;
}

// Assembly:
testq %rdx, %rdx
js 0xe36b
pushq %rbx
movq %rsi, %rbx
cmpq %rdx, 0x8(%rdi)
setle %al
testq %rsi, %rsi
sets %cl
orb %al, %cl
je 0xe36e
xorl %eax, %eax
jmp 0xe38a
xorl %eax, %eax
retq
movq (%rdi), %rax
movq (%rax,%rdx,8), %rdi
callq 0xe38c
movq %rax, %rcx
movb $0x1, %al
cmpq %rbx, %rcx
jg 0xe38a
orq %rbx, %rcx
sete %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_utf8_strlen
int64_t ce_utf8_strlen(const char* string){
     int64_t len = 0;
     int64_t byte_count = 0;

     while(*string){
          if((*string & 0x80) == 0){
               byte_count = 1;
          }else if((*string & 0xE0) == 0xC0){
               byte_count = 2;
          }else if((*string & 0xF0) == 0xE0){
               byte_count = 3;
          }else if((*string & 0xF8) == 0xF0){
               byte_count = 4;
          }else{
               assert(!"unicode character claiming it has more than 4 bytes?!");
               return -1;
          }

          // validate string doesn't early terminate
          for(int64_t i = 0; i < byte_count; i++){
               if(*string == 0) return -1;
               string++;
          }

          len++;
     }

     return len;
}

// Assembly:
pushq %rbx
xorl %eax, %eax
pushq $0x1
popq %rdx
pushq $-0x1
popq %rcx
pushq $0x2
popq %rsi
pushq $0x3
popq %r8
pushq $0x4
popq %r9
movzbl (%rdi), %r11d
testl %r11d, %r11d
je 0xe404
movq %rdx, %r10
testb %r11b, %r11b
jns 0xe3e3
movl %r11d, %ebx
andl $-0x20, %ebx
movq %rsi, %r10
cmpl $0xc0, %ebx
je 0xe3e3
movl %r11d, %ebx
andl $-0x10, %ebx
movq %r8, %r10
cmpl $0xe0, %ebx
je 0xe3e3
andl $-0x8, %r11d
movq %r9, %r10
cmpl $0xf0, %r11d
jne 0xe406
leaq (%rdi,%r10), %r11
xorl %ebx, %ebx
cmpq %rbx, %r10
je 0xe3f9
cmpb $0x0, (%rdi,%rbx)
je 0xe401
incq %rbx
jmp 0xe3e9
incq %rax
movq %r11, %rdi
jmp 0xe3a0
movq %rcx, %rax
popq %rbx
retq
leaq 0x1c31a(%rip), %rdi     # 0x2a727
leaq 0x1c264(%rip), %rsi     # 0x2a678
leaq 0x1c345(%rip), %rcx     # 0x2a760
movl $0x531, %edx            # imm = 0x531
callq 0xd280
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_point_is_valid
int64_t ce_buffer_point_is_valid(CeBuffer_t* buffer, CePoint_t point){
     if(point.y < 0 || point.y >= buffer->line_count || point.x < 0) return false;
     int64_t line_len = ce_utf8_strlen(buffer->lines[point.y]);
     if(point.x > line_len) return false;

     return true;
}

// Assembly:
testq %rdx, %rdx
js 0xe443
pushq %rbx
movq %rsi, %rbx
cmpq %rdx, 0x8(%rdi)
setle %al
testq %rsi, %rsi
sets %cl
orb %al, %cl
je 0xe446
xorl %eax, %eax
jmp 0xe45d
xorl %eax, %eax
retq
movq (%rdi), %rax
movq (%rax,%rdx,8), %rdi
callq 0xe38c
movq %rax, %rcx
xorl %eax, %eax
cmpq %rbx, %rcx
setge %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_get_rune
CeRune_t ce_buffer_get_rune(CeBuffer_t* buffer, CePoint_t point){
     if(!ce_buffer_point_is_valid(buffer, point)) return CE_UTF8_INVALID;

     char* str = ce_utf8_iterate_to(buffer->lines[point.y], point.x);
     int64_t rune_len = 0;
     return ce_utf8_decode(str, &rune_len);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
callq 0xe425
testq %rax, %rax
je 0xe499
movq (%r15), %rax
movq (%rax,%r14,8), %rdi
movq %rbx, %rsi
callq 0xe4a6
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0xe53f
jmp 0xe49c
pushq $-0x1
popq %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_utf8_iterate_to
char* ce_utf8_iterate_to(char* string, int64_t index){
     int64_t bytes = 0;
     while(index){
          if((*string & 0x80) == 0){
               bytes = 1;
          }else if((*string & 0xE0) == 0xC0){
               bytes = 2;
          }else if((*string & 0xF0) == 0xE0){
               bytes = 3;
          }else if((*string & 0xF8) == 0xF0){
               bytes = 4;
          }else{
               assert(!"unicode character claiming it has more than 4 bytes?!");
               return NULL;
          }

          for(int64_t i = 0; i < bytes; ++i){
               if(*string == 0){
                    return NULL;
               }
               string++;
          }

          index--;
     }

     return string;
}

// Assembly:
pushq %rax
pushq $0x1
popq %rax
pushq $0x2
popq %rcx
pushq $0x3
popq %rdx
pushq $0x4
popq %r8
subq $0x1, %rsi
jb 0xe51b
movzbl (%rdi), %r10d
movq %rax, %r9
testb %r10b, %r10b
jns 0xe4fc
movl %r10d, %r11d
andl $-0x20, %r11d
movq %rcx, %r9
cmpl $0xc0, %r11d
je 0xe4fc
movl %r10d, %r11d
andl $-0x10, %r11d
movq %rdx, %r9
cmpl $0xe0, %r11d
je 0xe4fc
andl $-0x8, %r10d
movq %r8, %r9
cmpl $0xf0, %r10d
jne 0xe520
leaq (%rdi,%r9), %r10
xorl %r11d, %r11d
cmpq %r11, %r9
je 0xe514
cmpb $0x0, (%rdi,%r11)
je 0xe519
incq %r11
jmp 0xe503
movq %r10, %rdi
jmp 0xe4b4
xorl %edi, %edi
movq %rdi, %rax
popq %rcx
retq
leaq 0x1c200(%rip), %rdi     # 0x2a727
leaq 0x1c14a(%rip), %rsi     # 0x2a678
leaq 0x1c28b(%rip), %rcx     # 0x2a7c0
movl $0x572, %edx            # imm = 0x572
callq 0xd280
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_utf8_decode
CeRune_t ce_utf8_decode(const char* string, int64_t* bytes_consumed){
     CeRune_t rune = CE_UTF8_INVALID;

     // 0xxxxxxx is just ascii
     if((*string & 0x80) == 0){
          *bytes_consumed = 1;
          rune = string[0];
     // 110xxxxx is a 2 byte utf8 string
     }else if((*string & 0xE0) == 0xC0){
          *bytes_consumed = 2;
          rune = string[0] & 0x1F;
          rune <<= 6;
          rune |= string[1] & 0x3F;
     // 1110xxxx is a 3 byte utf8 string
     }else if((*string & 0xF0) == 0xE0){
          *bytes_consumed = 3;
          rune = string[0] & 0x0F;
          rune <<= 6;
          rune |= string[1] & 0x3F;
          rune <<= 6;
          rune |= string[2] & 0x3F;
     // 11110xxx is a 4 byte utf8 string
     }else if((*string & 0xF8) == 0xF0){
          *bytes_consumed = 4;
          rune = string[0] & 0x0F;
          rune <<= 6;
          rune |= string[1] & 0x3F;
          rune <<= 6;
          rune |= string[2] & 0x3F;
          rune <<= 6;
          rune |= string[3] & 0x3F;
     }

     return rune;
}

// Assembly:
movzbl (%rdi), %eax
testb %al, %al
js 0xe551
movq $0x1, (%rsi)
movsbl (%rdi), %eax
retq
movl %eax, %ecx
andl $-0x20, %ecx
cmpl $0xc0, %ecx
jne 0xe574
movq $0x2, (%rsi)
movzbl (%rdi), %ecx
andl $0x1f, %ecx
shll $0x6, %ecx
movzbl 0x1(%rdi), %eax
jmp 0xe5a1
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0xe0, %ecx
jne 0xe5a7
movq $0x3, (%rsi)
movzbl (%rdi), %eax
andl $0xf, %eax
movzbl 0x1(%rdi), %ecx
andl $0x3f, %ecx
shll $0xc, %eax
shll $0x6, %ecx
orl %eax, %ecx
movzbl 0x2(%rdi), %eax
andl $0x3f, %eax
orl %ecx, %eax
retq
andl $-0x8, %eax
cmpl $0xf0, %eax
jne 0xe5e3
movq $0x4, (%rsi)
movzbl (%rdi), %eax
andl $0xf, %eax
movzbl 0x1(%rdi), %ecx
andl $0x3f, %ecx
shll $0xc, %eax
shll $0x6, %ecx
orl %eax, %ecx
movzbl 0x2(%rdi), %edx
andl $0x3f, %edx
orl %ecx, %edx
shll $0x6, %edx
movzbl 0x3(%rdi), %eax
andl $0x3f, %eax
orl %edx, %eax
retq
pushq $-0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_search_forward
CePoint_t ce_buffer_search_forward(CeBuffer_t* buffer, CePoint_t start, const char* pattern){
     CePoint_t result = (CePoint_t){-1, -1};

     if(!ce_buffer_point_is_valid(buffer, start)) return result;

     int64_t save_y = start.y;
     char* itr = ce_utf8_iterate_to(buffer->lines[start.y], start.x);
     char* match = NULL;

     // try to match the pattern on each line to the end
     while(true){
          match = strstr(itr, pattern);
          if(match) break;
          start.y++;
          if(start.y >= buffer->line_count) break;
          itr = buffer->lines[start.y];
     }

     if(match){
          // figure out index in the line
          int64_t index = 0;
          int64_t rune_len = 0;
          while(match > itr){
               ce_utf8_decode(itr, &rune_len);
               itr += rune_len;
               index++;
          }

          if(start.y == save_y){
               // if we are on the same line, use the starting x plus the index
               result.x = start.x + index;
          }else{
               result.x = index;
          }
          result.y = start.y;
     }

     return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %rbp
callq 0xe425
pushq $-0x1
popq %rcx
testq %rax, %rax
je 0xe69e
movq (%rbp), %rax
movq (%rax,%rbx,8), %rdi
movq %r14, 0x8(%rsp)
movq %r14, %rsi
callq 0xe4a6
movq %rax, %r12
movq %rbx, (%rsp)
leaq 0x1(%rbx), %r15
xorl %ebx, %ebx
movq %r12, %rdi
movq %r13, %rsi
callq 0xd6f0
testq %rax, %rax
jne 0xe65a
cmpq 0x8(%rbp), %r15
jge 0xe69b
movq (%rbp), %rax
movq (%rax,%r15,8), %r12
decq %rbx
incq %r15
jmp 0xe634
movq %rax, %r14
leaq 0x10(%rsp), %r15
andq $0x0, (%r15)
subq %rbx, (%rsp)
xorl %r13d, %r13d
cmpq %r12, %r14
jbe 0xe687
movq %r12, %rdi
movq %r15, %rsi
callq 0xe53f
addq 0x10(%rsp), %r12
incq %r13
jmp 0xe66d
xorl %ecx, %ecx
testq %rbx, %rbx
cmoveq 0x8(%rsp), %rcx
addq %r13, %rcx
movq (%rsp), %rdx
jmp 0xe6a1
pushq $-0x1
popq %rcx
movq %rcx, %rdx
movq %rcx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_search_backward
CePoint_t ce_buffer_search_backward(CeBuffer_t* buffer, CePoint_t start, const char* pattern){
     CePoint_t result = (CePoint_t){-1, -1};

     if(!ce_buffer_point_is_valid(buffer, start)) return result;

     char* beginning_of_line = buffer->lines[start.y];
     char* itr = ce_utf8_iterate_to(beginning_of_line, start.x);
     bool match = false;
     size_t pattern_len = strlen(pattern);

     // try to match the pattern on each line to the end
     while(true){
          while(itr > beginning_of_line){
               if(strncmp(itr, pattern, pattern_len) == 0){
                    match = true;
                    break;
               }

               itr--;
          }
          if(match) break;
          start.y--;
          if(start.y < 0) break;
          beginning_of_line = buffer->lines[start.y];
          itr = beginning_of_line + ce_utf8_last_index(beginning_of_line);
     }

     if(match){
          // figure out index in the line
          int64_t index = 0;
          int64_t rune_len = 0;
          while(itr > beginning_of_line){
               ce_utf8_decode(beginning_of_line, &rune_len);
               beginning_of_line += rune_len;
               index++;
          }

          result.x = index;
          result.y = start.y;
     }

     return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r15
callq 0xe425
pushq $-0x1
popq %r14
testq %rax, %rax
je 0xe76c
movq %r15, 0x8(%rsp)
movq (%r15), %rax
movq (%rax,%rbx,8), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0xe4a6
movq %rax, %rbp
movq %r12, %rdi
callq 0xd210
movq %rax, %r13
cmpq %r15, %rbp
jbe 0xe720
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xd0d0
testl %eax, %eax
je 0xe745
decq %rbp
jmp 0xe704
testq %rbx, %rbx
jle 0xe76c
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq -0x8(%rax,%rbx,8), %r15
decq %rbx
movq %r15, %rdi
callq 0xe784
movq %rax, %rbp
addq %r15, %rbp
jmp 0xe704
leaq 0x10(%rsp), %r12
andq $0x0, (%r12)
xorl %r14d, %r14d
cmpq %r15, %rbp
jbe 0xe76f
movq %r15, %rdi
movq %r12, %rsi
callq 0xe53f
addq 0x10(%rsp), %r15
incq %r14
jmp 0xe752
movq %r14, %rbx
movq %r14, %rax
movq %rbx, %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_regex_search_forward
CeRegexSearchResult_t ce_buffer_regex_search_forward(CeBuffer_t* buffer, CePoint_t start, CeRegex_t regex){
     CeRegexSearchResult_t result = {(CePoint_t){-1, -1}, -1};

     if(!ce_buffer_point_is_valid(buffer, start)) return result;

     while(start.y < buffer->line_count){
          CeRegexResult_t regex_result = ce_regex_match(regex,
                                                        buffer->lines[start.y] + start.x);
          if(regex_result.error_message != NULL){
               ce_log("ce_regex_match() failed: %s", regex_result.error_message);
               free(regex_result.error_message);
               break;
          }
          if(regex_result.match_start != CE_REGEX_NO_MATCH){
               result.point = start;
               result.point.x += regex_result.match_start;
               result.length = regex_result.match_length;
               break;
          }
          start.y++;
          start.x = 0;
     }

     return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %rbx
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rdi)
orq $-0x1, 0x10(%rdi)
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
callq 0xe425
testq %rax, %rax
je 0xe83c
movq %rsp, %rbp
cmpq 0x8(%r12), %r14
jge 0xe83c
movq (%r12), %rax
movq (%rax,%r14,8), %rdx
addq %r13, %rdx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1d69d
movq (%rsp), %rsi
testq %rsi, %rsi
jne 0xe810
movq 0x8(%rsp), %rax
cmpq $-0x1, %rax
jne 0xe829
incq %r14
xorl %r13d, %r13d
jmp 0xe7d7
leaq 0x1be38(%rip), %rdi     # 0x2a64f
xorl %eax, %eax
callq 0xd8e5
movq (%rsp), %rdi
callq 0xd090
jmp 0xe83c
movq %r14, 0x8(%rbx)
addq %r13, %rax
movq %rax, (%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_range_len
int64_t ce_buffer_range_len(CeBuffer_t* buffer, CePoint_t start, CePoint_t end){
     if(!ce_buffer_point_is_valid(buffer, start)) return -1;
     if(!ce_buffer_point_is_valid(buffer, end)) return -1;
     if(ce_point_after(start, end)) return -1; // TODO: calculate negative value?

     // easy case where they are on the same line
     if(start.y == end.y) return (end.x - start.x) + 1;

     int64_t length = 0;
     for(int64_t y = start.y; y <= end.y; ++y){
          if(y == start.y){
               // count from the star to the end of the line
               length = ce_utf8_strlen(ce_utf8_iterate_to(buffer->lines[y], start.x)) + 1;
          }else if(y == end.y){
               length += end.x + 1;
          }else{
               // count entire line
               int64_t line_length = ce_utf8_strlen(buffer->lines[y]) + 1;
               if(line_length == 0) length++;
               length += line_length;
          }
     }

     return length;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
callq 0xe425
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0xe9f0
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xe425
testq %rax, %rax
sete %al
cmpq %r12, %rbx
setl %cl
orb %al, %cl
jne 0xe9f0
cmpq %r12, %rbx
sete %cl
movq %r14, %rax
subq %r15, %rax
setl %dl
testb %dl, %cl
jne 0xe9f0
cmpq %r12, %rbx
jne 0xea02
incq %rax
movq %rax, %rbp
movq %rbp, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x10(%rsp)
incq %r14
movq %r14, 0x8(%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r12, %r15
cmpq %rbx, %r15
jg 0xe9f0
subq $0x1, %r14
jae 0xea44
movq (%r13), %rax
movq (%rax,%r12,8), %rdi
movq 0x10(%rsp), %rsi
callq 0xe4a6
movq %rax, %rdi
callq 0xe38c
movq %rax, %rbp
incq %rbp
jmp 0xea64
cmpq %r15, %rbx
jne 0xea50
addq 0x8(%rsp), %rbp
jmp 0xea64
movq (%r13), %rax
movq (%rax,%r15,8), %rdi
callq 0xe38c
addq $0x1, %rax
adcq %rax, %rbp
incq %r15
jmp 0xea17
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_move_point
CePoint_t ce_buffer_move_point(CeBuffer_t* buffer, CePoint_t point, CePoint_t delta, int64_t tab_width, CeClampX_t clamp_x){
     if(delta.y){
          CE_CLAMP(point.y, 0, (buffer->line_count - 1));

          // figure out where we are visibly (due to tabs being variable length)
          int64_t cur_visible_index = ce_util_string_index_to_visible_index(buffer->lines[point.y], point.x, tab_width);

          // move to the new line
          point.y += delta.y;

          // always clamp y
          CE_CLAMP(point.y, 0, (buffer->line_count - 1));

          // convert the x from visible index to a string index
          point.x = ce_util_visible_index_to_string_index(buffer->lines[point.y], cur_visible_index, tab_width);
     }

     point.x += delta.x;
     int64_t line_len = ce_buffer_line_len(buffer, point.y);

     switch(clamp_x){
     case CE_CLAMP_X_NONE:
          break;
     case CE_CLAMP_X_ON:
          CE_CLAMP(point.x, 0, line_len);
          break;
     case CE_CLAMP_X_INSIDE:
          if(line_len == 0){
               point.x = 0;
          }else{
               CE_CLAMP(point.x, 0, (line_len - 1));
          }
          break;
     }

     return point;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movl 0x40(%rsp), %r15d
testq %r8, %r8
je 0xeb24
movq %r9, %r13
movq %r8, %rbp
testq %rbx, %rbx
movq %rcx, (%rsp)
js 0xead6
movq 0x8(%r12), %rax
leaq -0x1(%rax), %r15
cmpq %rbx, %rax
cmovgq %rbx, %r15
jmp 0xead9
xorl %r15d, %r15d
movq (%r12), %rax
movq (%rax,%r15,8), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xeb75
addq %r15, %rbp
js 0xeb03
movq 0x8(%r12), %rcx
leaq -0x1(%rcx), %rbx
cmpq %rcx, %rbp
cmovlq %rbp, %rbx
jmp 0xeb05
xorl %ebx, %ebx
movl 0x40(%rsp), %r15d
movq (%r12), %rcx
movq (%rcx,%rbx,8), %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0xebd5
movq %rax, %r14
movq (%rsp), %rcx
addq %rcx, %r14
movq %r12, %rdi
movq %rbx, %rsi
callq 0xea7c
cmpl $0x2, %r15d
je 0xeb40
cmpl $0x1, %r15d
je 0xeb48
jmp 0xeb5b
testq %rax, %rax
je 0xeb70
decq %rax
cmpq %rax, %r14
cmovlq %r14, %rax
xorl %ecx, %ecx
testq %r14, %r14
cmovnsq %rax, %rcx
movq %rcx, %r14
movq %r14, %rax
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0xeb5b
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_util_string_index_to_visible_index
int64_t ce_util_string_index_to_visible_index(const char* string, int64_t index, int64_t tab_width){
     int64_t x = 0;
     int64_t rune_len = 0;
     CeRune_t rune = 1;

     while(rune > 0 && index > 0){
          rune = ce_utf8_decode(string, &rune_len);

          if(rune > 0){
               if(rune == CE_TAB){
                    x += tab_width;
               }else{
                    x++;
               }
          }else{
               x++;
          }

          string += rune_len;
          index--;
     }

     return x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rsp, %r15
andq $0x0, (%r15)
movq %rdi, %r12
pushq $0x1
popq %rax
xorl %r13d, %r13d
pushq $0x1
popq %rbp
testl %eax, %eax
jle 0xebc3
testq %r14, %r14
jle 0xebc3
movq %r12, %rdi
movq %r15, %rsi
callq 0xe53f
cmpl $0x9, %eax
movq %rbp, %rcx
cmoveq %rbx, %rcx
addq %rcx, %r13
addq (%rsp), %r12
decq %r14
jmp 0xeb99
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_util_visible_index_to_string_index
int64_t ce_util_visible_index_to_string_index(const char* string, int64_t index, int64_t tab_width){
     int64_t x = 0;
     int64_t rune_len = 0;
     CeRune_t rune = 1;

     while(rune > 0 && index > 0){
          rune = ce_utf8_decode(string, &rune_len);

          if(rune > 0){
               if(rune == CE_TAB){
                    index -= tab_width;
               }else{
                    index--;
               }
          }else{
               index--;
          }

          string += rune_len;
          x++;
     }

     return x;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
leaq 0x8(%rsp), %r14
andq $0x0, (%r14)
movq %rsi, %r15
movq %rdi, %r12
pushq $0x1
popq %rax
xorl %r13d, %r13d
testl %eax, %eax
jle 0xec29
testq %r15, %r15
jle 0xec29
movq %r12, %rdi
movq %r14, %rsi
callq 0xe53f
testl %eax, %eax
jle 0xec1c
cmpl $0x9, %eax
jne 0xec1c
subq %rbx, %r15
jmp 0xec1f
decq %r15
addq 0x8(%rsp), %r12
incq %r13
jmp 0xebfa
movq %r13, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_advance_point
CePoint_t ce_buffer_advance_point(CeBuffer_t* buffer, CePoint_t point, int64_t delta){
     if(!ce_buffer_point_is_valid(buffer, point)) return (CePoint_t){-1, -1};

     if(delta < 0){
          while(delta < 0){
               int64_t destination = point.x + delta;
               if(destination < 0){
                    // if we are already at the beginning of the buffer, get out
                    int64_t new_line = point.y - 1;
                    if(new_line < 0){
                         point.x = 0;
                         break;
                    }

                    // move to the previous line, add to the delta
                    if(point.x == 0){
                         delta += 1;
                    }else{
                         delta += point.x;
                    }
                    point.y = new_line;
                    point.x = ce_utf8_strlen(buffer->lines[point.y]);
               }else{
                    point.x = destination;
                    break;
               }
          }
     }else if(delta > 0){
          while(delta > 0){
               int64_t line_len = ce_utf8_strlen(buffer->lines[point.y]);
               int64_t destination = point.x + delta;
               if(destination > line_len){
                    // if we are already at the end of the buffer, get out
                    int64_t new_line = point.y + 1;
                    if(new_line >= buffer->line_count) break;

                    // move to the next line, and subtract from the delta
                    delta -= (line_len - point.x) + 1;
                    point.x = 0;
                    point.y = new_line;
               }else{
                    point.x = destination;
                    break;
               }
          }
     }

     return point;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
callq 0xe425
testq %rax, %rax
je 0xecc8
testq %r15, %r15
js 0xecc1
je 0xeccf
movq (%r12), %rax
movq (%rax,%rbx,8), %rdi
callq 0xe38c
addq %r14, %r15
cmpq %rax, %r15
jle 0xecdf
leaq 0x1(%rbx), %rcx
cmpq 0x8(%r12), %rcx
jge 0xeccf
notq %rax
addq %rax, %r15
movl $0x0, %r14d
movq %rcx, %rbx
testq %r15, %r15
jg 0xec60
jmp 0xeccf
movq %r14, %r13
addq %r15, %r13
jns 0xece4
testq %rbx, %rbx
jle 0xece9
incq %r15
movq (%r12), %rax
movq -0x8(%rax,%rbx,8), %rdi
decq %rbx
callq 0xe38c
testq %r14, %r14
cmovneq %r13, %r15
movq %rax, %r14
testq %r15, %r15
js 0xec96
jmp 0xeccf
pushq $-0x1
popq %r14
movq %r14, %rbx
movq %r14, %rax
movq %rbx, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %r15, %r14
jmp 0xeccf
movq %r13, %r14
jmp 0xeccf
xorl %r14d, %r14d
jmp 0xeccf
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_clamp_point
CePoint_t ce_buffer_clamp_point(CeBuffer_t* buffer, CePoint_t point, CeClampX_t clamp_x){
     switch(clamp_x){
     case CE_CLAMP_X_NONE:
          return point;
     case CE_CLAMP_X_ON:
          if(buffer->line_count){
               CE_CLAMP(point.y, 0, (buffer->line_count - 1));
               int64_t line_len = ce_utf8_strlen(buffer->lines[point.y]);
               CE_CLAMP(point.x, 0, line_len);
          }else{
               point.x = 0;
               point.y = 0;
          }
          break;
     case CE_CLAMP_X_INSIDE:
          if(buffer->line_count){
               CE_CLAMP(point.y, 0, (buffer->line_count - 1));
               int64_t line_len = ce_utf8_strlen(buffer->lines[point.y]);
               if(line_len){
                    CE_CLAMP(point.x, 0, (line_len - 1));
               }else{
                    point.x = 0;
               }
          }else{
               point.x = 0;
               point.y = 0;
          }
          break;
     }

     return point;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
cmpl $0x2, %ecx
je 0xed4e
cmpl $0x1, %ecx
jne 0xeda0
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0xed97
leaq -0x1(%rax), %r15
cmpq %r14, %rax
cmovgq %r14, %r15
xorl %r12d, %r12d
testq %r14, %r14
cmovsq %r12, %r15
movq (%rdi), %rax
movq (%rax,%r15,8), %rdi
callq 0xe38c
cmpq %rbx, %rax
cmovgeq %rbx, %rax
testq %rbx, %rbx
cmovsq %r12, %rax
movq %rax, %rbx
movq %r15, %r14
jmp 0xeda0
movq 0x8(%rdi), %rax
testq %rax, %rax
je 0xed97
leaq -0x1(%rax), %rcx
cmpq %r14, %rax
cmovgq %r14, %rcx
xorl %eax, %eax
testq %r14, %r14
movq %rcx, %r14
cmovsq %rax, %r14
movq (%rdi), %rax
movq (%rax,%r14,8), %rdi
callq 0xe38c
testq %rax, %rax
je 0xed9e
decq %rax
cmpq %rbx, %rax
cmovgeq %rbx, %rax
xorl %ecx, %ecx
testq %rbx, %rbx
cmovnsq %rax, %rcx
movq %rcx, %rbx
jmp 0xeda0
xorl %ebx, %ebx
xorl %r14d, %r14d
jmp 0xeda0
xorl %ebx, %ebx
movq %rbx, %rax
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: buffer_realloc_lines
static bool buffer_realloc_lines(CeBuffer_t* buffer, int64_t new_line_count){
     // if we want to realloc 0 lines, clear everything
     if(new_line_count == 0){
          free(buffer->lines);
          buffer->lines = NULL;
          buffer->line_count = 0;
          return true;
     }else if(new_line_count == buffer->line_count){
          return true;
     }

     buffer->lines = realloc(buffer->lines, new_line_count * sizeof(buffer->lines[0]));
     if(buffer->lines == NULL) return false;
     buffer->line_count = new_line_count;
     return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0xedf5
movq %rsi, %r15
movb $0x1, %bl
cmpq %rsi, 0x8(%r14)
je 0xee0a
movq (%r14), %rdi
leaq (,%r15,8), %rsi
callq 0xd520
movq %rax, (%r14)
testq %rax, %rax
je 0xee08
movq %r15, 0x8(%r14)
jmp 0xee0a
movq (%r14), %rdi
callq 0xd090
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movb $0x1, %bl
jmp 0xee0a
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_insert_rune
bool ce_buffer_insert_rune(CeBuffer_t* buffer, CeRune_t rune, CePoint_t point){
     char str[5];
     int64_t written = 0;
     ce_utf8_encode(rune, str, 5, &written);
     str[written] = 0;
     return ce_buffer_insert_string(buffer, str, point);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r15
leaq 0x8(%rsp), %r12
andq $0x0, (%r12)
leaq 0x3(%rsp), %r13
pushq $0x5
popq %rdx
movl %esi, %edi
movq %r13, %rsi
movq %r12, %rcx
callq 0xee6f
movq (%r12), %rax
movb $0x0, 0x3(%rsp,%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xd9ef
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_utf8_encode
bool ce_utf8_encode(CeRune_t u, char* string, int64_t string_len, int64_t* bytes_written){
     if(u < 0x80){
          if(string_len < 1) return false;
          *bytes_written = 1;

          // leave as-is
          string[0] = u;
     }else if(u < 0x0800){
          if(string_len < 2) return false;
          *bytes_written = 2;

          // u = 00000000 00000000 00000abc defghijk

          // 2 bytes
          // first byte:  110abcde
          string[0] = 0xC0 | ((u >> 6) & 0x1f);

          // second byte: 10fghijk
          string[1] = 0x80 | (u & 0x3f);
     }else if(u < 0x10000){
          if(string_len < 3) return false;
          *bytes_written = 3;

          // u = 00000000 00000000 abcdefgh ijklmnop

          // 3 bytes
          // first byte:  1110abcd
          string[0] = 0xE0 | ((u >> 12) & 0x0F);

          // second byte: 10efghij
          string[1] = 0x80 | ((u >> 6) & 0x3F);

          // third byte:  10klmnop
          string[2] = 0x80 | (u & 0x3F);
     }else if(u < 0x110000){
          if(string_len < 4) return false;
          *bytes_written = 4;

          // u = 00000000 000abcde fghijklm nopqrstu

          // 4 bytes
          // first byte:  11110abc
          string[0] = 0xF0 | ((u >> 18) & 0x07);
          // second byte: 10defghi
          string[1] = 0x80 | ((u >> 12) & 0x3F);
          // third byte:  10jklmno
          string[2] = 0x80 | ((u >> 6) & 0x3F);
          // fourth byte: 10pqrstu
          string[3] = 0x80 | (u & 0x3F);
     }

     return true;
}

// Assembly:
cmpl $0x7f, %edi
jg 0xee89
testq %rdx, %rdx
jle 0xeefe
movq $0x1, (%rcx)
movb %dil, (%rsi)
jmp 0xeeeb
cmpl $0x7ff, %edi            # imm = 0x7FF
ja 0xeeb5
cmpq $0x2, %rdx
jl 0xeefe
movq $0x2, (%rcx)
movl %edi, %eax
shrl $0x6, %eax
orb $-0x40, %al
movb %al, (%rsi)
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, 0x1(%rsi)
jmp 0xeeeb
cmpl $0xffff, %edi           # imm = 0xFFFF
ja 0xeeee
cmpq $0x3, %rdx
jl 0xeefe
movq $0x3, (%rcx)
movl %edi, %eax
shrl $0xc, %eax
orb $-0x20, %al
movb %al, (%rsi)
movl %edi, %eax
shrl $0x6, %eax
andb $0x3f, %al
orb $-0x80, %al
movb %al, 0x1(%rsi)
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, 0x2(%rsi)
movb $0x1, %al
retq
movb $0x1, %al
cmpl $0x10ffff, %edi         # imm = 0x10FFFF
ja 0xeeed
cmpq $0x4, %rdx
jge 0xef01
xorl %eax, %eax
retq
movq $0x4, (%rcx)
movl %edi, %ecx
shrl $0x12, %ecx
orb $-0x10, %cl
movb %cl, (%rsi)
movl %edi, %ecx
shrl $0xc, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
movb %cl, 0x1(%rsi)
movl %edi, %ecx
shrl $0x6, %ecx
andb $0x3f, %cl
orb $-0x80, %cl
movb %cl, 0x2(%rsi)
andb $0x3f, %dil
orb $-0x80, %dil
movb %dil, 0x3(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_remove_lines
bool ce_buffer_remove_lines(CeBuffer_t* buffer, int64_t line_start, int64_t lines_to_remove){
     // check invalid input
     if(line_start < 0) return false;
     if(line_start >= buffer->line_count) return false;
     if(lines_to_remove <= 0) return false;
     if(line_start + lines_to_remove > buffer->line_count) return false;

     // free lines we are going to remove and overwrite
     for(int64_t i = line_start; i < line_start + lines_to_remove; i++){
          free(buffer->lines[i]);
     }

     // shift lines down, overwriting lines we want to remove
     int64_t last_line_to_shift = buffer->line_count - lines_to_remove;
     for(int64_t dst = line_start; dst < last_line_to_shift; dst++){
          int64_t src = dst + lines_to_remove;
          buffer->lines[dst] = buffer->lines[src];
     }

     // update line count, and shrink our allocation
     buffer->line_count -= lines_to_remove;
     if(buffer->line_count > 0){
          buffer->lines = realloc(buffer->lines, buffer->line_count * sizeof(*buffer->lines));
     }else{
          ce_buffer_empty(buffer);
     }

     buffer->status = CE_BUFFER_STATUS_MODIFIED;
     return buffer->lines != NULL;
}

// Assembly:
testq %rsi, %rsi
js 0xf2e5
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rdi), %rax
cmpq %rsi, %rax
setle %cl
testq %rdx, %rdx
setle %dl
orb %cl, %dl
jne 0xf2e1
leaq (%r14,%r15), %r12
cmpq %rax, %r12
jbe 0xf2e8
xorl %eax, %eax
jmp 0xf357
xorl %eax, %eax
retq
movq %r15, %r13
cmpq %r12, %r13
jge 0xf301
movq (%rbx), %rax
movq (%rax,%r13,8), %rdi
callq 0xd090
incq %r13
jmp 0xf2eb
movq 0x8(%rbx), %rsi
subq %r14, %rsi
shlq $0x3, %r14
cmpq %rsi, %r15
jge 0xf325
movq (%rbx), %rax
leaq (%rax,%r15,8), %rcx
movq (%r14,%rcx), %rcx
movq %rcx, (%rax,%r15,8)
incq %r15
jmp 0xf30c
movq %rsi, 0x8(%rbx)
testq %rsi, %rsi
jle 0xf33f
movq (%rbx), %rdi
shlq $0x3, %rsi
callq 0xd520
movq %rax, (%rbx)
jmp 0xf34a
movq %rbx, %rdi
callq 0xe2e2
movq (%rbx), %rax
movl $0x1, 0x18(%rbx)
testq %rax, %rax
setne %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_dupe
char* ce_buffer_dupe(CeBuffer_t* buffer){
     CePoint_t start = {0, 0};
     CePoint_t end = {0, buffer->line_count};
     if(end.y) end.y--;
     end.x = ce_utf8_last_index(buffer->lines[end.y]);
     int64_t len = ce_buffer_range_len(buffer, start, end);
     if(len > 0) return ce_buffer_dupe_string(buffer, start, len);
     return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rax
movq 0x8(%rdi), %r14
xorl %ecx, %ecx
subq $0x1, %r14
cmovbq %rcx, %r14
movq (%rax,%r14,8), %rdi
callq 0xe784
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rax, %rcx
movq %r14, %r8
callq 0xe98a
testq %rax, %rax
jle 0xf5be
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %rax, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xf361
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_insert_string_change
bool ce_buffer_insert_string_change(CeBuffer_t* buffer, char* alloced_string, CePoint_t point, CePoint_t* cursor_before,
                                    CePoint_t cursor_after, bool chain_undo){
     if(!ce_buffer_insert_string(buffer, alloced_string, point)) return false;

     CeBufferChange_t change = {};
     change.chain = chain_undo;
     change.insertion = true;
     change.string = alloced_string;
     change.location = point;
     change.cursor_before = *cursor_before;
     change.cursor_after = cursor_after;
     ce_buffer_change(buffer, &change);

     *cursor_before = cursor_after;
     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, 0x4(%rsp)
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
callq 0xd9ef
movl %eax, %ebp
testb %al, %al
je 0xf63c
leaq 0x80(%rsp), %rcx
leaq 0x8(%rsp), %rsi
andq $0x0, (%rsi)
movl 0x4(%rsp), %eax
movb %al, (%rsi)
movb $0x1, 0x1(%rsi)
movq %r13, 0x8(%rsi)
movq %r12, 0x10(%rsi)
movq %r15, 0x18(%rsi)
movups (%rbx), %xmm0
movups %xmm0, 0x20(%rsi)
movq %rcx, %r15
movups (%rcx), %xmm0
movups %xmm0, 0x30(%rsi)
movq %r14, %rdi
callq 0xf64d
movups (%r15), %xmm0
movups %xmm0, (%rbx)
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_change
bool ce_buffer_change(CeBuffer_t* buffer, CeBufferChange_t* change){
     CeBufferChangeNode_t* node = calloc(1, sizeof(*node));
     node->change = *change;
     node->next = NULL;

     if(buffer->change_node){
          if(buffer->change_node->next){
               ce_buffer_change_node_free(&buffer->change_node->next);
          }

          node->prev = buffer->change_node;
          node->index = buffer->change_node->index + 1;
          buffer->change_node->next = node;
     }else{
          CeBufferChangeNode_t* first_empty_node = calloc(1, sizeof(*node));
          first_empty_node->next = node;
          node->prev = first_empty_node;
          if(buffer->save_at_change_node == NULL) buffer->save_at_change_node = first_empty_node;
     }

     buffer->change_node = node;
     return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
pushq $0x1
popq %rdi
pushq $0x58
popq %rsi
callq 0xd380
movq %rax, %r14
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups 0x30(%r15), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0xf6ba
cmpq $0x0, 0x40(%rdi)
je 0xf6a5
addq $0x40, %rdi
callq 0xde91
movq 0x40(%rbx), %rdi
movq %rdi, 0x48(%r14)
movq 0x50(%rdi), %rax
incq %rax
movq %rax, 0x50(%r14)
movq %r14, 0x40(%rdi)
jmp 0xf6d8
pushq $0x1
popq %rdi
pushq $0x58
popq %rsi
callq 0xd380
movq %r14, 0x40(%rax)
movq %rax, 0x48(%r14)
cmpq $0x0, 0x48(%rbx)
jne 0xf6d8
movq %rax, 0x48(%rbx)
movq %r14, 0x40(%rbx)
movb $0x1, %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce.c
// Function: ce_buffer_insert_string_change_at_cursor
bool ce_buffer_insert_string_change_at_cursor(CeBuffer_t* buffer, char* alloced_string, CePoint_t* cursor, bool chain_undo){
     if(!ce_buffer_insert_string(buffer, alloced_string, *cursor)) return false;
     CePoint_t cursor_after = ce_buffer_advance_point(buffer, *cursor, strlen(alloced_string));

     CeBufferChange_t change = {};
     change.chain = chain_undo;
     change.insertion = true;
     change.string = alloced_string;
     change.location = *cursor;
     change.cursor_before = *cursor;
     change.cursor_after = cursor_after;
     ce_buffer_change(buffer, &change);

     *cursor = cursor_after;
     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r12d
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdx), %rdx
movq 0x8(%rbx), %rcx
callq 0xd9ef
movl %eax, %ebp
testb %al, %al
je 0xf76b
movq %r15, %rdi
callq 0xd210
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
movq %rax, %rcx
callq 0xec3a
movq %rax, %r13
movl %r12d, %eax
movq %rdx, %r12
leaq 0x8(%rsp), %rsi
andq $0x0, (%rsi)
movb %al, (%rsi)
movb $0x1, 0x1(%rsi)
movq %r15, 0x8(%rsi)
movups (%rbx), %xmm0
movups %xmm0, 0x10(%rsi)
movups (%rbx), %xmm0
movups %xmm0, 0x20(%rsi)
movq %r13, 0x30(%rsi)
movq %rdx, 0x38(%rsi)
movq %r14, %rdi
callq 0xf64d
movq %r13, (%rbx)
movq %r12, 0x8(%rbx)
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq