// File: /workspace/github_c_makefile_star2_O0/silverneko[P]miku/isolate/isolate.c
// Function: set_quota
static void
set_quota(void)
{
  if (!block_quota)
    return;

  char cwd[PATH_MAX];
  if (!getcwd(cwd, sizeof(cwd)))
    die("getcwd: %m");

  char *dev = find_device(cwd);
  if (!dev)
    die("Cannot identify filesystem which contains %s", cwd);
  msg("Quota: Mapped path %s to a filesystem on %s\n", cwd, dev);

  // Sanity check
  struct stat dev_st, cwd_st;
  if (stat(dev, &dev_st) < 0)
    die("Cannot identify block device %s: %m", dev);
  if (!S_ISBLK(dev_st.st_mode))
    die("Expected that %s is a block device", dev);
  if (stat(".", &cwd_st) < 0)
    die("Cannot stat cwd: %m");
  if (cwd_st.st_dev != dev_st.st_rdev)
    die("Identified %s as a filesystem on %s, but it is obviously false", cwd, dev);

  struct dqblk dq = {
    .dqb_bhardlimit = block_quota,
    .dqb_bsoftlimit = block_quota,
    .dqb_ihardlimit = inode_quota,
    .dqb_isoftlimit = inode_quota,
    .dqb_valid = QIF_LIMITS,
  };
  if (quotactl(QCMD(Q_SETQUOTA, USRQUOTA), dev, box_uid, (caddr_t) &dq) < 0)
    die("Cannot set disk quota: %m");
  msg("Quota: Set block quota %d and inode quota %d\n", block_quota, inode_quota);

  free(dev);
}

// Assembly:
subq $0x1178, %rsp           # imm = 0x1178
cmpl $0x0, 0x5e0a(%rip)      # 0xa2e8
jne 0x44e5
jmp 0x46b9
leaq 0x170(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x2260
cmpq $0x0, %rax
jne 0x450b
leaq 0x2ef0(%rip), %rdi      # 0x73f4
movb $0x0, %al
callq 0x2ed0
leaq 0x170(%rsp), %rdi
callq 0x49c0
movq %rax, 0x168(%rsp)
cmpq $0x0, 0x168(%rsp)
jne 0x4541
leaq 0x170(%rsp), %rsi
leaq 0x2ec5(%rip), %rdi      # 0x73ff
movb $0x0, %al
callq 0x2ed0
leaq 0x170(%rsp), %rsi
movq 0x168(%rsp), %rdx
leaq 0x2ed4(%rip), %rdi      # 0x742c
movb $0x0, %al
callq 0x4090
movq 0x168(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x2320
cmpl $0x0, %eax
jge 0x458f
movq 0x168(%rsp), %rsi
leaq 0x2ed1(%rip), %rdi      # 0x7459
movb $0x0, %al
callq 0x2ed0
movl 0xf0(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x6000, %eax           # imm = 0x6000
je 0x45b8
movq 0x168(%rsp), %rsi
leaq 0x2ecc(%rip), %rdi      # 0x747d
movb $0x0, %al
callq 0x2ed0
leaq 0x2ee1(%rip), %rdi      # 0x74a0
leaq 0x48(%rsp), %rsi
callq 0x2320
cmpl $0x0, %eax
jge 0x45dc
leaq 0x2ecd(%rip), %rdi      # 0x74a2
movb $0x0, %al
callq 0x2ed0
movq 0x48(%rsp), %rax
cmpq 0x100(%rsp), %rax
je 0x4609
leaq 0x170(%rsp), %rsi
movq 0x168(%rsp), %rdx
leaq 0x2eb4(%rip), %rdi      # 0x74b6
movb $0x0, %al
callq 0x2ed0
movslq 0x5cd8(%rip), %rax      # 0xa2e8
movq %rax, (%rsp)
movslq 0x5ccd(%rip), %rax      # 0xa2e8
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movslq 0x5cbc(%rip), %rax      # 0xa2ec
movq %rax, 0x18(%rsp)
movslq 0x5cb0(%rip), %rax      # 0xa2ec
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movl $0x5, 0x40(%rsp)
movq 0x168(%rsp), %rsi
movl 0x5e06(%rip), %edx      # 0xa478
movl $0x80000800, %edi       # imm = 0x80000800
movq %rsp, %rcx
callq 0x2150
cmpl $0x0, %eax
jge 0x4692
leaq 0x2e6a(%rip), %rdi      # 0x74f5
movb $0x0, %al
callq 0x2ed0
movl 0x5c50(%rip), %esi      # 0xa2e8
movl 0x5c4e(%rip), %edx      # 0xa2ec
leaq 0x2e6a(%rip), %rdi      # 0x750f
movb $0x0, %al
callq 0x4090
movq 0x168(%rsp), %rdi
callq 0x2030
addq $0x1178, %rsp           # imm = 0x1178
retq
nopw %cs:(%rax,%rax)