// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/includes/load-service.h
// Function: dinit_load::fill_environment_userinfo(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, environment&)
inline void fill_environment_userinfo(uid_t uid, const std::string &service_name, environment &env)
{
    if (uid == (uid_t)-1) {
        uid = geteuid();
    }

    char buf[std::numeric_limits<unsigned long long>::digits10 + 1];
    snprintf(buf, sizeof(buf), "%llu", (unsigned long long)uid);

    errno = 0;
    struct passwd *pwent = getpwuid(uid);

    if (!pwent) {
        if (!errno) {
            throw service_load_exc(service_name, std::string("user id '") + buf
                    + "' does not exist in system database");
        } else {
            throw service_load_exc(service_name, std::string("error accessing user database: ")
                    + strerror(errno));
        }
    }

    std::string enval;

    // USER
    enval = "USER=";
    enval += pwent->pw_name;
    env.set_var(std::move(enval));
    // LOGNAME
    enval = "LOGNAME=";
    enval += pwent->pw_name;
    env.set_var(std::move(enval));
    // HOME
    enval = "HOME=";
    enval += pwent->pw_dir;
    env.set_var(std::move(enval));
    // SHELL
    enval = "SHELL=";
    enval += pwent->pw_shell;
    env.set_var(std::move(enval));
    // UID (non-standard, but useful)
    enval = "UID=";
    snprintf(buf, sizeof(buf), "%llu", (unsigned long long)pwent->pw_uid);
    enval += buf;
    env.set_var(std::move(enval));
    // GID (non-standard, but useful)
    enval = "GID=";
    snprintf(buf, sizeof(buf), "%llu", (unsigned long long)pwent->pw_gid);
    enval += buf;
    env.set_var(std::move(enval));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %ebp
cmpl $-0x1, %edi
jne 0x11464
callq 0x4260
movl %eax, %ebp
movl %ebp, %ecx
leaq 0xb695(%rip), %rdx      # 0x1cb02
leaq 0x60(%rsp), %rdi
movl $0x14, %esi
xorl %eax, %eax
callq 0x45c0
callq 0x4060
movq %rax, %r12
movl $0x0, (%rax)
movl %ebp, %edi
callq 0x4440
testq %rax, %rax
je 0x1164c
movq %rax, %r14
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0xb697(%rip), %rcx      # 0x1cb55
movq %rsp, %rdi
movl $0x5, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x45a0
movq (%r14), %rsi
movq %rsp, %rdi
callq 0x46a0
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x118e8
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb665(%rip), %rcx      # 0x1cb5b
movl $0x8, %r8d
xorl %esi, %esi
callq 0x45a0
movq (%r14), %rsi
movq %rsp, %rdi
callq 0x46a0
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x118e8
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb63b(%rip), %rcx      # 0x1cb64
movl $0x5, %r8d
xorl %esi, %esi
callq 0x45a0
movq 0x20(%r14), %rsi
movq %rsp, %rdi
callq 0x46a0
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x118e8
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb60d(%rip), %rcx      # 0x1cb6a
movl $0x6, %r8d
xorl %esi, %esi
callq 0x45a0
movq 0x28(%r14), %rsi
movq %rsp, %rdi
callq 0x46a0
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x118e8
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb5e0(%rip), %rcx      # 0x1cb71
movl $0x4, %r8d
xorl %esi, %esi
callq 0x45a0
movl 0x10(%r14), %ecx
leaq 0xb559(%rip), %rdx      # 0x1cb02
leaq 0x60(%rsp), %r15
movl $0x14, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x45c0
movq %rsp, %rdi
movq %r15, %rsi
callq 0x46a0
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x118e8
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb593(%rip), %rcx      # 0x1cb76
movl $0x4, %r8d
xorl %esi, %esi
callq 0x45a0
movl 0x14(%r14), %ecx
leaq 0xb507(%rip), %rdx      # 0x1cb02
leaq 0x60(%rsp), %r14
movl $0x14, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x45c0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x46a0
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x118e8
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1163d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r12), %ebp
movl $0x40, %edi
callq 0x41c0
movq %rax, %rbx
testl %ebp, %ebp
jne 0x116b4
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xb495(%rip), %rsi      # 0x1cb07
leaq 0xb497(%rip), %rdx      # 0x1cb10
leaq 0x40(%rsp), %rdi
callq 0x129da
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x46a0
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x1170e
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x1171b
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xb471(%rip), %rsi      # 0x1cb35
leaq 0xb489(%rip), %rdx      # 0x1cb54
leaq 0x20(%rsp), %rdi
callq 0x129da
movl (%r12), %edi
callq 0x4140
leaq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x46a0
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x11768
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x11774
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
movq 0x8(%rax), %rdx
leaq 0x20(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xb3d3(%rip), %rsi      # 0x1cb11
callq 0x46a0
leaq 0x10(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x117b6
movups (%rcx), %xmm0
leaq 0x10(%rsp), %rdx
movups %xmm0, (%rdx)
jmp 0x117c2
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rsi
movq %rsp, %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %rbx, %rdi
movq %r15, %rsi
callq 0x113a2
xorl %ebp, %ebp
leaq 0x1440b(%rip), %rsi     # 0x25bb0
leaq -0x3a0(%rip), %rdx      # 0x1140c
movq %rbx, %rdi
callq 0x4620
jmp 0x11802
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rsi
movq %rsp, %rdx
movq %rsi, 0x8(%rdx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %rbx, %rdi
movq %r15, %rsi
callq 0x113a2
xorl %ebp, %ebp
leaq 0x143bd(%rip), %rsi     # 0x25bb0
leaq -0x3ee(%rip), %rdx      # 0x1140c
movq %rbx, %rdi
callq 0x4620
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x11828
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x11828
movq %rax, %r14
movb $0x1, %bpl
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x1183f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x11880
movq 0x50(%rsp), %rsi
jmp 0x11878
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x11869
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x11880
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
jne 0x118bc
jmp 0x118df
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x118bc
movq 0x30(%rsp), %rsi
jmp 0x118ad
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x118bc
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x118bc
jmp 0x118b9
movq %rax, %r14
movq %rbx, %rdi
callq 0x42d0
jmp 0x118df
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x118df
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r14, %rdi
callq 0x4630
nop