// File: /workspace/github_c_makefile_star2_O0/wuxb45[P]SLB/lib1.c
// Function: icache_create
struct icache *
icache_create(const struct kvmap_mm * const mm, const u64 nr_mb)
{
  debug_assert(ICACHE_ENTRY_NR == 15 || ICACHE_ENTRY_NR == 7);
  debug_assert((sizeof(struct __icache_slot) % 64) == 0);
  debug_assert((sizeof(struct __icache_hist) % 8) == 0);

  struct icache * const cache = (typeof(cache))malloc(sizeof(*cache));
  memset(cache, 0, sizeof(*cache));
  cache->mm = mm ? (*mm) : __kvmap_mm_default;
  for (u64 i = 0; i < KVMAP_HLOCK_NR; i++) {
    spinlock_init(&(cache->hlocks[i]));
  }
  const u64 table_size = nr_mb << 20;
  const u64 nr_slots = table_size / sizeof(cache->table[0]);
  struct __icache_slot * const table = pages_alloc_best(table_size, false, &(cache->slots_alloc_size));
  if (table == NULL) {
    free(cache);
    return NULL;
  }
  debug_assert(nr_slots % KVMAP_HLOCK_NR == 0);
  cache->table = table;
  cache->nr_slots = nr_slots;

  const u64 nr_hists = nr_slots * 16;
  const u64 hists_size = nr_hists * sizeof(cache->hists[0]);
  struct __icache_hist * const hists = pages_alloc_best(hists_size, false, &(cache->hists_alloc_size));
  if (hists == NULL) {
    pages_unmap(table, cache->slots_alloc_size);
    free(cache);
    return NULL;
  }

  cache->nr_hists = nr_hists;
  cache->hists = hists;
  return cache;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, %edi
callq 0x7640
movl $0x1, %edi
callq 0x7640
movl $0x1, %edi
callq 0x7640
movl $0x10158, %edi          # imm = 0x10158
callq 0x6380
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x10158, %edx          # imm = 0x10158
callq 0x6200
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xe92f
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x50, %edx
callq 0x6320
jmp 0xe944
movq -0x60(%rbp), %rdi
leaq 0x1344e(%rip), %rsi     # 0x21d88
movl $0x50, %edx
callq 0x6320
movq $0x0, -0x28(%rbp)
cmpq $0x400, -0x28(%rbp)     # imm = 0x400
jae 0xe97f
movq -0x20(%rbp), %rdi
addq $0xe0, %rdi
movq -0x28(%rbp), %rax
shlq $0x6, %rax
addq %rax, %rdi
callq 0x6e30
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xe94c
movq -0x18(%rbp), %rax
shlq $0x14, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
shrq $0x6, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0x10128, %rdx          # imm = 0x10128
xorl %esi, %esi
callq 0x8d40
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe9ce
movq -0x20(%rbp), %rdi
callq 0x6060
movq $0x0, -0x8(%rbp)
jmp 0xea8e
movq -0x38(%rbp), %rax
andq $0x3ff, %rax            # imm = 0x3FF
cmpq $0x0, %rax
sete %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x7640
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10130(%rax)
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10120(%rax)
movq -0x38(%rbp), %rax
shlq $0x4, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x4, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0x10140, %rdx          # imm = 0x10140
xorl %esi, %esi
callq 0x8d40
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xea68
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10128(%rax), %rsi
callq 0x8c10
movq -0x20(%rbp), %rdi
callq 0x6060
movq $0x0, -0x8(%rbp)
jmp 0xea8e
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10138(%rax)
movq -0x58(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10148(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)