// File: /workspace/github_cpp_makefile_star2_O3/ivan-tkatchev[P]makerpm/makerpm.cc
// Function: add_to_rpmprops(archive_entry*, mfile*, rpmprops_t&)
void add_to_rpmprops(struct archive_entry* entry, mfile* data, rpmprops_t& props) {

    props.files.push_back(rpmprops_t::file_t());

    rpmprops_t::file_t& f = props.files.back();

    uint64_t size = ::archive_entry_size(entry);

    if (size < 0xFFFFFFFF) {
        f.size = size;
    } else {
        f.longsize = size;
    }

    f.mode = ::archive_entry_mode(entry);
    f.rdev = ::archive_entry_rdev(entry);
    f.mtime = ::archive_entry_mtime(entry);

    const char* linkto = ::archive_entry_symlink(entry);
    if (linkto != NULL) {
        f.linkto = linkto;
    }

    f.device = ::archive_entry_dev(entry);
    f.inode = ::archive_entry_ino(entry);

    if (props.forceusername.size() > 0) {
        f.username = props.forceusername;

    } else {

        const char* uname = ::archive_entry_uname(entry);

        if (uname == NULL) {
            f.username = uid_to_uname(::archive_entry_uid(entry));
        } else {
            f.username = uname;
        }
    }

    if (props.forcegroupname.size() > 0) {
        f.groupname = props.forcegroupname;

    } else {

        const char* gname = ::archive_entry_gname(entry);

        if (gname == NULL) {
            f.groupname = gid_to_gname(::archive_entry_gid(entry));
        } else {
            f.groupname = gname;
        }
    }

    f.fname = ::archive_entry_pathname(entry);

    if (f.fname.size() < 2 ||
        f.fname[0] != '.' ||
        f.fname[1] != '/') {

        throw std::runtime_error("RPM requires a CPIO archive with relative paths that start with \"./\"!\n"
                                 "Malformed pathname in archive: " + f.fname);
    }

    unsigned char digest[16];
    if (data != nullptr) {
        ::MD5((const unsigned char*)data->addr, data->size, digest);
    } else {
        ::MD5((const unsigned char*)"", 0, digest);
    }
    f.digest = print_digest(digest, 16);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %r15
leaq 0x408(%rdx), %r14
leaq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x148c6
movq %r14, %rdi
movq %r13, %rsi
callq 0x16232
leaq 0xe8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128aa
callq 0x32f0
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128c0
callq 0x32f0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128d6
callq 0x32f0
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128e9
callq 0x32f0
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x128fc
callq 0x32f0
movq 0x410(%r12), %r14
movq %r15, %rdi
callq 0x3630
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmpq %rcx, %rax
ja 0x1291f
movl %eax, -0xd0(%r14)
jmp 0x12926
movq %rax, -0xc8(%r14)
movq %r15, %rdi
callq 0x3150
movw %ax, -0xc0(%r14)
movq %r15, %rdi
callq 0x3540
movw %ax, -0xbe(%r14)
movq %r15, %rdi
callq 0x31b0
movl %eax, -0xbc(%r14)
movq %r15, %rdi
callq 0x32b0
testq %rax, %rax
je 0x129a4
movq %rax, %r13
movq %r15, 0x8(%rsp)
movq %r12, %r15
movq %rbp, %r12
leaq -0x98(%r14), %rbp
movq -0x90(%r14), %rbx
movq %rax, %rdi
callq 0x3250
movq %rbp, %rdi
movq %r12, %rbp
movq %r15, %r12
movq 0x8(%rsp), %r15
xorl %esi, %esi
movq %rbx, %rdx
movq %r13, %rcx
movq %rax, %r8
callq 0x32d0
movq %r15, %rdi
callq 0x3210
movl %eax, -0x2c(%r14)
movq %r15, %rdi
callq 0x31a0
movl %eax, -0x28(%r14)
cmpq $0x0, 0x270(%r12)
je 0x129dd
leaq 0x268(%r12), %rsi
leaq -0x70(%r14), %rdi
callq 0x3660
jmp 0x12a5d
movq %r15, %rdi
callq 0x3180
testq %rax, %rax
je 0x12a28
movq %rax, %r13
leaq -0x70(%r14), %rbx
movq %r15, 0x8(%rsp)
movq %r12, %r15
movq %rbp, %r12
movq -0x68(%r14), %rbp
movq %rax, %rdi
callq 0x3250
movq %rbx, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r12, %rbp
movq %r15, %r12
movq 0x8(%rsp), %r15
movq %r13, %rcx
movq %rax, %r8
callq 0x32d0
jmp 0x12a5d
movq %r15, %rdi
callq 0x30f0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movl %eax, %esi
callq 0x12733
leaq -0x70(%r14), %rdi
movq %rbx, %rsi
callq 0x32e0
movq (%rbx), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x12a5d
callq 0x32f0
cmpq $0x0, 0x290(%r12)
je 0x12a7d
addq $0x288, %r12            # imm = 0x288
leaq -0x50(%r14), %rdi
movq %r12, %rsi
callq 0x3660
jmp 0x12ae7
movq %r15, %rdi
callq 0x33b0
testq %rax, %rax
je 0x12ab2
movq %rax, %r12
leaq -0x50(%r14), %rbx
movq -0x48(%r14), %r13
movq %rax, %rdi
callq 0x3250
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r12, %rcx
movq %rax, %r8
callq 0x32d0
jmp 0x12ae7
movq %r15, %rdi
callq 0x31e0
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movl %eax, %esi
callq 0x127e9
leaq -0x50(%r14), %rdi
movq %rbx, %rsi
callq 0x32e0
movq (%rbx), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x12ae7
callq 0x32f0
movq %r15, %rdi
callq 0x3610
movq %rax, %rbx
leaq -0x20(%r14), %r15
movq -0x18(%r14), %r12
movq %rax, %rdi
callq 0x3250
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x32d0
cmpq $0x2, -0x18(%r14)
jb 0x12ba2
movq (%r15), %rax
cmpb $0x2e, (%rax)
jne 0x12ba2
cmpb $0x2f, 0x1(%rax)
jne 0x12ba2
testq %rbp, %rbp
je 0x12b42
movq (%rbp), %rdi
movq 0x10(%rbp), %rsi
leaq 0x10(%rsp), %rdx
jmp 0x12b50
leaq 0x8642(%rip), %rdi      # 0x1b18b
leaq 0x10(%rsp), %rdx
xorl %esi, %esi
callq 0x3490
leaq 0x28(%rsp), %rbx
leaq 0x10(%rsp), %rsi
movl $0x10, %edx
movq %rbx, %rdi
callq 0x1213f
addq $-0xb8, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x32e0
movq (%rbx), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x12b90
callq 0x32f0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x3240
movq %rax, %rbx
leaq 0x839f(%rip), %rsi      # 0x1af55
leaq 0x28(%rsp), %rdi
movq %r15, %rdx
callq 0x145e8
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x31c0
xorl %ebp, %ebp
movq 0xc40c(%rip), %rsi      # 0x1efe8
movq 0xc3fd(%rip), %rdx      # 0x1efe0
movq %rbx, %rdi
callq 0x3360
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x1496c
jmp 0x12c22
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12c10
callq 0x32f0
testb %bpl, %bpl
jne 0x12c1a
jmp 0x12c22
movq %rax, %r14
movq %rbx, %rdi
callq 0x34f0
movq %r14, %rdi
callq 0x3370