// File: /workspace/github_c_makefile_star2_O3/google[P]multichase/arena.c
// Function: alloc_arena_mmap
void *alloc_arena_mmap(size_t page_size, bool use_thp, size_t arena_size, int fd) {
  void *arena;
  size_t pagemask = page_size - 1;
  int flags;

  if (fd == -1)
    flags = MAP_PRIVATE | MAP_ANONYMOUS | get_page_size_flags(page_size);
  else
    flags = MAP_SHARED;

  arena_size = (arena_size + pagemask) & ~pagemask;
  arena = mmap(0, arena_size, PROT_READ | PROT_WRITE, flags, fd, 0);
  if (arena == MAP_FAILED) {
    perror("mmap");
    exit(1);
  }

  if (use_thp && fd == -1)
    check_thp_state();

  /* Explicitly disable THP for small pages. */
  if (!page_size_is_huge(page_size) && fd == -1) {
    if (madvise(arena, arena_size, use_thp ? MADV_HUGEPAGE : MADV_NOHUGEPAGE)) {
      perror("madvise");
    }
  } else if (use_thp) {
    fprintf(stderr,
            "Can't use transparent hugepages with a non-native page size.\n");
    exit(1);
  }

  if (is_weighted_mbind) {
    arena_weighted_mbind(page_size, arena, arena_size, mbind_weights,
                         MAX_MEM_NODES);
  }
  return arena;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r12d
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rbx
leaq -0x1(%rdi), %r13
movl $0x1, %ecx
cmpl $-0x1, %r12d
jne 0x408e8d
movq %rbx, %rax
xorq %r13, %rax
cmpq %r13, %rax
jbe 0x4091ec
callq 0x408d38
movl $0x22, %ecx
cmpq %rbx, %rax
jae 0x408e8d
movl $0x40022, %ecx          # imm = 0x40022
cmpq $0x2, %rbx
jb 0x408e8d
bsrq %rbx, %rcx
shll $0x1a, %ecx
orl $0x40022, %ecx          # imm = 0x40022
addq %r14, %r13
movq %rbx, %r15
negq %r15
andq %r13, %r15
xorl %edi, %edi
movq %r15, %rsi
movl $0x3, %edx
movl %r12d, %r8d
xorl %r9d, %r9d
callq 0x467dc0
movq %rax, 0x8(%rsp)
cmpq $-0x1, %rax
je 0x4091b9
cmpl $-0x1, %r12d
setne %al
movl %ebp, %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0x408f76
leaq 0xca4be(%rip), %rdi     # 0x4d3396
callq 0x40920a
movq %rax, %r14
leaq 0xca4db(%rip), %rdi     # 0x4d33c2
callq 0x40920a
movq %rax, %r13
leaq 0xca4f7(%rip), %rsi     # 0x4d33ed
movq %r14, %rdi
callq 0x4010b8
testl %eax, %eax
je 0x408f21
leaq 0xca4ed(%rip), %rsi     # 0x4d33f6
movq %r14, %rdi
callq 0x4010b8
testl %eax, %eax
je 0x408f21
leaq 0xca47a(%rip), %rdi     # 0x4d3396
callq 0x4092ca
leaq 0xca4c5(%rip), %rsi     # 0x4d33ed
movq %r13, %rdi
callq 0x4010b8
testl %eax, %eax
je 0x408f66
leaq 0xca4c5(%rip), %rsi     # 0x4d3400
movq %r13, %rdi
callq 0x4010b8
testl %eax, %eax
je 0x408f66
leaq 0xca4a8(%rip), %rsi     # 0x4d33f6
movq %r13, %rdi
callq 0x4010b8
testl %eax, %eax
je 0x408f66
leaq 0xca461(%rip), %rdi     # 0x4d33c2
callq 0x4092ca
movq %r14, %rdi
callq 0x436200
movq %r13, %rdi
callq 0x436200
cmpl $-0x1, %r12d
setne %r14b
callq 0x408d38
cmpq %rbx, %rax
setb %al
orb %r14b, %al
jne 0x408fb4
movzbl %bpl, %edx
xorl $0xf, %edx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x467e80
testl %eax, %eax
je 0x408fbd
leaq 0xca36a(%rip), %rdi     # 0x4d3317
callq 0x413f10
jmp 0x408fbd
testb %bpl, %bpl
jne 0x4091e7
movq $0x50b314, %rax         # imm = 0x50B314
cmpl $0x0, (%rax)
je 0x40919b
movl $0x200, %edi            # imm = 0x200
callq 0x435ec0
testq %rax, %rax
je 0x4091be
movq %rax, %r12
movq $0x50b320, %rax         # imm = 0x50B320
movzwl (%rax), %ecx
decq %rcx
movq %rcx, (%r12)
movl $0x1, %edx
movzwl (%rax,%rdx,2), %esi
addq %rsi, %rcx
movq %rcx, (%r12,%rdx,8)
incq %rdx
cmpq $0x40, %rdx
jne 0x408ff9
movq 0x1f8(%r12), %r13
movq $0x0, 0x20(%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x437310
movq %rax, %r14
movq $-0x60, %rax
movq %r14, %fs:(%rax)
movl $0x1, %edi
movl $0x30, %esi
callq 0x437310
movq $-0x58, %rbp
movq %rax, %fs:(%rbp)
testq %rax, %rax
je 0x4091c3
movl $0x20, %edx
movl $0x1, %edi
movq %r14, %rsi
movq %rax, %rcx
callq 0x4130a0
testl %eax, %eax
jne 0x4091e2
testq %r15, %r15
jle 0x409193
movq 0x8(%rsp), %rax
movq %rax, %r14
addq %r15, %r14
incl %r13d
movslq %r13d, %r15
movq %rax, %r13
movq %fs:(%rbp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x413340
testl %eax, %eax
jne 0x4091af
movq %fs:(%rbp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x413340
testl %eax, %eax
jne 0x4091af
movq %fs:(%rbp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x413340
testl %eax, %eax
jne 0x4091af
movq %fs:(%rbp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x413340
testl %eax, %eax
jne 0x4091af
movzwl 0x1c(%rsp), %eax
movl 0x18(%rsp), %ecx
shll $0x10, %ecx
orq %rax, %rcx
movl 0x14(%rsp), %eax
movzwl %ax, %eax
shlq $0x20, %rax
orq %rcx, %rax
movl 0x10(%rsp), %ecx
shlq $0x30, %rcx
orq %rax, %rcx
movq %rcx, %rax
subq $-0x7fffffff, %rax      # imm = 0x80000001
cmovbq %rcx, %rax
xorl %edx, %edx
divq %r15
movl %edx, %eax
xorl %ecx, %ecx
cmpq %rax, (%r12,%rcx,8)
jge 0x409147
incq %rcx
cmpq $0x40, %rcx
jne 0x409133
movl $0x40, %ecx
movl $0x1, %eax
shll %cl, %eax
cltq
movq %rax, 0x20(%rsp)
movl $0x1, (%rsp)
movl $0xed, %edi
movl $0x40, %r9d
movq %r13, %rsi
movq %rbx, %rdx
movl $0x2, %ecx
leaq 0x20(%rsp), %r8
xorl %eax, %eax
callq 0x467d80
testl %eax, %eax
jne 0x4091b4
movb $0x0, (%r13)
addq %rbx, %r13
cmpq %r14, %r13
jb 0x409099
movq %r12, %rdi
callq 0x436200
movq 0x8(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4012f5
callq 0x40130a
callq 0x401344
callq 0x40131f
leaq 0xc9dd7(%rip), %rdi     # 0x4d2fa1
leaq 0xc9ddb(%rip), %rsi     # 0x4d2fac
leaq 0xc9de4(%rip), %rcx     # 0x4d2fbc
movl $0x5d, %edx
callq 0x40c5b0
callq 0x4012e0
callq 0x4012bb
movq %rbx, %rdi
callq 0x401297