// File: /workspace/github_cpp_makefile_star2_O2/establishment[P]sandman/src/cgroups.hpp
// Function: CGroups::writeStat(CGroups::CGSubsystem, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
int writeStat(CGSubsystem subsystem, const std::string& parameter, const std::string& value, bool maybe=false) {
        int success = 0;
        ssize_t writeSize = 0;

        Base::Msg(2, "CG: Write %s = %s\n", parameter.c_str(), value.c_str());

        std::string path = getPath(subsystem, parameter);

        /// check file descriptor
        int fd = open(path.c_str(), O_WRONLY | O_TRUNC);
        if (fd < 0) {
            if (maybe) {
                goto fail;
            } else {
                Base::Die("Cannot write %s: %m", path.c_str());
            }
        }

        /// write and sanity check
        writeSize = write(fd, value.c_str(), value.size());
        if (writeSize < 0) {
            if (maybe) {
                goto fail_close;
            } else {
                Base::Die("Cannot set %s to %s: %m", path.c_str(), value.c_str());
            }
        }

        if (writeSize != (ssize_t)value.size()) {
            Base::Die("Short write to %s (%zd out of %zu bytes) err:%m", path.c_str(), writeSize, value.size());
        }

        success = 1;
        fail_close:
        if (success == 0) {
            Base::Msg(2, "Failed to write %s=%s\n", path.c_str(), value.c_str());
        }
        close(fd);
        fail:

        return success;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r8d, %ebp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r13
movq (%rdx), %rdx
movq (%rcx), %rcx
leaq 0x16b19(%rip), %rsi     # 0x5c0df
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x3b38c
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x414c6
movq %rsp, %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x4442c
leaq 0x20(%rsp), %rdi
callq 0x37958
movq (%rsp), %rdi
movl $0x201, %esi            # imm = 0x201
xorl %eax, %eax
callq 0x37340
movl %eax, %r15d
testl %eax, %eax
js 0x45638
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movl %r15d, %edi
callq 0x37130
testq %rax, %rax
js 0x45652
movq 0x8(%r14), %rcx
cmpq %rcx, %rax
jne 0x45694
pushq $0x1
popq %r14
jmp 0x45672
xorl %r14d, %r14d
testb %bpl, %bpl
jne 0x4567a
movq (%rsp), %rsi
leaq 0x16aa7(%rip), %rdi     # 0x5c0f2
xorl %eax, %eax
callq 0x3b2a4
movq (%rsp), %rdx
movq (%r14), %rcx
testb %bpl, %bpl
je 0x456a9
xorl %r14d, %r14d
leaq 0x16ae6(%rip), %rsi     # 0x5c14e
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x3b38c
movl %r15d, %edi
callq 0x37920
movq %rsp, %rdi
callq 0x37958
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rsi
leaq 0x16a7f(%rip), %rdi     # 0x5c11e
movq %rax, %rdx
xorl %eax, %eax
callq 0x3b2a4
xorl %eax, %eax
testq %rcx, %rcx
setne %al
leaq 0x16a4e(%rip), %rdi     # 0x5c106
movq %rdx, %rsi
movl %eax, %edx
callq 0x3af9f
movq %rax, %r14
movq %r15, %rbx
jmp 0x456cd
movq %rax, %r14
movq %rbx, %rdi
callq 0x37958
movq %r14, %rdi
callq 0x377f0
nop