// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
movq (%rdi), %rsi
leaq 0x1007e(%rip), %rdi     # 0x566bc
xorl %eax, %eax
callq 0x2cfe4
leaq 0x98(%rsp), %r14
leaq 0x243dc(%rip), %rbx     # 0x6aa30
leaq 0x60(%rsp), %r12
leaq 0xeb28(%rip), %r13      # 0x55188
leaq 0x88(%rsp), %rbp
leaq 0x1009f(%rip), %rax     # 0x5670e
movq %rax, 0x30(%rsp)
xorl %r15d, %r15d
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq (%r15,%rbx), %rsi
movq 0x8(%r15,%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x47a78
movb 0x20(%r15,%rbx), %al
movb %al, 0x28(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x47a78
movb 0x28(%rsp), %al
movb %al, 0x80(%rsp)
movq %r14, 0x88(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
movq %r13, %rdx
callq 0x43424
leaq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x3a162
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x46712
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x4672e
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x40(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x273f0
testl %eax, %eax
jns 0x4674e
callq 0x27050
cmpl $0x2, (%rax)
je 0x46773
movq 0x40(%rsp), %rsi
leaq 0xff7e(%rip), %rdi      # 0x566d8
xorl %eax, %eax
callq 0x2cfe4
movq 0x40(%rsp), %rdi
callq 0x271c0
testl %eax, %eax
js 0x46b5b
movq 0x40(%rsp), %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x271f0
testl %eax, %eax
jns 0x46791
cmpb $0x1, 0x28(%rsp)
jne 0x46b4f
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x467ad
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x467c9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
addq $0x28, %r15
cmpq $0x78, %r15
jne 0x46677
leaq 0x1c0(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x2421e(%rip), %rsi     # 0x6aa08
movq 0x2421f(%rip), %rdx     # 0x6aa10
addq %rsi, %rdx
leaq 0x1b0(%rsp), %rbx
movq %rbx, %rdi
callq 0x47a78
movb 0x2421e(%rip), %al      # 0x6aa28
movb %al, 0x20(%rbx)
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xff39(%rip), %rsi      # 0x56759
leaq 0xff3d(%rip), %rdx      # 0x56764
leaq 0xa8(%rsp), %rdi
callq 0x43424
leaq 0x1b0(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
movq 0x38(%rsp), %r13
movq %r13, %rdi
movl $0x1, %ecx
callq 0x39fd6
movl %eax, %ebx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46875
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x1b0(%rsp), %rdi
cmpq %r14, %rdi
je 0x46892
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x27480
testl %ebx, %ebx
je 0x46991
leaq 0x198(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x2415a(%rip), %rsi     # 0x6aa08
movq 0x2415b(%rip), %rdx     # 0x6aa10
addq %rsi, %rdx
leaq 0x188(%rsp), %rbx
movq %rbx, %rdi
callq 0x47a78
movb 0x2415a(%rip), %al      # 0x6aa28
movb %al, 0x20(%rbx)
leaq 0xa8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0xfe76(%rip), %rsi      # 0x56759
leaq 0xfe7a(%rip), %rdx      # 0x56764
callq 0x43424
leaq 0x28(%r13), %rbx
leaq 0x8(%rsp), %r14
leaq 0x18(%rsp), %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x271e0
leaq (%rax,%r13), %rdx
addq $0x28, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x43424
leaq 0x188(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
xorl %r8d, %r8d
callq 0x3bbe6
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x46957
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46974
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x188(%rsp), %rdi
cmpq %r12, %rdi
je 0x46991
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x27480
leaq 0x170(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x24064(%rip), %rsi     # 0x6aa08
movq 0x24065(%rip), %rdx     # 0x6aa10
addq %rsi, %rdx
leaq 0x160(%rsp), %rbx
movq %rbx, %rdi
callq 0x47a78
movb 0x24064(%rip), %al      # 0x6aa28
movb %al, 0x20(%rbx)
leaq 0xa8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0xfd8c(%rip), %rsi      # 0x56765
leaq 0xfd90(%rip), %rdx      # 0x56770
callq 0x43424
leaq 0x160(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
movq %r13, %rdi
movl $0x1, %ecx
callq 0x39fd6
movl %eax, %ebx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46a21
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x160(%rsp), %rdi
cmpq %r14, %rdi
je 0x46a3e
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x27480
testl %ebx, %ebx
je 0x46b3d
leaq 0x148(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x23fae(%rip), %rsi     # 0x6aa08
movq 0x23faf(%rip), %rdx     # 0x6aa10
addq %rsi, %rdx
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
callq 0x47a78
movb 0x23fae(%rip), %al      # 0x6aa28
movb %al, 0x20(%rbx)
leaq 0xa8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0xfcd6(%rip), %rsi      # 0x56765
leaq 0xfcda(%rip), %rdx      # 0x56770
callq 0x43424
leaq 0x28(%r13), %rbx
leaq 0x8(%rsp), %r14
leaq 0x18(%rsp), %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x271e0
leaq (%rax,%r13), %rdx
addq $0x28, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x43424
leaq 0x138(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %r13, %rdi
xorl %r8d, %r8d
callq 0x3bbe6
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x46b03
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46b20
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x46b3d
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x27480
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfbdd(%rip), %rax      # 0x56733
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rsi
movq 0x30(%rsp), %rdi
xorl %eax, %eax
callq 0x2ce45
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x46b90
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x46b90
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46bb2
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x46bb2
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x46d34
movq 0x148(%rsp), %rsi
jmp 0x46d2c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x46bf4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x46bf4
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46c16
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x46c16
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r12, %rdi
je 0x46d34
movq 0x198(%rsp), %rsi
jmp 0x46d2c
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46c59
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x46c59
movq %rax, %rbx
movq 0x160(%rsp), %rdi
cmpq %r14, %rdi
je 0x46d34
movq 0x170(%rsp), %rsi
jmp 0x46d2c
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x46c9c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x46c9c
movq %rax, %rbx
movq 0x1b0(%rsp), %rdi
cmpq %r14, %rdi
je 0x46d34
movq 0x1c0(%rsp), %rsi
jmp 0x46d2c
jmp 0x46cf9
movq %rax, %rbx
jmp 0x46d18
movq %rax, %rbx
jmp 0x46ce3
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x46ce3
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x46d18
movq 0x70(%rsp), %rsi
jmp 0x46d10
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x46d18
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x46d34
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
movq %rbx, %rdi
callq 0x27830