// File: /workspace/github_cpp_makefile_star2_O3/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 0x18e99
movq %r9, %r15
movq (%rdi), %r13
andb $-0x4, 0x4(%r9)
callq 0x4060
movq %rax, %r12
movl $0x0, (%rax)
cmpb $0x3a, (%r13)
je 0x18dd0
orb $0x1, 0x4(%r15)
cmpb $0x2d, (%r13)
jne 0x18d7f
movq $-0x1, 0x8(%r15)
incq %r13
movq $-0x1, %rax
movq %r13, %rcx
jmp 0x18db6
movl $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x44e0
cmpl $0x22, (%r12)
je 0x18ef1
movq 0x8(%rsp), %rcx
cmpq %r13, %rcx
je 0x18f7c
movq %rax, 0x8(%r15)
movq %rcx, %r13
movzbl (%rcx), %ecx
cmpl $0x3a, %ecx
je 0x18dd0
testl %ecx, %ecx
jne 0x18f20
orb $0x2, 0x4(%r15)
jmp 0x18e86
cmpb $0x0, 0x1(%r13)
je 0x18e8a
orb $0x2, 0x4(%r15)
leaq 0x1(%r13), %rbp
cmpb $0x2d, (%rbp)
jne 0x18e59
movq $-0x1, 0x10(%r15)
cmpb $0x0, 0x2(%r13)
je 0x18e8a
movl $0x70, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfff2
leaq 0x4841(%rip), %rsi      # 0x1d664
leaq 0x28(%rsp), %rdi
callq 0x46a0
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x190be
movups (%rcx), %xmm0
leaq 0x18(%rsp), %rdx
movups %xmm0, (%rdx)
jmp 0x190cb
movl $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x44e0
cmpl $0x22, (%r12)
je 0x18fae
cmpq %rbp, 0x8(%rsp)
je 0x18fda
movq %rax, 0x10(%r15)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x70, %edi
callq 0x41c0
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfff2
leaq 0x47a5(%rip), %rsi      # 0x1d664
leaq 0x28(%rsp), %rdi
callq 0x46a0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x1900c
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x19019
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x3665(%rip), %rsi      # 0x1c56a
movq %rax, %rdi
callq 0x40a0
movq 0xd084(%rip), %rdx      # 0x25f98
movq 0xd09d(%rip), %rsi      # 0x25fb8
jmp 0x18fa6
movl $0x70, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfff2
leaq 0x471e(%rip), %rsi      # 0x1d664
leaq 0x28(%rsp), %rdi
callq 0x46a0
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x19065
movups (%rcx), %xmm0
leaq 0x18(%rsp), %rdx
movups %xmm0, (%rdx)
jmp 0x19072
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x35da(%rip), %rsi      # 0x1c56a
movq %rax, %rdi
callq 0x4680
movq 0xd001(%rip), %rdx      # 0x25fa0
movq 0xd02a(%rip), %rsi      # 0x25fd0
movq %r13, %rdi
callq 0x4620
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x35a8(%rip), %rsi      # 0x1c56a
movq %rax, %rdi
callq 0x40a0
movq 0xcfc7(%rip), %rdx      # 0x25f98
movq 0xcfe0(%rip), %rsi      # 0x25fb8
jmp 0x19004
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x357c(%rip), %rsi      # 0x1c56a
movq %rax, %rdi
callq 0x4680
movq 0xcfa3(%rip), %rdx      # 0x25fa0
movq 0xcfcc(%rip), %rsi      # 0x25fd0
movq %r13, %rdi
callq 0x4620
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
leaq 0x48(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x16d7c
xorl %ebp, %ebp
leaq 0xcbcf(%rip), %rsi      # 0x25c20
leaq -0x24b2(%rip), %rdx     # 0x16ba6
movq %r12, %rdi
callq 0x4620
jmp 0x19310
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
leaq 0x48(%rsp), %rcx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x16d7c
xorl %ebp, %ebp
leaq 0xcb76(%rip), %rsi      # 0x25c20
leaq -0x250b(%rip), %rdx     # 0x16ba6
movq %r13, %rdi
callq 0x4620
jmp 0x19310
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
leaq 0x48(%rsp), %rcx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x16d7c
xorl %ebp, %ebp
leaq 0xcb1d(%rip), %rsi      # 0x25c20
leaq -0x2564(%rip), %rdx     # 0x16ba6
movq %r13, %rdi
callq 0x4620
jmp 0x19310
jmp 0x1911b
jmp 0x1915f
movq %rdx, %r12
movq %rax, %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1913d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19158
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
jne 0x19192
jmp 0x191a4
movq %rdx, %r12
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19192
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19192
jmp 0x1918c
jmp 0x1918c
jmp 0x1918c
jmp 0x1918c
jmp 0x1918c
movq %rdx, %r12
movq %rax, %r15
movq %r13, %rdi
callq 0x42d0
jmp 0x191a4
jmp 0x1919e
movq %rdx, %r12
movq %rax, %r15
cmpl $0x2, %r12d
jne 0x19203
movq %r15, %rdi
callq 0x4170
movl $0x70, %edi
callq 0x41c0
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfff2
leaq 0x448c(%rip), %rsi      # 0x1d664
leaq 0x28(%rsp), %rdi
callq 0x46a0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x19266
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x19273
cmpl $0x1, %r12d
jne 0x1945d
movq %r15, %rdi
callq 0x4170
movl $0x70, %edi
callq 0x41c0
movq %rax, %r12
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfff2
leaq 0x4436(%rip), %rsi      # 0x1d671
leaq 0x28(%rsp), %rdi
callq 0x46a0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x192bc
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x192c9
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
leaq 0x48(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x16d7c
xorl %ebp, %ebp
leaq 0xc975(%rip), %rsi      # 0x25c20
leaq -0x270c(%rip), %rdx     # 0x16ba6
movq %r12, %rdi
callq 0x4620
jmp 0x19310
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
leaq 0x48(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x16d7c
xorl %ebp, %ebp
leaq 0xc91f(%rip), %rsi      # 0x25c20
leaq -0x2762(%rip), %rdx     # 0x16ba6
movq %r12, %rdi
callq 0x4620
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x1932a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19345
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
jne 0x193b2
jmp 0x193ba
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x193b2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x193b2
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x19386
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x193a1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
jne 0x19443
jmp 0x1944b
movq %rax, %r15
movq %r12, %rdi
callq 0x42d0
callq 0x4600
jmp 0x1945d
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19443
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19443
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x193fe
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19419
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
jne 0x19455
jmp 0x1945d
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19455
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19455
movq %rax, %r15
movq %r12, %rdi
callq 0x42d0
callq 0x4600
jmp 0x1945d
movq %rax, %r15
movq %r12, %rdi
callq 0x42d0
movq %r15, %rdi
callq 0x4630
movq %rax, %rdi
callq 0x1002f
nop