// File: 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
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movl %esi, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5830
testb $0x1, %al
jne 0x322b4
jmp 0x323cc
movb $0x1, -0x85(%rbp)
movl $0x70, %edi
callq 0x5220
movq %rax, -0x210(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x200(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x5880
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x13710
jmp 0x3230b
leaq 0x8363(%rip), %rdx      # 0x3a675
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x16640
jmp 0x32321
movq -0x208(%rbp), %rsi
movq -0x210(%rbp), %rdi
leaq -0x50(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x2e2d0
jmp 0x3233e
movq -0x210(%rbp), %rdi
movb $0x0, -0x85(%rbp)
leaq 0x1e89d(%rip), %rsi     # 0x50bf0
leaq -0x460a(%rip), %rdx     # 0x2dd50
callq 0x5840
jmp 0x32d02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x323a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3239e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5320
leaq -0x70(%rbp), %rdi
callq 0x5320
leaq -0x71(%rbp), %rdi
callq 0x5520
testb $0x1, -0x85(%rbp)
jne 0x323bb
jmp 0x323c7
movq -0x210(%rbp), %rdi
callq 0x53a0
jmp 0x32cf1
movq -0x18(%rbp), %rdi
callq 0x51b0
movq %rax, -0x90(%rbp)
movq -0x30(%rbp), %rax
movb 0x4(%rax), %cl
andb $-0x2, %cl
orb $0x0, %cl
movb %cl, 0x4(%rax)
movq -0x30(%rbp), %rax
movb 0x4(%rax), %cl
andb $-0x3, %cl
orb $0x0, %cl
movb %cl, 0x4(%rax)
movq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x5070
movl $0x0, (%rax)
movq -0x90(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
je 0x3273f
movq -0x30(%rbp), %rax
movb 0x4(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x4(%rax)
movq -0x90(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x3246a
movq -0x30(%rbp), %rax
movq $-0x1, 0x8(%rax)
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x325c6
callq 0x5070
movl $0x0, (%rax)
movq -0x90(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
xorl %edx, %edx
callq 0x5958
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x5070
cmpl $0x22, (%rax)
je 0x324cb
movq -0xa8(%rbp), %rax
movq %rax, -0x218(%rbp)
callq 0x34160
movq %rax, %rcx
movq -0x218(%rbp), %rax
cmpq %rcx, %rax
jbe 0x32543
movl $0x10, %edi
callq 0x5220
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x220(%rbp)
leaq 0x7090(%rip), %rsi      # 0x39579
callq 0x50b0
jmp 0x324f0
movq -0x220(%rbp), %rdi
movq 0x1eab2(%rip), %rsi     # 0x50fb0
movq 0x1ea8b(%rip), %rdx     # 0x50f90
callq 0x5840
jmp 0x32d02
movq -0x220(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x53a0
jmp 0x32a20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32a20
movq -0x98(%rbp), %rax
cmpq -0x90(%rbp), %rax
jne 0x325b7
movl $0x10, %edi
callq 0x5220
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x228(%rbp)
leaq 0x7008(%rip), %rsi      # 0x39579
callq 0x58c0
jmp 0x32578
movq -0x228(%rbp), %rdi
movq 0x1ea42(%rip), %rsi     # 0x50fc8
movq 0x1ea0b(%rip), %rdx     # 0x50f98
callq 0x5840
jmp 0x32d02
movq -0x228(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x53a0
jmp 0x32a20
movq -0xa8(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x325fa
movq -0x30(%rbp), %rax
movb 0x4(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x4(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x32ce8
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
je 0x3273d
movb $0x1, -0xea(%rbp)
movl $0x70, %edi
callq 0x5220
movq %rax, -0x248(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x5880
movq -0x238(%rbp), %rsi
movq -0x230(%rbp), %rdx
leaq -0xe8(%rbp), %rdi
callq 0x13710
jmp 0x3266a
leaq 0x8004(%rip), %rdx      # 0x3a675
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x16640
jmp 0x32686
movq -0x240(%rbp), %rsi
movq -0x248(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x2e2d0
jmp 0x326a6
movq -0x248(%rbp), %rdi
movb $0x0, -0xea(%rbp)
leaq 0x1e535(%rip), %rsi     # 0x50bf0
leaq -0x4972(%rip), %rdx     # 0x2dd50
callq 0x5840
jmp 0x32d02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32715
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32709
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5320
leaq -0xe8(%rbp), %rdi
callq 0x5320
leaq -0xe9(%rbp), %rdi
callq 0x5520
testb $0x1, -0xea(%rbp)
jne 0x3272c
jmp 0x32738
movq -0x248(%rbp), %rdi
callq 0x53a0
jmp 0x32a20
jmp 0x3273f
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x32765
jmp 0x32ce8
movq -0x30(%rbp), %rax
movb 0x4(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x4(%rax)
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x328dd
movq -0x30(%rbp), %rax
movq $-0x1, 0x10(%rax)
movq -0x98(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x328d8
movb $0x1, -0x132(%rbp)
movl $0x70, %edi
callq 0x5220
movq %rax, -0x268(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x5880
movq -0x258(%rbp), %rsi
movq -0x250(%rbp), %rdx
leaq -0x130(%rbp), %rdi
callq 0x13710
jmp 0x32805
leaq 0x7e69(%rip), %rdx      # 0x3a675
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x16640
jmp 0x32821
movq -0x260(%rbp), %rsi
movq -0x268(%rbp), %rdi
leaq -0x110(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x2e2d0
jmp 0x32841
movq -0x268(%rbp), %rdi
movb $0x0, -0x132(%rbp)
leaq 0x1e39a(%rip), %rsi     # 0x50bf0
leaq -0x4b0d(%rip), %rdx     # 0x2dd50
callq 0x5840
jmp 0x32d02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x328b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x328a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x5320
leaq -0x130(%rbp), %rdi
callq 0x5320
leaq -0x131(%rbp), %rdi
callq 0x5520
testb $0x1, -0x132(%rbp)
jne 0x328c7
jmp 0x328d3
movq -0x268(%rbp), %rdi
callq 0x53a0
jmp 0x32a20
jmp 0x32bf9
movq -0x98(%rbp), %rax
movq %rax, -0x140(%rbp)
callq 0x5070
movl $0x0, (%rax)
movq -0x140(%rbp), %rdi
leaq -0x148(%rbp), %rsi
xorl %edx, %edx
callq 0x5958
movq %rax, -0x150(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x5070
cmpl $0x22, (%rax)
je 0x3294c
movq -0x150(%rbp), %rax
movq %rax, -0x270(%rbp)
callq 0x34160
movq %rax, %rcx
movq -0x270(%rbp), %rax
cmpq %rcx, %rax
jbe 0x329ad
movl $0x10, %edi
callq 0x5220
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x278(%rbp)
leaq 0x6c0f(%rip), %rsi      # 0x39579
callq 0x50b0
jmp 0x32971
movq -0x278(%rbp), %rdi
movq 0x1e631(%rip), %rsi     # 0x50fb0
movq 0x1e60a(%rip), %rdx     # 0x50f90
callq 0x5840
jmp 0x32d02
movq -0x278(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x53a0
jmp 0x32a20
movq -0x98(%rbp), %rax
cmpq -0x140(%rbp), %rax
jne 0x32bea
movl $0x10, %edi
callq 0x5220
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x280(%rbp)
leaq 0x6b9a(%rip), %rsi      # 0x39579
callq 0x58c0
jmp 0x329e6
movq -0x280(%rbp), %rdi
movq 0x1e5d4(%rip), %rsi     # 0x50fc8
movq 0x1e59d(%rip), %rdx     # 0x50f98
callq 0x5840
jmp 0x32d02
movq -0x280(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
callq 0x53a0
movl -0x84(%rbp), %eax
movl %eax, -0x284(%rbp)
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x32b08
movq -0x80(%rbp), %rdi
callq 0x51a0
movq %rax, -0x1a8(%rbp)
movb $0x1, -0x1ea(%rbp)
movl $0x70, %edi
callq 0x5220
movq %rax, -0x2a8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x5880
movq -0x298(%rbp), %rsi
movq -0x290(%rbp), %rdx
leaq -0x1e8(%rbp), %rdi
callq 0x13710
jmp 0x32aa6
leaq 0x7bc8(%rip), %rdx      # 0x3a675
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x16640
jmp 0x32ac2
movq -0x2a0(%rbp), %rsi
movq -0x2a8(%rbp), %rdi
leaq -0x1c8(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x2e2d0
jmp 0x32ae2
movq -0x2a8(%rbp), %rdi
movb $0x0, -0x1ea(%rbp)
leaq 0x1e0f9(%rip), %rsi     # 0x50bf0
leaq -0x4dae(%rip), %rdx     # 0x2dd50
callq 0x5840
jmp 0x32d02
movl -0x284(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x32cf1
movq -0x80(%rbp), %rdi
callq 0x51a0
movq %rax, -0x158(%rbp)
movb $0x1, -0x19a(%rbp)
movl $0x70, %edi
callq 0x5220
movq %rax, -0x2c8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x199(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x5880
movq -0x2b8(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
leaq -0x198(%rbp), %rdi
callq 0x13710
jmp 0x32b88
leaq 0x7af3(%rip), %rdx      # 0x3a682
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x16640
jmp 0x32ba4
movq -0x2c0(%rbp), %rsi
movq -0x2c8(%rbp), %rdi
leaq -0x178(%rbp), %rdx
leaq -0x10(%rbp), %rcx
callq 0x2e2d0
jmp 0x32bc4
movq -0x2c8(%rbp), %rdi
movb $0x0, -0x19a(%rbp)
leaq 0x1e017(%rip), %rsi     # 0x50bf0
leaq -0x4e90(%rip), %rdx     # 0x2dd50
callq 0x5840
jmp 0x32d02
movq -0x150(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x32ce8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32c47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32c3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x5320
leaq -0x198(%rbp), %rdi
callq 0x5320
leaq -0x199(%rbp), %rdi
callq 0x5520
testb $0x1, -0x19a(%rbp)
jne 0x32c5e
jmp 0x32c6a
movq -0x2c8(%rbp), %rdi
callq 0x53a0
callq 0x5810
jmp 0x32c71
jmp 0x32cf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32cbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x32cb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x5320
leaq -0x1e8(%rbp), %rdi
callq 0x5320
leaq -0x1e9(%rbp), %rdi
callq 0x5520
testb $0x1, -0x1ea(%rbp)
jne 0x32cd3
jmp 0x32cdf
movq -0x2a8(%rbp), %rdi
callq 0x53a0
callq 0x5810
jmp 0x32ce6
jmp 0x32cf1
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x5870
movq %rax, %rdi
callq 0x138d0
nopw %cs:(%rax,%rax)
nopl (%rax)