// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rsi, -0x20(%rbp)
movq %rdx, -0x18(%rbp)
movq %rdi, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xeba0
cmpq $0x0, %rax
jne 0xfb34
movq $-0x1, -0x10(%rbp)
movq $-0x1, -0x8(%rbp)
jmp 0xfc81
cmpq $0x0, -0x30(%rbp)
jge 0xfbd3
jmp 0xfb41
cmpq $0x0, -0x30(%rbp)
jge 0xfbce
movq -0x20(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jge 0xfbbf
movq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jge 0xfb7c
movq $0x0, -0x20(%rbp)
jmp 0xfbce
cmpq $0x0, -0x20(%rbp)
jne 0xfb91
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xfb9d
movq -0x20(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xea70
movq %rax, -0x20(%rbp)
jmp 0xfbc9
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xfbce
jmp 0xfb41
jmp 0xfc71
cmpq $0x0, -0x30(%rbp)
jle 0xfc6f
jmp 0xfbe0
cmpq $0x0, -0x30(%rbp)
jle 0xfc6d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xea70
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jle 0xfc5e
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jl 0xfc35
jmp 0xfc6d
movq -0x48(%rbp), %rcx
subq -0x20(%rbp), %rcx
addq $0x1, %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0xfc68
movq -0x50(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xfc6d
jmp 0xfbe0
jmp 0xfc6f
jmp 0xfc71
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x60, %rsp
popq %rbp
retq
nop