// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movl %r8d, 0xc(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r12
movq (%rdx), %rdx
movq (%rcx), %rcx
leaq 0x1ab90(%rip), %rsi     # 0x56112
movl $0x2, %edi
xorl %eax, %eax
callq 0x2ce37
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
callq 0x47420
movb 0x20(%r13), %al
movb %al, 0x20(%rbp)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x39ad2
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3b5e0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x10(%rsp), %rdi
movl $0x201, %esi            # imm = 0x201
xorl %eax, %eax
callq 0x27350
movl %eax, %ebp
testl %eax, %eax
js 0x3b62f
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movl %ebp, %edi
callq 0x27160
testq %rax, %rax
js 0x3b64c
movq 0x8(%r14), %rcx
movl $0x1, %r14d
cmpq %rcx, %rax
je 0x3b671
movq 0x10(%rsp), %rsi
leaq 0x1ab2c(%rip), %rdi     # 0x56151
movq %rax, %rdx
xorl %eax, %eax
callq 0x2cd4f
xorl %r14d, %r14d
cmpb $0x0, 0xc(%rsp)
jne 0x3b678
movq 0x10(%rsp), %rsi
leaq 0x1aae0(%rip), %rdi     # 0x56125
xorl %eax, %eax
callq 0x2cd4f
movq 0x10(%rsp), %rdx
movq (%r14), %rcx
cmpb $0x0, 0xc(%rsp)
je 0x3b6a5
xorl %r14d, %r14d
leaq 0x1ab1c(%rip), %rsi     # 0x56181
movl $0x2, %edi
xorl %eax, %eax
callq 0x2ce37
movl %ebp, %edi
callq 0x27930
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b693
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x27480
movl %r14d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testq %rcx, %rcx
setne %al
leaq 0x1aa85(%rip), %rdi     # 0x56139
movq %rdx, %rsi
movl %eax, %edx
callq 0x2c78f
movq %rax, %r14
movq 0x30(%rsp), %rdi
jmp 0x3b6d4
movq %rax, %r14
leaq 0x20(%rsp), %rbx
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0x3b6e4
movq (%rbx), %rsi
incq %rsi
callq 0x27480
movq %r14, %rdi
callq 0x27830