// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x90, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movl %edi, %ebp
cmpl $-0x1, %edi
jne 0xc659
callq 0x4260
movl %eax, %ebp
movl %ebp, %ecx
leaq 0xb4a0(%rip), %rdx      # 0x17b02
leaq 0x30(%rsp), %rdi
pushq $0x14
popq %rsi
xorl %eax, %eax
callq 0x45c0
callq 0x4050
movq %rax, %r12
andl $0x0, (%rax)
movl %ebp, %edi
callq 0x4440
testq %rax, %rax
je 0xc804
movq %rax, %r14
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xb4ae(%rip), %rsi      # 0x17b55
leaq 0x10(%rsp), %rdi
callq 0x4690
movq (%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x4680
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc958
leaq 0xb487(%rip), %rsi      # 0x17b5b
leaq 0x10(%rsp), %rdi
callq 0x4690
movq (%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x4680
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc958
leaq 0xb463(%rip), %rsi      # 0x17b64
leaq 0x10(%rsp), %rdi
callq 0x4690
movq 0x20(%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x4680
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc958
leaq 0xb43b(%rip), %rsi      # 0x17b6a
leaq 0x10(%rsp), %rdi
callq 0x4690
movq 0x28(%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x4680
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc958
leaq 0xb414(%rip), %rsi      # 0x17b71
leaq 0x10(%rsp), %rdi
callq 0x4690
movl 0x10(%r14), %ecx
leaq 0xb390(%rip), %rdx      # 0x17b02
leaq 0x30(%rsp), %r15
pushq $0x14
popq %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x45c0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x4680
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc958
leaq 0xb3cf(%rip), %rsi      # 0x17b76
leaq 0x10(%rsp), %rdi
callq 0x4690
movl 0x14(%r14), %ecx
leaq 0xb346(%rip), %rdx      # 0x17b02
leaq 0x30(%rsp), %r14
pushq $0x14
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x45c0
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4680
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xc958
leaq 0x10(%rsp), %rdi
callq 0x41a0
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl (%r12), %ebp
pushq $0x40
popq %rdi
callq 0x41d0
movq %rax, %rbx
testl %ebp, %ebp
jne 0xc884
leaq 0xb2e9(%rip), %rsi      # 0x17b07
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xb9ce
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xcb22
leaq 0xb2c9(%rip), %rdx      # 0x17b11
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xcb22
movb $0x1, %bpl
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc5fa
xorl %ebp, %ebp
leaq 0x1731d(%rip), %rsi     # 0x23b90
leaq -0x25a(%rip), %rdx      # 0xc620
movq %rbx, %rdi
callq 0x4610
jmp 0xc8e0
leaq 0xb2aa(%rip), %rsi      # 0x17b35
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0xb9ce
movl (%r12), %edi
callq 0x4130
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rax, %rdx
callq 0xcb22
movb $0x1, %bpl
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc5fa
xorl %ebp, %ebp
leaq 0x172bf(%rip), %rsi     # 0x23b90
leaq -0x2b8(%rip), %rdx      # 0xc620
movq %rbx, %rdi
callq 0x4610
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x41a0
jmp 0xc8f5
movq %rax, %r14
movb $0x1, %bpl
leaq 0x50(%rsp), %rdi
callq 0x41a0
jmp 0xc923
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x41a0
jmp 0xc916
movq %rax, %r14
movb $0x1, %bpl
leaq 0x50(%rsp), %rdi
jmp 0xc928
movq %rax, %r14
movb $0x1, %bpl
leaq 0x70(%rsp), %rdi
callq 0x41a0
testb %bpl, %bpl
jne 0xc939
jmp 0xc950
jmp 0xc936
movq %rax, %r14
movq %rbx, %rdi
callq 0x42d0
jmp 0xc950
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x41a0
movq %r14, %rdi
callq 0x4620