// File: /workspace/github_cpp_makefile_star2_O2/davmac314[P]dinit/src/includes/load-service.h
// Function: dinit_load::parse_rlimit(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, file_pos_ref, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, char const*, service_rlimits&)
inline void parse_rlimit(const std::string &line, file_pos_ref input_pos,
        const std::string &service_name, const char *param_name, service_rlimits &rlimit)
{
    // Examples:
    // 4:5 - soft:hard limits both set
    // 4:-   soft set, hard set to unlimited
    // 4:    soft set, hard limit unchanged
    // 4     soft and hard limit set to same limit

    if (line.empty()) {
        throw service_description_exc(service_name, std::string(param_name) + ": bad value.", input_pos);
    }

    const char *cline = line.c_str();
    rlimit.hard_set = rlimit.soft_set = false;

    try {
        const char * index = cline;
        errno = 0;
        if (cline[0] != ':') {
            rlimit.soft_set = true;
            if (cline[0] == '-') {
                rlimit.limits.rlim_cur = RLIM_INFINITY;
                index = cline + 1;
            }
            else {
                errno = 0;
                char *nindex;
                unsigned long long limit = std::strtoull(cline, &nindex, 0);
                index = nindex;
                if (errno == ERANGE || limit > std::numeric_limits<rlim_t>::max()) throw std::out_of_range("");
                if (index == cline) throw std::invalid_argument("");
                rlimit.limits.rlim_cur = limit;
            }

            if (*index == 0) {
                rlimit.hard_set = true;
                rlimit.limits.rlim_max = rlimit.limits.rlim_cur;
                return;
            }

            if (*index != ':') {
                throw service_description_exc(service_name, std::string(param_name) + ": bad value.", input_pos);
            }
        }

        index++;
        if (*index == 0) return;

        rlimit.hard_set = true;

        if (*index == '-') {
            rlimit.limits.rlim_max = RLIM_INFINITY;
            if (index[1] != 0) {
                throw service_description_exc(service_name, std::string(param_name) + ": bad value.", input_pos);
            }
        }
        else {
            const char *hard_start = index;
            char *nindex;
            errno = 0;
            unsigned long long limit = std::strtoull(hard_start, &nindex, 0);
            index = nindex;
            if (errno == ERANGE || limit > std::numeric_limits<rlim_t>::max()) throw std::out_of_range("");
            if (index == hard_start) throw std::invalid_argument("");
            rlimit.limits.rlim_max = limit;
        }
    }
    catch (std::invalid_argument &exc) {
        throw service_description_exc(service_name, std::string(param_name) + ": bad value.", input_pos);
    }
    catch (std::out_of_range &exc) {
        throw service_description_exc(service_name, std::string(param_name) + ": too-large value.", input_pos);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r14
movq %rcx, %rbx
movl %esi, 0x48(%rsp)
movq %rdx, 0x50(%rsp)
cmpq $0x0, 0x8(%rdi)
je 0x13b94
movq %r9, %r15
movq (%rdi), %r13
andb $-0x4, 0x4(%r9)
callq 0x4050
movq %rax, %r12
andl $0x0, (%rax)
cmpb $0x3a, (%r13)
je 0x13ac5
orb $0x1, 0x4(%r15)
cmpb $0x2d, (%r13)
jne 0x13a77
orq $-0x1, 0x8(%r15)
incq %r13
pushq $-0x1
popq %rax
movq %r13, %rcx
jmp 0x13aab
andl $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x46e8
cmpl $0x22, (%r12)
je 0x13bfc
movq 0x8(%rsp), %rcx
cmpq %r13, %rcx
je 0x13c91
movq %rax, 0x8(%r15)
movq %rcx, %r13
movzbl (%rcx), %ecx
cmpl $0x3a, %ecx
je 0x13ac5
testl %ecx, %ecx
jne 0x13c29
orb $0x2, 0x4(%r15)
jmp 0x13b81
cmpb $0x0, 0x1(%r13)
je 0x13b85
orb $0x2, 0x4(%r15)
leaq 0x1(%r13), %rbp
cmpb $0x2d, (%rbp)
jne 0x13b57
orq $-0x1, 0x10(%r15)
cmpb $0x0, 0x2(%r13)
je 0x13b85
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r13
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xb9ce
leaq 0x4b51(%rip), %rdx      # 0x18664
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0x100bd(%rip), %rsi     # 0x23c00
leaq -0x1d6e(%rip), %rdx     # 0x11ddc
movq %r13, %rdi
callq 0x4610
jmp 0x13e55
andl $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x46e8
cmpl $0x22, (%r12)
je 0x13cc1
cmpq %rbp, 0x8(%rsp)
je 0x13ceb
movq %rax, 0x10(%r15)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xb9ce
leaq 0x4aac(%rip), %rdx      # 0x18664
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0x10018(%rip), %rsi     # 0x23c00
leaq -0x1e13(%rip), %rdx     # 0x11ddc
movq %r12, %rdi
callq 0x4610
jmp 0x13e55
pushq $0x10
popq %rdi
callq 0x41d0
movq %rax, %r13
leaq 0x395c(%rip), %rsi      # 0x1756a
movq %rax, %rdi
callq 0x4090
movq 0x10373(%rip), %rdx     # 0x23f90
movq 0x1038c(%rip), %rsi     # 0x23fb0
jmp 0x13cb9
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r13
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xb9ce
leaq 0x4a17(%rip), %rdx      # 0x18664
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0xff83(%rip), %rsi      # 0x23c00
leaq -0x1ea8(%rip), %rdx     # 0x11ddc
movq %r13, %rdi
callq 0x4610
jmp 0x13e55
pushq $0x10
popq %rdi
callq 0x41d0
movq %rax, %r13
leaq 0x38c7(%rip), %rsi      # 0x1756a
movq %rax, %rdi
callq 0x4660
movq 0x102e6(%rip), %rdx     # 0x23f98
movq 0x1030f(%rip), %rsi     # 0x23fc8
movq %r13, %rdi
callq 0x4610
pushq $0x10
popq %rdi
callq 0x41d0
movq %rax, %r13
leaq 0x3897(%rip), %rsi      # 0x1756a
movq %rax, %rdi
callq 0x4090
movq 0x102ae(%rip), %rdx     # 0x23f90
movq 0x102c7(%rip), %rsi     # 0x23fb0
jmp 0x13d13
pushq $0x10
popq %rdi
callq 0x41d0
movq %rax, %r13
leaq 0x386d(%rip), %rsi      # 0x1756a
movq %rax, %rdi
callq 0x4660
movq 0x1028c(%rip), %rdx     # 0x23f98
movq 0x102b5(%rip), %rsi     # 0x23fc8
movq %r13, %rdi
callq 0x4610
jmp 0x13d1f
jmp 0x13d31
movq %rdx, %r12
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x41a0
jmp 0x13d3a
movq %rdx, %r12
movq %rax, %r15
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0x13d5b
jmp 0x13d6d
jmp 0x13d55
jmp 0x13d55
jmp 0x13d55
jmp 0x13d55
jmp 0x13d55
movq %rdx, %r12
movq %rax, %r15
movq %r13, %rdi
callq 0x42d0
jmp 0x13d6d
jmp 0x13d67
movq %rdx, %r12
movq %rax, %r15
cmpl $0x2, %r12d
jne 0x13de0
movq %r15, %rdi
callq 0x4160
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xb9ce
leaq 0x48c5(%rip), %rdx      # 0x18664
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0xfe31(%rip), %rsi      # 0x23c00
leaq -0x1ffa(%rip), %rdx     # 0x11ddc
movq %r12, %rdi
callq 0x4610
jmp 0x13e55
cmpl $0x1, %r12d
jne 0x13ef6
movq %r15, %rdi
callq 0x4160
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xb9ce
leaq 0x485b(%rip), %rdx      # 0x18671
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x8(%rsp), %rdx
leaq 0x48(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0xfdba(%rip), %rsi      # 0x23c00
leaq -0x2071(%rip), %rdx     # 0x11ddc
movq %r12, %rdi
callq 0x4610
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x41a0
jmp 0x13e6a
movq %rax, %r15
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0x13e8d
jmp 0x13e95
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x41a0
jmp 0x13ea2
movq %rax, %r15
movq %r12, %rdi
callq 0x42d0
callq 0x4600
jmp 0x13ef6
movq %rax, %r15
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0x13edc
jmp 0x13ee4
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0x41a0
jmp 0x13ec8
movq %rax, %r15
movb $0x1, %bpl
leaq 0x28(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0x13eee
jmp 0x13ef6
movq %rax, %r15
movq %r12, %rdi
callq 0x42d0
callq 0x4600
jmp 0x13ef6
movq %rax, %r15
movq %r12, %rdi
callq 0x42d0
movq %r15, %rdi
callq 0x4620
movq %rax, %rdi
callq 0xba09