// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rsi, %r15
movq %rdi, %r14
movl 0x8(%rsi), %eax
movl 0xc(%rsi), %ecx
leaq (%rax,%rcx), %r12
addq $0x10, %r12
movq 0x8(%rdi), %rsi
movq %r12, %rdi
callq *(%r14)
testq %rax, %rax
movq %rax, -0x30(%rbp)
je 0xf481
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6340
movq -0x30(%rbp), %rdx
movq 0x258(%r14), %r13
leaq 0x260(%r14), %r12
decq %r13
cmpq $0x3f, %r13
ja 0xf336
movq %rdx, %rax
shlq $0x10, %rax
movq %rax, -0x38(%rbp)
movq %r12, %rbx
movq %r12, -0x40(%rbp)
movq 0x8(%rbx,%r13,8), %r12
testq %r12, %r12
je 0xf30d
movq (%r12), %r15
cmpq $0xffff, %r15           # imm = 0xFFFF
jbe 0xf328
shrq $0x10, %r15
movq %rdx, %rdi
movq %r15, %rsi
callq *0x50(%r14)
testl %eax, %eax
je 0xf281
js 0xf275
movq %r12, %rbx
sarl $0x1f, %eax
andl $0x5, %eax
movq -0x30(%rbp), %rdx
jmp 0xf2fc
movq (%r12), %rdi
cmpq $0x10000, %rdi          # imm = 0x10000
movq -0x30(%rbp), %rdx
jb 0xf2c3
shrq $0x10, %rdi
testq %rdx, %rdx
je 0xf2b0
movq 0x40(%r14), %rax
testq %rax, %rax
je 0xf2b0
movq 0x48(%r14), %rdx
movq -0x30(%rbp), %rsi
callq *%rax
jmp 0xf2bf
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xf2c3
movq 0x18(%r14), %rsi
callq *%rax
movq -0x30(%rbp), %rdx
movzwl (%r12), %eax
orq -0x38(%rbp), %rax
movq %rax, (%r12)
testq %rdx, %rdx
je 0xf2ed
movq (%rdx), %rax
movq %rax, %rcx
shrq $0x20, %rcx
xorl %eax, %ecx
movl %ecx, %eax
shrl $0x10, %eax
xorl %ecx, %eax
movzwl %ax, %eax
jmp 0xf2ef
xorl %eax, %eax
orq -0x38(%rbp), %rax
movq %rax, (%r12)
movl $0x1, %eax
testl %eax, %eax
je 0xf23f
cmpl $0x5, %eax
jne 0xf422
movq %rbx, -0x250(%rbp,%r13,8)
decq %r13
cmpq $0x40, %r13
movq -0x40(%rbp), %r12
jb 0xf23f
jmp 0xf336
callq 0x66ef
movq -0x30(%rbp), %rdx
jmp 0xf25e
movq %fs:-0x8, %rax
testq %rax, %rax
jne 0xf360
leaq -0x50(%rbp), %r15
movl $0x4, %edi
movq %r15, %rsi
callq 0x6110
imulq $0x3b9aca00, (%r15), %rax # imm = 0x3B9ACA00
addq 0x8(%r15), %rax
movq %rax, %rcx
shrq $0xc, %rcx
xorq %rax, %rcx
movq %rcx, %rax
shlq $0x19, %rax
xorq %rcx, %rax
movq %rax, %rcx
shrq $0x1b, %rcx
xorq %rax, %rcx
movabsq $0x2545f4914f6cdd1d, %rax # imm = 0x2545F4914F6CDD1D
imulq %rcx, %rax
movq %rax, %fs:-0x8
vcvtusi2sd %rax, %xmm0, %xmm0
vmulsd 0x5cdd(%rip), %xmm0, %xmm0 # 0x15080
movl $0x1, %ebx
xorl %edi, %edi
vmovsd 0x58(%r14,%rdi), %xmm1
decq %rbx
addq $0x8, %rdi
vucomisd %xmm0, %xmm1
ja 0xf3aa
movq 0x258(%r14), %rax
movq %rbx, %r15
negq %r15
cmpq %rax, %r15
jbe 0xf3e7
movq %r12, -0x250(%rbp,%rax,8)
incq %rax
cmpq %rax, %r15
jne 0xf3d0
movq %r15, 0x258(%r14)
callq 0x63a0
testq %rax, %rax
je 0xf426
movzwl (%rax), %edx
movq -0x30(%rbp), %rsi
movq %rsi, %rcx
shlq $0x10, %rcx
orq %rcx, %rdx
movq %rdx, (%rax)
testq %rsi, %rsi
je 0xf43d
movq (%rsi), %rdx
movq %rdx, %rsi
shrq $0x20, %rsi
xorl %edx, %esi
movl %esi, %edx
shrl $0x10, %edx
xorl %esi, %edx
movzwl %dx, %edx
jmp 0xf43f
movb $0x1, %cl
jmp 0xf46d
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xf439
movq 0x18(%r14), %rsi
movq -0x30(%rbp), %rdi
callq *%rax
xorl %ecx, %ecx
jmp 0xf46d
xorl %edx, %edx
orq %rcx, %rdx
movq %rdx, (%rax)
movb $0x1, %cl
testq %rbx, %rbx
je 0xf46d
xorl %edx, %edx
movq -0x250(%rbp,%rdx,8), %rsi
movq 0x8(%rsi,%rdx,8), %rdi
movq %rdi, 0x8(%rax,%rdx,8)
movq %rax, 0x8(%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %r15
jne 0xf44e
movl %ecx, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x66ef
movq -0x30(%rbp), %rax
jmp 0xf200