// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movq (%rdx), %rdx
movq (%rcx), %rcx
leaq 0x1a500(%rip), %rsi     # 0x56112
movl $0x2, %edi
xorl %eax, %eax
callq 0x2cf2d
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x47a78
movb 0x20(%r12), %al
movb %al, 0x20(%r13)
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x3a162
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3bc73
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x27480
movq 0x10(%rsp), %rdi
movl $0x201, %esi            # imm = 0x201
xorl %eax, %eax
callq 0x27350
movl %eax, %r14d
testl %eax, %eax
js 0x3bcc4
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl %r14d, %edi
callq 0x27160
testq %rax, %rax
js 0x3bce1
movq 0x8(%rbx), %rcx
movl $0x1, %r15d
cmpq %rcx, %rax
je 0x3bceb
movq 0x10(%rsp), %rsi
leaq 0x1a497(%rip), %rdi     # 0x56151
movq %rax, %rdx
xorl %eax, %eax
callq 0x2ce45
xorl %r15d, %r15d
cmpb $0x0, 0xc(%rsp)
jne 0x3bd13
movq 0x10(%rsp), %rsi
leaq 0x1a44b(%rip), %rdi     # 0x56125
xorl %eax, %eax
callq 0x2ce45
xorl %r15d, %r15d
cmpb $0x0, 0xc(%rsp)
je 0x3bd40
testq %rax, %rax
jns 0x3bd0b
movq 0x10(%rsp), %rdx
movq (%rbx), %rcx
leaq 0x1a482(%rip), %rsi     # 0x56181
movl $0x2, %edi
xorl %eax, %eax
callq 0x2cf2d
movl %r14d, %edi
callq 0x27930
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bd2e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x27480
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rsi
xorl %edx, %edx
cmpq $0x0, (%rbx)
setne %dl
leaq 0x1a3e4(%rip), %rdi     # 0x56139
callq 0x2c889
movq %rax, %rbx
movq 0x30(%rsp), %rdi
jmp 0x3bd70
movq %rax, %rbx
leaq 0x20(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x3bd81
movq (%rbp), %rsi
incq %rsi
callq 0x27480
movq %rbx, %rdi
callq 0x27830