// File: /workspace/github_cpp_makefile_star2_O2/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 $0xe8, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
leaq 0x408(%rdx), %rbx
leaq 0x18(%rsp), %r13
movq %r13, %rdi
callq 0x12eec
movq %rbx, %rdi
movq %r13, %rsi
callq 0x14548
leaq 0x18(%rsp), %rdi
callq 0x12f8a
movq 0x410(%r12), %rbx
movq %r15, %rdi
callq 0x3620
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmpq %rcx, %rax
ja 0x11575
movl %eax, -0xd0(%rbx)
jmp 0x1157c
movq %rax, -0xc8(%rbx)
movq %r15, %rdi
callq 0x3140
movw %ax, -0xc0(%rbx)
movq %r15, %rdi
callq 0x3540
movw %ax, -0xbe(%rbx)
movq %r15, %rdi
callq 0x31a0
movl %eax, -0xbc(%rbx)
movq %r15, %rdi
callq 0x32b0
testq %rax, %rax
je 0x115c4
leaq -0x98(%rbx), %rdi
movq %rax, %rsi
callq 0x3670
movq %r15, %rdi
callq 0x3200
movl %eax, -0x2c(%rbx)
movq %r15, %rdi
callq 0x3190
movl %eax, -0x28(%rbx)
cmpq $0x0, 0x270(%r12)
je 0x115f8
leaq 0x268(%r12), %rsi
leaq -0x70(%rbx), %rdi
callq 0x3640
jmp 0x1163e
movq %r15, %rdi
callq 0x3170
testq %rax, %rax
je 0x11613
leaq -0x70(%rbx), %rdi
movq %rax, %rsi
callq 0x3670
jmp 0x1163e
movq %r15, %rdi
callq 0x30f0
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movl %eax, %esi
callq 0x11419
leaq -0x70(%rbx), %rdi
movq %r13, %rsi
callq 0x32d0
movq %r13, %rdi
callq 0x33a0
cmpq $0x0, 0x290(%r12)
je 0x1165e
addq $0x288, %r12            # imm = 0x288
leaq -0x50(%rbx), %rdi
movq %r12, %rsi
callq 0x3640
jmp 0x116a4
movq %r15, %rdi
callq 0x33b0
testq %rax, %rax
je 0x11679
leaq -0x50(%rbx), %rdi
movq %rax, %rsi
callq 0x3670
jmp 0x116a4
movq %r15, %rdi
callq 0x31d0
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movl %eax, %esi
callq 0x114b4
leaq -0x50(%rbx), %rdi
movq %r12, %rsi
callq 0x32d0
movq %r12, %rdi
callq 0x33a0
movq %r15, %rdi
callq 0x35f0
leaq -0x20(%rbx), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x3670
cmpq $0x2, -0x18(%rbx)
jb 0x11731
movq (%r15), %rax
cmpb $0x2e, (%rax)
jne 0x11731
cmpb $0x2f, 0x1(%rax)
jne 0x11731
testq %r14, %r14
je 0x116e1
movq (%r14), %rdi
movq 0x10(%r14), %rsi
movq %rsp, %rdx
jmp 0x116ed
leaq 0x7aa3(%rip), %rdi      # 0x1918b
movq %rsp, %rdx
xorl %esi, %esi
callq 0x3470
leaq 0x18(%rsp), %r14
movq %rsp, %rsi
pushq $0x10
popq %rdx
movq %r14, %rdi
callq 0x10f51
addq $-0xb8, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x33a0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3230
movq %rax, %rbx
leaq 0x7812(%rip), %rsi      # 0x18f55
leaq 0x18(%rsp), %rdi
movq %r15, %rdx
callq 0x12bf8
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x31b0
xorl %ebp, %ebp
movq 0xc87f(%rip), %rsi      # 0x1dfe8
movq 0xc870(%rip), %rdx      # 0x1dfe0
movq %rbx, %rdi
callq 0x3350
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x12f8a
jmp 0x117a6
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x33a0
testb %bpl, %bpl
jne 0x1179e
jmp 0x117a6
movq %rax, %r14
movq %rbx, %rdi
callq 0x34f0
movq %r14, %rdi
callq 0x3360