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

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

        int fd = open(path.c_str(), O_RDONLY);
        if (fd < 0) {
            if (maybe) {
                goto fail;
            }
            Base::Die("Cannot read %s: %m", path.c_str());
        }

        readSize = read(fd, buffer, kCGBufferSize);

        /// check read
        if (readSize < 0) {
            if (maybe) {
                goto fail_close;
            }
            Base::Die("Cannot read %s: %m", path.c_str());
        }

        if (readSize >= kCGBufferSize - 1) {
            Base::Die("Attribute %s too long", path.c_str());
        }

        /// erase \n from answer
        if (readSize > 0 && buffer[readSize - 1] == '\n') {
            readSize -= 1;
        }

        /// set end of read
        buffer[readSize] = 0;

        Base::Msg(2, "CG: Read '%s' = '%s'\n", parameter.c_str(), buffer);

        success = 1;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %r15d
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x30(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rsi), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x47420
movb 0x20(%r12), %al
movb %al, 0x20(%r13)
movq %rsp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x39ad2
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x399b2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x27480
movq (%rsp), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x27350
movl %eax, %ebp
testl %eax, %eax
js 0x399f7
addq $0x28, %rbx
movl $0x1000, %edx           # imm = 0x1000
movl %ebp, %edi
movq %rbx, %rsi
callq 0x276c0
testl %eax, %eax
js 0x39a0b
cmpl $0xfff, %eax            # imm = 0xFFF
jae 0x39a85
testl %eax, %eax
je 0x39a2c
leal -0x1(%rax), %ecx
cmpb $0xa, (%rbx,%rcx)
cmovel %ecx, %eax
jmp 0x39a2e
xorl %r14d, %r14d
testb %r15b, %r15b
jne 0x39a58
leaq 0x1c5a7(%rip), %rdi     # 0x55fad
jmp 0x39a8c
movq (%rsp), %rdx
testb %r15b, %r15b
je 0x39a92
xorl %r14d, %r14d
leaq 0x1c5ce(%rip), %rsi     # 0x55fec
movl $0x2, %edi
xorl %eax, %eax
callq 0x2ce37
jmp 0x39a51
xorl %eax, %eax
movb $0x0, (%rbx,%rax)
movq (%r14), %rdx
movl $0x1, %r14d
leaq 0x1c594(%rip), %rsi     # 0x55fd6
movl $0x2, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2ce37
movl %ebp, %edi
callq 0x27930
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x39a73
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x27480
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c534(%rip), %rdi     # 0x55fc0
movq (%rsp), %rdx
jmp 0x39a99
leaq 0x1c514(%rip), %rdi     # 0x55fad
movq %rdx, %rsi
xorl %eax, %eax
callq 0x2cd4f
movq %rax, %rbx
movq 0x20(%rsp), %rdi
jmp 0x39ab9
movq %rax, %rbx
leaq 0x10(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x39aca
movq (%rbp), %rsi
incq %rsi
callq 0x27480
movq %rbx, %rdi
callq 0x27830