// File: /workspace/github_cpp_makefile_star2_O1/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 0x111e6
callq 0x4260
movl %eax, %ebp
movl %ebp, %ecx
leaq 0xb915(%rip), %rdx      # 0x1cb04
leaq 0x40(%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 0x113ce
movq %rax, %r14
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0xb917(%rip), %rcx      # 0x1cb57
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 0x1164c
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb8e5(%rip), %rcx      # 0x1cb5d
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 0x1164c
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb8bb(%rip), %rcx      # 0x1cb66
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 0x1164c
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb88d(%rip), %rcx      # 0x1cb6c
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 0x1164c
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb860(%rip), %rcx      # 0x1cb73
movl $0x4, %r8d
xorl %esi, %esi
callq 0x45a0
movl 0x10(%r14), %ecx
leaq 0xb7d9(%rip), %rdx      # 0x1cb04
leaq 0x40(%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 0x1164c
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0xb813(%rip), %rcx      # 0x1cb78
movl $0x4, %r8d
xorl %esi, %esi
callq 0x45a0
movl 0x14(%r14), %ecx
leaq 0xb787(%rip), %rdx      # 0x1cb04
leaq 0x40(%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 0x1164c
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x113bf
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 0x11436
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xb715(%rip), %rsi      # 0x1cb09
leaq 0xb717(%rip), %rdx      # 0x1cb12
leaq 0x58(%rsp), %rdi
callq 0x127a8
leaq 0x58(%rsp), %rdi
leaq 0x40(%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 0x11490
movups (%rcx), %xmm0
movups %xmm0, (%r13)
jmp 0x1149d
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0xb6f1(%rip), %rsi      # 0x1cb37
leaq 0xb709(%rip), %rdx      # 0x1cb56
leaq 0x20(%rsp), %rdi
callq 0x127a8
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 0x114ea
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x114f6
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 0xb653(%rip), %rsi      # 0x1cb13
callq 0x46a0
leaq 0x10(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x11538
movups (%rcx), %xmm0
leaq 0x10(%rsp), %rdx
movups %xmm0, (%rdx)
jmp 0x11544
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 0x11124
xorl %ebp, %ebp
leaq 0x14689(%rip), %rsi     # 0x25bb0
leaq -0x3a0(%rip), %rdx      # 0x1118e
movq %rbx, %rdi
callq 0x4620
jmp 0x11584
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 0x11124
xorl %ebp, %ebp
leaq 0x1463b(%rip), %rsi     # 0x25bb0
leaq -0x3ee(%rip), %rdx      # 0x1118e
movq %rbx, %rdi
callq 0x4620
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x115aa
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x115aa
movq %rax, %r14
movb $0x1, %bpl
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x115fb
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x115fb
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x115e4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x115e4
movq %rax, %r14
movb $0x1, %bpl
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x1161c
movq 0x30(%rsp), %rsi
jmp 0x1160a
movq %rax, %r14
movb $0x1, %bpl
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x1161c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x1161c
jmp 0x11616
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x11644
movq %rbx, %rdi
callq 0x42d0
jmp 0x11644
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x11644
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r14, %rdi
callq 0x4630