// File: /workspace/github_c_makefile_star2_O0/silverneko[P]miku/isolate/isolate.c
// Function: apply_dir_rules
static void apply_dir_rules(void)
{
  for (struct dir_rule *r = first_dir_rule; r; r=r->next)
    {
      char *in = r->inside;
      char *out = r->outside;
      if (!out)
	{
	  msg("Not binding anything on %s\n", r->inside);
	  continue;
	}

      if ((r->flags & DIR_FLAG_MAYBE) && !dir_exists(out))
	{
	  msg("Not binding %s on %s (does not exist)\n", out, r->inside);
	  continue;
	}

      char root_in[1024];
      snprintf(root_in, sizeof(root_in), "root/%s", in);
      make_dir(root_in);

      unsigned long mount_flags = 0;
      if (!(r->flags & DIR_FLAG_RW))
	mount_flags |= MS_RDONLY;
      if (r->flags & DIR_FLAG_NOEXEC)
	mount_flags |= MS_NOEXEC;
      if (!(r->flags & DIR_FLAG_DEV))
	mount_flags |= MS_NODEV;

      if (r->flags & DIR_FLAG_FS)
	{
	  msg("Mounting %s on %s (flags %lx)\n", out, in, mount_flags);
	  if (mount("none", root_in, out, mount_flags, "") < 0)
	    die("Cannot mount %s on %s: %m", out, in);
	}
      else
	{
	  mount_flags |= MS_BIND | MS_NOSUID;
	  msg("Binding %s on %s (flags %lx)\n", out, in, mount_flags);
	  // Most mount flags need remount to work
	  if (mount(out, root_in, "none", mount_flags, "") < 0 ||
	      mount(out, root_in, "none", MS_REMOUNT | mount_flags, "") < 0)
	    die("Cannot mount %s on %s: %m", out, in);
	}
    }
}

// Assembly:
subq $0x428, %rsp            # imm = 0x428
movq 0x4d62(%rip), %rax      # 0xa320
movq %rax, 0x420(%rsp)
cmpq $0x0, 0x420(%rsp)
je 0x584f
movq 0x420(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x418(%rsp)
movq 0x420(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x410(%rsp)
cmpq $0x0, 0x410(%rsp)
jne 0x5625
movq 0x420(%rsp), %rax
movq (%rax), %rsi
leaq 0x20c6(%rip), %rdi      # 0x76df
movb $0x0, %al
callq 0x4090
jmp 0x5836
movq 0x420(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5670
movq 0x410(%rsp), %rdi
callq 0x42d0
cmpl $0x0, %eax
jne 0x5670
movq 0x410(%rsp), %rsi
movq 0x420(%rsp), %rax
movq (%rax), %rdx
leaq 0x2097(%rip), %rdi      # 0x76fb
movb $0x0, %al
callq 0x4090
jmp 0x5836
leaq 0x10(%rsp), %rdi
movq 0x418(%rsp), %rcx
movl $0x400, %esi            # imm = 0x400
leaq 0x2099(%rip), %rdx      # 0x7722
movb $0x0, %al
callq 0x2210
leaq 0x10(%rsp), %rdi
callq 0x4210
movq $0x0, 0x8(%rsp)
movq 0x420(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x56c4
movq 0x8(%rsp), %rax
orq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x420(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x56e5
movq 0x8(%rsp), %rax
orq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x420(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x5706
movq 0x8(%rsp), %rax
orq $0x4, %rax
movq %rax, 0x8(%rsp)
movq 0x420(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x5789
movq 0x410(%rsp), %rsi
movq 0x418(%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x1ff5(%rip), %rdi      # 0x772a
movb $0x0, %al
callq 0x4090
leaq 0x10(%rsp), %rsi
movq 0x410(%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x1f19(%rip), %rdi      # 0x766e
leaq 0x21c4(%rip), %r8       # 0x7920
callq 0x2190
cmpl $0x0, %eax
jge 0x5784
movq 0x410(%rsp), %rsi
movq 0x418(%rsp), %rdx
leaq 0x1fcc(%rip), %rdi      # 0x7749
movb $0x0, %al
callq 0x2ed0
jmp 0x5834
movq 0x8(%rsp), %rax
orq $0x1002, %rax           # imm = 0x1002
movq %rax, 0x8(%rsp)
movq 0x410(%rsp), %rsi
movq 0x418(%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x1fae(%rip), %rdi      # 0x7763
movb $0x0, %al
callq 0x4090
movq 0x410(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rcx
leaq 0x1e99(%rip), %rdx      # 0x766e
leaq 0x2144(%rip), %r8       # 0x7920
callq 0x2190
cmpl $0x0, %eax
jl 0x5814
movq 0x410(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rcx
orq $0x20, %rcx
leaq 0x1e6b(%rip), %rdx      # 0x766e
leaq 0x2116(%rip), %r8       # 0x7920
callq 0x2190
cmpl $0x0, %eax
jge 0x5832
movq 0x410(%rsp), %rsi
movq 0x418(%rsp), %rdx
leaq 0x1f1e(%rip), %rdi      # 0x7749
movb $0x0, %al
callq 0x2ed0
jmp 0x5834
jmp 0x5836
movq 0x420(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x420(%rsp)
jmp 0x55c6
addq $0x428, %rsp            # imm = 0x428
retq
nopw (%rax,%rax)