// File: /workspace/github_cpp_makefile_star2_O1/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 0x47a78
movb 0x20(%r12), %al
movb %al, 0x20(%r13)
movq %rsp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x3a162
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3a042
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 0x3a091
addq $0x28, %rbx
movl $0x1000, %edx           # imm = 0x1000
movl %ebp, %edi
movq %rbx, %rsi
callq 0x276c0
movq %rax, %r12
testl %r12d, %r12d
js 0x3a09b
cmpl $0xfff, %r12d           # imm = 0xFFF
jge 0x3a121
testl %r12d, %r12d
je 0x3a0ac
leal -0x1(%r12), %eax
cmpb $0xa, (%rbx,%rax)
cmovnel %r12d, %eax
jmp 0x3a0ae
xorl %r14d, %r14d
testb %r15b, %r15b
jne 0x3a0f4
jmp 0x3a0a3
xorl %r14d, %r14d
testb %r15b, %r15b
jne 0x3a0d1
leaq 0x1bf03(%rip), %rdi     # 0x55fad
jmp 0x3a128
xorl %eax, %eax
movb $0x0, (%rbx,%rax)
movq (%r14), %rdx
movl $0x1, %r14d
leaq 0x1bf14(%rip), %rsi     # 0x55fd6
movl $0x2, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2cf2d
testl %r12d, %r12d
jns 0x3a0ed
movq (%rsp), %rdx
leaq 0x1bf0b(%rip), %rsi     # 0x55fec
movl $0x2, %edi
xorl %eax, %eax
callq 0x2cf2d
movl %ebp, %edi
callq 0x27930
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a10f
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 0x1be98(%rip), %rdi     # 0x55fc0
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x2ce45
movq %rax, %rbx
movq 0x20(%rsp), %rdi
jmp 0x3a149
movq %rax, %rbx
leaq 0x10(%rsp), %rbp
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x3a15a
movq (%rbp), %rsi
incq %rsi
callq 0x27480
movq %rbx, %rdi
callq 0x27830