// File: /workspace/github_c_makefile_star2_O0/justy989[P]ce/ce_app.c
// Function: extract_completion_from_response
CeComplete_t* _extract_completion_from_response(CeJsonObj_t* obj, CePoint_t* start){
     CeComplete_t* result = NULL;

     CeJsonFindResult_t result_find = ce_json_obj_find(obj, "result");
     if(result_find.type != CE_JSON_TYPE_OBJECT){
          return result;
     }

     // TODO: check isIncomplete

     CeJsonObj_t* result_obj = ce_json_obj_get_obj(obj, &result_find);

     CeJsonFindResult_t items_find = ce_json_obj_find(result_obj, "items");
     if(items_find.type != CE_JSON_TYPE_ARRAY){
          return result;
     }

     CeJsonArray_t* items_array = ce_json_obj_get_array(result_obj, &items_find);
     if(items_array == NULL){
          return result;
     }

     int64_t completion_count = 0;
     char** completions = NULL;
     char** descriptions = NULL;

     for(int64_t i = 0; i < items_array->count; i++){
          CeJsonValue_t* value = items_array->values + i;
          if(value->type != CE_JSON_TYPE_OBJECT){
               continue;
          }

          CeJsonFindResult_t insert_text_find = ce_json_obj_find(&value->obj, "insertText");
          if(insert_text_find.type != CE_JSON_TYPE_STRING){
               continue;
          }

          CeJsonFindResult_t detail_find = ce_json_obj_find(&value->obj, "detail");

          char* completion = strdup(ce_json_obj_get_string(&value->obj, &insert_text_find));


          CeJsonFindResult_t label_find = ce_json_obj_find(&value->obj, "label");

          char* description = NULL;
          if(label_find.type == CE_JSON_TYPE_STRING){
               int64_t completion_len = strlen(completion);
               char* match = strstr(ce_json_obj_get_string(&value->obj, &label_find),
                                    completion);
               if(match && strlen(match + completion_len) > 0){
                    char buffer[BUFSIZ];
                    if(detail_find.type == CE_JSON_TYPE_STRING){
                         snprintf(buffer, BUFSIZ, "%s%s",
                                  ce_json_obj_get_string(&value->obj, &detail_find),
                                  match + completion_len);
                    }else{
                         snprintf(buffer, BUFSIZ, "%s", match + completion_len);
                    }
                    description = strdup(buffer);
               }else if(detail_find.type == CE_JSON_TYPE_STRING){
                    description = strdup(ce_json_obj_get_string(&value->obj, &detail_find));
               }
          }else{
               description = strdup(ce_json_obj_get_string(&value->obj, &detail_find));
          }

          int64_t new_completion_count = completion_count + 1;
          completions = realloc(completions, new_completion_count * sizeof(completions[0]));
          descriptions = realloc(descriptions, new_completion_count * sizeof(descriptions[0]));
          completions[completion_count] = completion;
          descriptions[completion_count] = description;
          completion_count = new_completion_count;

          CeJsonFindResult_t text_edit_find = ce_json_obj_find(&value->obj, "textEdit");
          if(text_edit_find.type != CE_JSON_TYPE_OBJECT){
               continue;
          }
          CeJsonObj_t* text_edit_obj = ce_json_obj_get_obj(&value->obj, &text_edit_find);
          if(text_edit_obj == NULL){
               continue;
          }
          CeJsonFindResult_t range_find = ce_json_obj_find(text_edit_obj, "range");
          if(range_find.type != CE_JSON_TYPE_OBJECT){
               continue;
          }
          CeJsonObj_t* range_obj = ce_json_obj_get_obj(text_edit_obj, &range_find);
          if(range_obj == NULL){
               continue;
          }
          CeJsonFindResult_t start_find = ce_json_obj_find(range_obj, "start");
          if(start_find.type != CE_JSON_TYPE_OBJECT){
               continue;
          }
          CeJsonObj_t* start_obj = ce_json_obj_get_obj(range_obj, &start_find);
          if(start_obj == NULL){
               continue;
          }
          CeJsonFindResult_t line_find = ce_json_obj_find(start_obj, "line");
          if(line_find.type != CE_JSON_TYPE_NUMBER){
               continue;
          }
          CeJsonFindResult_t character_find = ce_json_obj_find(start_obj, "character");
          if(character_find.type != CE_JSON_TYPE_NUMBER){
               continue;
          }
          start->x = *ce_json_obj_get_number(start_obj, &character_find);
          start->y = *ce_json_obj_get_number(start_obj, &line_find);
     }

     result = malloc(sizeof(*result));
     memset(result, 0, sizeof(*result));
     ce_complete_init(result, (const char**)completions, (const char**)descriptions, completion_count);
     for(int64_t i = 0; i < completion_count; i++){
          free(completions[i]);
          free(descriptions[i]);
     }
     free(completions);
     free(descriptions);
     return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2150, %rsp           # imm = 0x2150
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x2d954(%rip), %rsi     # 0x43b6a
callq 0x25e70
movl %eax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
cmpl $0x1, -0x30(%rbp)
je 0x16235
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1679f
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x25f10
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x2d920(%rip), %rsi     # 0x43b71
callq 0x25e70
movl %eax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
cmpl $0x2, -0x48(%rbp)
je 0x16270
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1679f
movq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x25f60
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x16295
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1679f
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x166fe
movq -0x50(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x70(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x1, (%rax)
je 0x162e8
jmp 0x166ed
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq 0x2d880(%rip), %rsi     # 0x43b77
callq 0x25e70
movl %eax, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
cmpl $0x3, -0x88(%rbp)
je 0x16314
jmp 0x166ed
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq 0x2d85f(%rip), %rsi     # 0x43b82
callq 0x25e70
movl %eax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq -0x88(%rbp), %rsi
callq 0x25fb0
movq %rax, %rdi
callq 0xd620
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq 0x2d822(%rip), %rsi     # 0x43b89
callq 0x25e70
movl %eax, -0xb0(%rbp)
movq %rdx, -0xa8(%rbp)
movq $0x0, -0xb8(%rbp)
cmpl $0x3, -0xb0(%rbp)
jne 0x164be
movq -0xa0(%rbp), %rdi
callq 0xd200
movq %rax, -0xc0(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x25fb0
movq %rax, %rdi
movq -0xa0(%rbp), %rsi
callq 0xd6d0
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
je 0x1648e
movq -0xc8(%rbp), %rdi
addq -0xc0(%rbp), %rdi
callq 0xd200
cmpq $0x0, %rax
jbe 0x1648e
cmpl $0x3, -0x98(%rbp)
jne 0x16451
leaq -0x20d0(%rbp), %rax
movq %rax, -0x2150(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq -0x98(%rbp), %rsi
callq 0x25fb0
movq -0x2150(%rbp), %rdi
movq %rax, %rcx
movq -0xc8(%rbp), %r8
addq -0xc0(%rbp), %r8
movl $0x2000, %esi           # imm = 0x2000
leaq 0x2d747(%rip), %rdx     # 0x43b8f
movb $0x0, %al
callq 0xd250
jmp 0x16479
leaq -0x20d0(%rbp), %rdi
movq -0xc8(%rbp), %rcx
addq -0xc0(%rbp), %rcx
movl $0x2000, %esi           # imm = 0x2000
leaq 0x2f768(%rip), %rdx     # 0x45bda
movb $0x0, %al
callq 0xd250
leaq -0x20d0(%rbp), %rdi
callq 0xd620
movq %rax, -0xb8(%rbp)
jmp 0x164bc
cmpl $0x3, -0x98(%rbp)
jne 0x164ba
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq -0x98(%rbp), %rsi
callq 0x25fb0
movq %rax, %rdi
callq 0xd620
movq %rax, -0xb8(%rbp)
jmp 0x164bc
jmp 0x164e1
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq -0x98(%rbp), %rsi
callq 0x25fb0
movq %rax, %rdi
callq 0xd620
movq %rax, -0xb8(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20d8(%rbp)
movq -0x60(%rbp), %rdi
movq -0x20d8(%rbp), %rsi
shlq $0x3, %rsi
callq 0xd500
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rdi
movq -0x20d8(%rbp), %rsi
shlq $0x3, %rsi
callq 0xd500
movq %rax, -0x68(%rbp)
movq -0xa0(%rbp), %rdx
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xb8(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20d8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq 0x2d634(%rip), %rsi     # 0x43b94
callq 0x25e70
movl %eax, -0x20e8(%rbp)
movq %rdx, -0x20e0(%rbp)
cmpl $0x1, -0x20e8(%rbp)
je 0x16580
jmp 0x166ed
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
leaq -0x20e8(%rbp), %rsi
callq 0x25f10
movq %rax, -0x20f0(%rbp)
cmpq $0x0, -0x20f0(%rbp)
jne 0x165aa
jmp 0x166ed
movq -0x20f0(%rbp), %rdi
leaq 0x2d5e5(%rip), %rsi     # 0x43b9d
callq 0x25e70
movl %eax, -0x2100(%rbp)
movq %rdx, -0x20f8(%rbp)
cmpl $0x1, -0x2100(%rbp)
je 0x165d8
jmp 0x166ed
movq -0x20f0(%rbp), %rdi
leaq -0x2100(%rbp), %rsi
callq 0x25f10
movq %rax, -0x2108(%rbp)
cmpq $0x0, -0x2108(%rbp)
jne 0x16601
jmp 0x166ed
movq -0x2108(%rbp), %rdi
leaq 0x2c056(%rip), %rsi     # 0x42665
callq 0x25e70
movl %eax, -0x2118(%rbp)
movq %rdx, -0x2110(%rbp)
cmpl $0x1, -0x2118(%rbp)
je 0x1662f
jmp 0x166ed
movq -0x2108(%rbp), %rdi
leaq -0x2118(%rbp), %rsi
callq 0x25f10
movq %rax, -0x2120(%rbp)
cmpq $0x0, -0x2120(%rbp)
jne 0x16658
jmp 0x166ed
movq -0x2120(%rbp), %rdi
leaq 0x2c608(%rip), %rsi     # 0x42c6e
callq 0x25e70
movl %eax, -0x2130(%rbp)
movq %rdx, -0x2128(%rbp)
cmpl $0x4, -0x2130(%rbp)
je 0x16683
jmp 0x166ed
movq -0x2120(%rbp), %rdi
leaq 0x2d512(%rip), %rsi     # 0x43ba3
callq 0x25e70
movl %eax, -0x2140(%rbp)
movq %rdx, -0x2138(%rbp)
cmpl $0x4, -0x2140(%rbp)
je 0x166ae
jmp 0x166ed
movq -0x2120(%rbp), %rdi
leaq -0x2140(%rbp), %rsi
callq 0x26000
cvttsd2si (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x2120(%rbp), %rdi
leaq -0x2130(%rbp), %rsi
callq 0x26000
cvttsd2si (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x162b5
movl $0x20, %edi
callq 0xd4a0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0xd290
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x220d0
movq $0x0, -0x2148(%rbp)
movq -0x2148(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x16785
movq -0x60(%rbp), %rax
movq -0x2148(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xd090
movq -0x68(%rbp), %rax
movq -0x2148(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xd090
movq -0x2148(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2148(%rbp)
jmp 0x1673c
movq -0x60(%rbp), %rdi
callq 0xd090
movq -0x68(%rbp), %rdi
callq 0xd090
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2150, %rsp           # imm = 0x2150
popq %rbp
retq
nopl (%rax)