// File: /workspace/github_cpp_makefile_star2_O2/establishment[P]sandman/src/cgroups.hpp
// Function: CGroups::prepare()
void prepare() {
        Base::Msg("Preparing control group %s\n", cgName.c_str());
        for (auto subsystem : cgAllSubSystems) {
            struct stat st;
            std::string path = getPath(subsystem, "");
            if (stat(path.c_str(), &st) >= 0 || errno != ENOENT) {
                Base::Msg("Control group %s already exists, trying to empty it.\n", path.c_str());
                if (rmdir(path.c_str()) < 0) {
                    Base::Die("Failed to reset control group %s: %m", path.c_str());
                }
            }

            if (mkdir(path.c_str(), 0777) < 0 && !subsystem.optional) {
                Base::Die("Failed to create control group %s: %m", path.c_str());
            }
        }

        /// If cpuset module is enabled, copy allowed cpus and memory nodes from parent group
        /// limits the cpus which can be used by target process
        /// usefull in a multi cored environment
        if (readStat(cgCpuset, "cpuset.cpus", true)) { /// try to read
            writeStat(cgCpuset, "cpuset.cpus", buffer); /// write what was just read
        }

        /// sets RAM nodes which this program can use
        /// can be specified to be the first 2 GB of ram for example
        if (readStat(cgCpuset, "cpuset.mems", true)) { /// try to read
            writeStat(cgCpuset, "cpuset.mems", buffer); /// write what was just read
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, %r13
movq (%rdi), %rsi
leaq 0xea7d(%rip), %rdi      # 0x5c689
xorl %eax, %eax
callq 0x3b443
leaq 0x18(%rsp), %r15
leaq 0x1b0(%rsp), %r12
leaq 0x60(%rsp), %rbp
leaq 0x40(%rsp), %rbx
leaq 0xeaaa(%rip), %rax      # 0x5c6db
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
cmpq $0x78, %r14
je 0x4dd12
leaq 0x26de6(%rip), %rax     # 0x74a30
leaq (%rax,%r14), %rsi
movq %r15, %rdi
callq 0x414c6
movq %r12, %rdi
movq %r15, %rsi
callq 0x414c6
movq %rbp, %rdi
leaq 0xd4dd(%rip), %rsi      # 0x5b148
leaq 0xf(%rsp), %rdx
callq 0x40b24
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x4442c
movq %rbp, %rdi
callq 0x37958
movq %r12, %rdi
callq 0x37958
movq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x373e0
testl %eax, %eax
jns 0x4dcb6
callq 0x37050
cmpl $0x2, (%rax)
je 0x4dcdb
movq 0x40(%rsp), %rsi
leaq 0xe9e3(%rip), %rdi      # 0x5c6a5
xorl %eax, %eax
callq 0x3b443
movq 0x40(%rsp), %rdi
callq 0x37190
testl %eax, %eax
js 0x4df10
movq 0x40(%rsp), %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x371d0
testl %eax, %eax
jns 0x4dcf9
cmpb $0x1, 0x38(%rsp)
jne 0x4df04
movq %rbx, %rdi
callq 0x37958
movq %r15, %rdi
callq 0x37958
addq $0x28, %r14
jmp 0x4dc39
leaq 0x26cef(%rip), %rsi     # 0x74a08
leaq 0x188(%rsp), %rdi
callq 0x414c6
leaq 0xe9f9(%rip), %rsi      # 0x5c726
leaq 0x80(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x40b24
leaq 0x188(%rsp), %rsi
leaq 0x80(%rsp), %rdx
pushq $0x1
popq %rcx
movq %r13, %rdi
callq 0x442f8
movl %eax, %ebx
leaq 0x80(%rsp), %rdi
callq 0x37958
leaq 0x188(%rsp), %rdi
callq 0x37958
testl %ebx, %ebx
je 0x4de02
leaq 0x26c83(%rip), %rsi     # 0x74a08
leaq 0x160(%rsp), %rdi
callq 0x414c6
leaq 0xe98d(%rip), %rsi      # 0x5c726
leaq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x40b24
leaq 0x28(%r13), %rsi
leaq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x40b24
leaq 0x160(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
xorl %r8d, %r8d
callq 0x4559c
leaq 0x18(%rsp), %rdi
callq 0x37958
leaq 0x80(%rsp), %rdi
callq 0x37958
leaq 0x160(%rsp), %rdi
callq 0x37958
leaq 0x26bff(%rip), %rsi     # 0x74a08
leaq 0x138(%rsp), %rdi
callq 0x414c6
leaq 0xe915(%rip), %rsi      # 0x5c732
leaq 0x80(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x40b24
leaq 0x138(%rsp), %rsi
leaq 0x80(%rsp), %rdx
pushq $0x1
popq %rcx
movq %r13, %rdi
callq 0x442f8
movl %eax, %ebx
leaq 0x80(%rsp), %rdi
callq 0x37958
leaq 0x138(%rsp), %rdi
callq 0x37958
testl %ebx, %ebx
je 0x4def2
leaq 0x26b93(%rip), %rsi     # 0x74a08
leaq 0x110(%rsp), %rdi
callq 0x414c6
leaq 0xe8a9(%rip), %rsi      # 0x5c732
leaq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x40b24
leaq 0x28(%r13), %rsi
leaq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x40b24
leaq 0x110(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r13, %rdi
xorl %r8d, %r8d
callq 0x4559c
leaq 0x18(%rsp), %rdi
callq 0x37958
leaq 0x80(%rsp), %rdi
callq 0x37958
leaq 0x110(%rsp), %rdi
callq 0x37958
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe7f5(%rip), %rax      # 0x5c700
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x3b2a4
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x37958
jmp 0x4df33
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x37958
jmp 0x4df45
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x4dff3
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x37958
jmp 0x4df64
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x37958
jmp 0x4df76
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
jmp 0x4dff3
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x37958
jmp 0x4df95
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x4dff3
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x37958
jmp 0x4dfb4
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
jmp 0x4dff3
jmp 0x4dfe1
movq %rax, %rbx
jmp 0x4dfd2
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x37958
leaq 0x1b0(%rsp), %rdi
jmp 0x4dfe9
movq %rax, %rbx
jmp 0x4dfee
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x37958
leaq 0x18(%rsp), %rdi
callq 0x37958
movq %rbx, %rdi
callq 0x377f0