// File: /workspace/github_c_makefile_star2_O0/wuxb45[P]SLB/lib1.c
// Function: skiplist_set
bool
skiplist_set(struct skiplist * const list, const struct kv * const kv)
{
  const struct kv * const newkv = kv_alloc_dup(kv, &(list->mm));
  u64 h = list->height - 1;
  struct skipnode * path[64];
  struct skipnode * left = &(list->n0);
  struct skipnode * right = NULL;
  while (h < 64) { // h >= 0
    while (left->next[h]) {
      right = left->next[h];
      struct kv * const curr = __u64_to_ptr(right->e.ptr);
      debug_assert(curr);
      const int cmp = list->comp(newkv, curr);
      if (cmp == 0) {
        kvmap_put_entry(&(list->mm), &(right->e), newkv);
        return true;
      } else if (cmp < 0) {
        break;
      } else {
        left = right;
      }
    }
    path[h] = left;
    h--;
  }
  // insert
  const double r = random_double();
  h = 0;
  while (r < list->factors[h]) h++;
  const u64 height = h;
  if (height > list->height) {
    for (u64 i = list->height; i < height; i++) {
      path[i] = &(list->n0);
    }
    list->height = height;
  }
  const u64 nodesize = sizeof(list->n0) + (sizeof(list->n0.next[0]) * height);
  struct skipnode * const newnode = (typeof(newnode))malloc(nodesize);
  if (newnode == NULL) {
    if (list->mm.rf) {
      list->mm.rf((struct kv *)newkv, list->mm.rp);
    }
    return false;
  }
  newnode->e.ptr = 0;
  kvmap_put_entry(&(list->mm), &(newnode->e), newkv);
  for (u64 i = 0; i < height; i++) {
    newnode->next[i] = path[i]->next[i];
    path[i]->next[i] = newnode;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xf860
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x258(%rax), %rax
subq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x260, %rax            # imm = 0x260
movq %rax, -0x238(%rbp)
movq $0x0, -0x240(%rbp)
cmpq $0x40, -0x28(%rbp)
jae 0x12203
jmp 0x12120
movq -0x238(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
je 0x121df
movq -0x238(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rax
movq (%rax), %rdi
shrq $0x10, %rdi
callq 0xf220
movq %rax, -0x248(%rbp)
cmpq $0x0, -0x248(%rbp)
setne %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x7640
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x20(%rbp), %rdi
movq -0x248(%rbp), %rsi
callq *%rax
movl %eax, -0x24c(%rbp)
cmpl $0x0, -0x24c(%rbp)
jne 0x121bf
movq -0x10(%rbp), %rdi
movq -0x240(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x11390
movb $0x1, -0x1(%rbp)
jmp 0x123cf
cmpl $0x0, -0x24c(%rbp)
jge 0x121ca
jmp 0x121df
movq -0x240(%rbp), %rax
movq %rax, -0x238(%rbp)
jmp 0x121da
jmp 0x12120
movq -0x238(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x230(%rbp,%rax,8)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x12113
callq 0xb270
vmovsd %xmm0, -0x258(%rbp)
movq $0x0, -0x28(%rbp)
vmovsd -0x258(%rbp), %xmm1
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
vmovsd 0x58(%rax,%rcx,8), %xmm0
vucomisd %xmm1, %xmm0
jbe 0x12242
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x12218
movq -0x28(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x258(%rcx), %rax
jbe 0x122c3
movq -0x10(%rbp), %rax
movq 0x258(%rax), %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rax
cmpq -0x260(%rbp), %rax
jae 0x122b1
movq -0x10(%rbp), %rcx
addq $0x260, %rcx            # imm = 0x260
movq -0x268(%rbp), %rax
movq %rcx, -0x230(%rbp,%rax,8)
movq -0x268(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x268(%rbp)
jmp 0x12273
movq -0x260(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x258(%rax)
movq -0x260(%rbp), %rax
shlq $0x3, %rax
addq $0x8, %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rdi
callq 0x6380
movq %rax, -0x278(%rbp)
cmpq $0x0, -0x278(%rbp)
jne 0x12320
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x12317
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rsi
callq *%rax
movb $0x0, -0x1(%rbp)
jmp 0x123cf
movq -0x278(%rbp), %rax
movq (%rax), %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
orq $0x0, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x278(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x11390
movq $0x0, -0x280(%rbp)
movq -0x280(%rbp), %rax
cmpq -0x260(%rbp), %rax
jae 0x123cb
movq -0x280(%rbp), %rax
movq -0x230(%rbp,%rax,8), %rax
movq -0x280(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rdx
movq -0x278(%rbp), %rax
movq -0x280(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x278(%rbp), %rdx
movq -0x280(%rbp), %rax
movq -0x230(%rbp,%rax,8), %rax
movq -0x280(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x280(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x280(%rbp)
jmp 0x12357
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
nopl (%rax)