// File: /workspace/github_cpp_makefile_star2_O1/ivan-tkatchev[P]makerpm/makerpm.cc
// Function: make_index1(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, mfile&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
mfile make_index1(const std::string& index2, mfile& payload, const std::string& compressed_payload, std::string& header) {

    // Add signature fields.

    Store store;

    ////

    unsigned char sha1_raw[20];

    ::SHA1((const unsigned char*)index2.data(), index2.size(), sha1_raw);

    std::string sha1 = print_digest(sha1_raw, 20);

    uint64_t uncompressedsize = payload.size;

    ////

    compress_file(payload, compressed_payload);

    mfile ret(compressed_payload);

    ////

    std::vector<unsigned char> md5;
    md5.resize(16);

    MD5_CTX md5_c;

    if (!::MD5_Init(&md5_c))
        throw std::runtime_error("MD5_Init() failed");

    if (!::MD5_Update(&md5_c, (const unsigned char*)index2.data(), index2.size()))
        throw std::runtime_error("MD5_Update() failed");

    if (!::MD5_Update(&md5_c, (const unsigned char*)ret.addr, ret.size))
        throw std::runtime_error("MD5_Update() failed");

    if (!::MD5_Final(&(md5[0]), &md5_c))
        throw std::runtime_error("MD5_Final() failed");

    ////

    store.add(rpm::TAG_SHA1HEADER, sha1, false);

    uint64_t size = index2.size() + ret.size;

    if (size < 0xFFFFFFFF) {
        store.add(rpm::TAG_SIGSIZE, (uint32_t)size);
    } else {
        store.add(rpm::TAG_SIGLONGSIZE, size);
    }

    store.add(rpm::TAG_MD5, md5);

    if (uncompressedsize < 0xFFFFFFFF) {
        store.add(rpm::TAG_PAYLOADSIZE, (uint32_t)uncompressedsize);
    } else {
        store.add(rpm::TAG_PAYLOADLONGSIZE, uncompressedsize);
    }

    header = store.str(rpm::TAG_HEADERSIGNATURES);

    // Align the data to 8 bytes.

    size_t n = header.size();
    size_t q = (8 - (n % 8)) % 8;

    while (q > 0) {
        header += '\0';
        --q;
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x28(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x48(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq %rax, 0x10(%rcx)
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
leaq 0x80(%rsp), %rdx
callq 0x3130
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0x14, %edx
callq 0x106a1
movq 0x10(%rbp), %r15
movq %rbp, %rdi
movq %r13, %rsi
callq 0x1054a
movq %rbx, %rdi
movq %r13, %rsi
callq 0x12b98
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x10, %esi
callq 0x12ccc
leaq 0xbc(%rsp), %rdi
callq 0x3400
testl %eax, %eax
je 0x10986
movq (%r12), %rsi
movq 0x8(%r12), %rdx
leaq 0xbc(%rsp), %rdi
callq 0x3090
testl %eax, %eax
je 0x109a4
movq (%rbx), %rsi
movq 0x10(%rbx), %rdx
leaq 0xbc(%rsp), %rdi
callq 0x3090
testl %eax, %eax
je 0x109c2
movq (%rsp), %rdi
leaq 0xbc(%rsp), %rsi
callq 0x3270
testl %eax, %eax
je 0x109e0
leaq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movl $0x10d, %esi            # imm = 0x10D
xorl %ecx, %ecx
callq 0x1241e
movq 0x10(%rbx), %rdx
addq 0x8(%r12), %rdx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %rdx
ja 0x1087c
leaq 0x18(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x12484
jmp 0x1088b
leaq 0x18(%rsp), %rdi
movl $0x10e, %esi            # imm = 0x10E
callq 0x12792
leaq 0x18(%rsp), %rdi
movq %rsp, %rdx
movl $0x3ec, %esi            # imm = 0x3EC
callq 0x12cf8
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %r15
ja 0x108bb
leaq 0x18(%rsp), %rdi
movl $0x3ef, %esi            # imm = 0x3EF
movl %r15d, %edx
callq 0x12484
jmp 0x108cd
leaq 0x18(%rsp), %rdi
movl $0x10f, %esi            # imm = 0x10F
movq %r15, %rdx
callq 0x12792
leaq 0x98(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x3e, %edx
callq 0x127fc
leaq 0x98(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x32e0
movq (%r15), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1090c
callq 0x32f0
xorl %r15d, %r15d
subl 0x8(%r14), %r15d
andl $0x7, %r15d
je 0x10928
movq %r14, %rdi
xorl %esi, %esi
callq 0x3690
decq %r15
jne 0x10919
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x10936
callq 0x32f0
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10949
callq 0x32f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1095d
callq 0x32f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x10971
callq 0x32f0
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8df8(%rip), %rsi      # 0x19792
movq %rax, %rdi
callq 0x3190
jmp 0x109fc
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8dec(%rip), %rsi      # 0x197a4
movq %rax, %rdi
callq 0x3190
jmp 0x109fc
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8dce(%rip), %rsi      # 0x197a4
movq %rax, %rdi
callq 0x3190
jmp 0x109fc
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8dc4(%rip), %rsi      # 0x197b8
movq %rax, %rdi
callq 0x3190
movq 0xc5e5(%rip), %rsi      # 0x1cfe8
movq 0xc5d6(%rip), %rdx      # 0x1cfe0
movq %r15, %rdi
callq 0x3360
jmp 0x10a18
jmp 0x10a18
jmp 0x10a18
movq %rax, %r14
movq %r15, %rdi
callq 0x3500
jmp 0x10a3c
jmp 0x10a39
jmp 0x10a39
jmp 0x10a2b
movq %rax, %r14
jmp 0x10a65
movq %rax, %r14
jmp 0x10a52
jmp 0x10a39
jmp 0x10a39
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x10a4a
callq 0x32f0
movq %rbx, %rdi
callq 0x12d74
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x10a65
callq 0x32f0
leaq 0x18(%rsp), %rdi
callq 0x12aec
movq %r14, %rdi
callq 0x3370