// File: /workspace/github_cpp_makefile_star2_O2/davmac314[P]dinit/src/includes/load-service.h
// Function: dinit_load::parse_uid_param(file_pos_ref, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, char const*, unsigned int*)
inline uid_t parse_uid_param(file_pos_ref input_pos, const std::string &param,
        const std::string &service_name, const char *setting_name, gid_t *group_p)
{
    const char * uid_err_msg = "specified user id contains invalid numeric characters "
            "or is outside allowed range.";

    // Could be a name or a numeric id. But we should assume numeric first, just in case
    // a user manages to give themselves a username that parses as a number.
    std::size_t ind = 0;
    try {
        // POSIX does not specify whether uid_t is a signed or unsigned type, but regardless
        // is is probably safe to assume that valid values are positive. We'll also assert
        // that the value range fits within "unsigned long long" since it seems unlikely
        // that would ever not be the case.
        static_assert((uintmax_t)std::numeric_limits<uid_t>::max()
                <= (uintmax_t)std::numeric_limits<unsigned long long>::max(), "uid_t is too large");
        unsigned long long v = std::stoull(param, &ind, 0);
        if (v > static_cast<unsigned long long>(std::numeric_limits<uid_t>::max())
                || ind != param.length()) {
            throw service_description_exc(service_name, std::string(setting_name) + ": " + uid_err_msg, input_pos);
        }
        return v;
    }
    catch (std::out_of_range &exc) {
        throw service_description_exc(service_name, uid_err_msg, input_pos);
    }
    catch (std::invalid_argument &exc) {
        // Ok, so it doesn't look like a number: proceed...
    }

    errno = 0;
    struct passwd * pwent = getpwnam(param.c_str());
    if (pwent == nullptr) {
        // Maybe an error, maybe just no entry.
        if (errno == 0) {
            throw service_description_exc(service_name, std::string(setting_name) + ": specified user \"" + param
                    + "\" does not exist in system database.", input_pos);
        }
        else {
            throw service_description_exc(service_name, std::string("error accessing user database: ")
                    + strerror(errno), input_pos);
        }
    }

    if (group_p) {
        *group_p = pwent->pw_gid;
    }

    return pwent->pw_uid;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r9, %r15
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, %r14
movl %edi, 0x30(%rsp)
movq %rsi, 0x38(%rsp)
leaq 0x60(%rsp), %rsi
andq $0x0, (%rsi)
movq %rdx, %rdi
xorl %edx, %edx
callq 0x14114
movq %rax, %rcx
shrq $0x20, %rcx
jne 0x12ce7
movq 0x60(%rsp), %rcx
cmpq 0x8(%r14), %rcx
jne 0x12ce7
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, 0x8(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x88(%rsp), %rdx
movq %r12, %rsi
callq 0xb9ce
leaq 0x4a40(%rip), %rdx      # 0x17750
leaq 0x40(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xcb22
leaq 0x57a1(%rip), %rdx      # 0x184c7
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xcb22
movb $0x1, %al
movl %eax, (%rsp)
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1205c
movl $0x0, (%rsp)
leaq 0x10ea1(%rip), %rsi     # 0x23c00
leaq -0xf8a(%rip), %rdx      # 0x11ddc
movq 0x8(%rsp), %rdi
callq 0x4610
jmp 0x12f77
movq %rdx, %rbp
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0x41a0
jmp 0x12d92
movq %rdx, %rbp
movq %rax, %r13
movb $0x1, %al
movl %eax, (%rsp)
leaq 0x40(%rsp), %rdi
callq 0x41a0
jmp 0x12da9
movq %rdx, %rbp
movq %rax, %r13
movb $0x1, %al
movl %eax, (%rsp)
leaq 0x68(%rsp), %rdi
callq 0x41a0
cmpb $0x0, (%rsp)
jne 0x12dc1
jmp 0x12dd3
movq %rdx, %rbp
movq %rax, %r13
movq 0x8(%rsp), %rdi
callq 0x42d0
jmp 0x12dd3
movq %rdx, %rbp
movq %rax, %r13
cmpl $0x2, %ebp
je 0x12e19
cmpl $0x1, %ebp
jne 0x13013
movq %r13, %rdi
callq 0x4160
callq 0x4600
callq 0x4050
movq %rax, %r13
andl $0x0, (%rax)
movq (%r14), %rdi
callq 0x4300
testq %rax, %rax
je 0x12e77
testq %r15, %r15
je 0x12e11
movl 0x14(%rax), %ecx
movl %ecx, (%r15)
movl 0x10(%rax), %eax
jmp 0x12cd5
movq %r13, %rdi
callq 0x4160
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r14
leaq 0x5694(%rip), %rsi      # 0x184c7
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0xb9ce
movb $0x1, %bpl
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0x10d9d(%rip), %rsi     # 0x23c00
leaq -0x108e(%rip), %rdx     # 0x11ddc
movq %r14, %rdi
callq 0x4610
jmp 0x12f77
movl (%r13), %ebp
pushq $0x70
popq %rdi
callq 0x41d0
movq %rax, %r15
testl %ebp, %ebp
jne 0x12f16
leaq 0x88(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r12, %rsi
callq 0xb9ce
leaq 0x5670(%rip), %rdx      # 0x1851a
leaq 0x68(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xcb22
leaq 0x40(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movq %r14, %rdx
callq 0xce5d
leaq 0x5658(%rip), %rdx      # 0x1852d
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0x10cfb(%rip), %rsi     # 0x23c00
leaq -0x1130(%rip), %rdx     # 0x11ddc
movq %r15, %rdi
callq 0x4610
jmp 0x12f77
leaq 0x4c18(%rip), %rsi      # 0x17b35
leaq 0x40(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0xb9ce
movl (%r13), %edi
callq 0x4130
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %rax, %rdx
callq 0xcb22
movb $0x1, %bpl
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1205c
xorl %ebp, %ebp
leaq 0x10c98(%rip), %rsi     # 0x23c00
leaq -0x1193(%rip), %rdx     # 0x11ddc
movq %r15, %rdi
callq 0x4610
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0x41a0
jmp 0x12f8c
movq %rax, %r13
movb $0x1, %bpl
leaq 0x40(%rsp), %rdi
callq 0x41a0
jmp 0x12f9e
movq %rax, %r13
movb $0x1, %bpl
leaq 0x68(%rsp), %rdi
callq 0x41a0
jmp 0x12fcc
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0x41a0
jmp 0x12fbf
movq %rax, %r13
movb $0x1, %bpl
leaq 0x40(%rsp), %rdi
jmp 0x12fd4
movq %rax, %r13
movb $0x1, %bpl
leaq 0x88(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0x12fe5
jmp 0x13013
jmp 0x12fe2
movq %rax, %r13
movq %r15, %rdi
callq 0x42d0
jmp 0x13013
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0x13006
jmp 0x1300e
movq %rax, %r13
movq %r14, %rdi
callq 0x42d0
callq 0x4600
movq %r13, %rdi
callq 0x4620
movq %rax, %rdi
callq 0xba09