// File: /workspace/github_cpp_makefile_star2_O1/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 0x18d3e
movq %r9, %r15
movq (%rdi), %r13
andb $-0x4, 0x4(%r9)
callq 0x4060
movq %rax, %r12
movl $0x0, (%rax)
cmpb $0x3a, (%r13)
je 0x18c75
orb $0x1, 0x4(%r15)
cmpb $0x2d, (%r13)
jne 0x18c20
movq $-0x1, 0x8(%r15)
incq %r13
movq %r13, %rcx
jmp 0x18c57
movl $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x44e0
cmpl $0x22, (%r12)
je 0x18d96
movq 0x8(%rsp), %rcx
cmpq %r13, %rcx
je 0x18e21
movq %rax, 0x8(%r15)
movq %rcx, %r13
movzbl (%rcx), %eax
cmpl $0x3a, %eax
je 0x18c75
testl %eax, %eax
jne 0x18dc5
orb $0x2, 0x4(%r15)
movq 0x8(%r15), %rax
jmp 0x18d2b
cmpb $0x0, 0x1(%r13)
je 0x18d2f
orb $0x2, 0x4(%r15)
leaq 0x1(%r13), %rbp
cmpb $0x2d, (%rbp)
jne 0x18cfe
movq $-0x1, 0x10(%r15)
cmpb $0x0, 0x2(%r13)
je 0x18d2f
movl $0x70, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfcc6
leaq 0x499e(%rip), %rsi      # 0x1d666
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 0x18f63
movups (%rcx), %xmm0
leaq 0x18(%rsp), %rdx
movups %xmm0, (%rdx)
jmp 0x18f70
movl $0x0, (%r12)
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0x44e0
cmpl $0x22, (%r12)
je 0x18e53
cmpq %rbp, 0x8(%rsp)
je 0x18e7f
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 0xfcc6
leaq 0x4902(%rip), %rsi      # 0x1d666
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 0x18eb1
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x18ebe
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x37c2(%rip), %rsi      # 0x1c56c
movq %rax, %rdi
callq 0x40a0
movq 0xd1df(%rip), %rdx      # 0x25f98
movq 0xd1f8(%rip), %rsi      # 0x25fb8
jmp 0x18e4b
movl $0x70, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r14, %rsi
callq 0xfcc6
leaq 0x487b(%rip), %rsi      # 0x1d666
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 0x18f0a
movups (%rcx), %xmm0
leaq 0x18(%rsp), %rdx
movups %xmm0, (%rdx)
jmp 0x18f17
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x3737(%rip), %rsi      # 0x1c56c
movq %rax, %rdi
callq 0x4680
movq 0xd15c(%rip), %rdx      # 0x25fa0
movq 0xd185(%rip), %rsi      # 0x25fd0
movq %r13, %rdi
callq 0x4620
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x3705(%rip), %rsi      # 0x1c56c
movq %rax, %rdi
callq 0x40a0
movq 0xd122(%rip), %rdx      # 0x25f98
movq 0xd13b(%rip), %rsi      # 0x25fb8
jmp 0x18ea9
movl $0x10, %edi
callq 0x41c0
movq %rax, %r13
leaq 0x36d9(%rip), %rsi      # 0x1c56c
movq %rax, %rdi
callq 0x4680
movq 0xd0fe(%rip), %rdx      # 0x25fa0
movq 0xd127(%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 0x16cc4
xorl %ebp, %ebp
leaq 0xcd2a(%rip), %rsi      # 0x25c20
leaq -0x2435(%rip), %rdx     # 0x16ac8
movq %r12, %rdi
callq 0x4620
jmp 0x191a6
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 0x16cc4
xorl %ebp, %ebp
leaq 0xccd1(%rip), %rsi      # 0x25c20
leaq -0x248e(%rip), %rdx     # 0x16ac8
movq %r13, %rdi
callq 0x4620
jmp 0x191a6
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 0x16cc4
xorl %ebp, %ebp
leaq 0xcc78(%rip), %rsi      # 0x25c20
leaq -0x24e7(%rip), %rdx     # 0x16ac8
movq %r13, %rdi
callq 0x4620
jmp 0x191a6
jmp 0x18fc0
jmp 0x18fe4
movq %rdx, %r12
movq %rax, %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x18fed
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x18fed
movq %rdx, %r12
movq %rax, %r15
movb $0x1, %bpl
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1901b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x1901b
jmp 0x19022
jmp 0x19022
jmp 0x19012
jmp 0x19022
movq %rdx, %r12
movq %rax, %r15
movb $0x1, %bpl
testb %bpl, %bpl
jne 0x19028
jmp 0x1903a
movq %rdx, %r12
movq %rax, %r15
movq %r13, %rdi
callq 0x42d0
jmp 0x1903a
jmp 0x19034
movq %rdx, %r12
movq %rax, %r15
cmpl $0x2, %r12d
jne 0x19099
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 0xfcc6
leaq 0x45f8(%rip), %rsi      # 0x1d666
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 0x190fc
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x19109
cmpl $0x1, %r12d
jne 0x192ad
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 0xfcc6
leaq 0x45a2(%rip), %rsi      # 0x1d673
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 0x19152
movups (%rcx), %xmm0
movups %xmm0, (%r14)
jmp 0x1915f
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 0x16cc4
xorl %ebp, %ebp
leaq 0xcadf(%rip), %rsi      # 0x25c20
leaq -0x2680(%rip), %rdx     # 0x16ac8
movq %r12, %rdi
callq 0x4620
jmp 0x191a6
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 0x16cc4
xorl %ebp, %ebp
leaq 0xca89(%rip), %rsi      # 0x25c20
leaq -0x26d6(%rip), %rdx     # 0x16ac8
movq %r12, %rdi
callq 0x4620
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x191c8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x191c8
movq %rax, %r15
movb $0x1, %bpl
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19207
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19207
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x19224
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19224
movq %rax, %r15
movb $0x1, %bpl
testb %bpl, %bpl
je 0x19214
movq %r12, %rdi
callq 0x42d0
callq 0x4600
jmp 0x192ad
movq %rax, %r15
movb $0x1, %bpl
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x19286
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19286
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x19263
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x19263
movq %rax, %r15
movb $0x1, %bpl
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x192a0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x192a0
movq %rax, %r15
movb $0x1, %bpl
testb %bpl, %bpl
je 0x19293
movq %r12, %rdi
callq 0x42d0
callq 0x4600
jmp 0x192ad
movq %rax, %r15
movb $0x1, %bpl
testb %bpl, %bpl
je 0x192ad
movq %r12, %rdi
callq 0x42d0
movq %r15, %rdi
callq 0x4630
movq %rax, %rdi
callq 0xfd03
nop