// File: /workspace/github_cpp_makefile_star2_O3/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 0x1213f
movq 0x10(%rbp), %r15
movq %rbp, %rdi
movq %r13, %rsi
callq 0x11fee
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1466a
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movl $0x10, %esi
callq 0x1479c
leaq 0xbc(%rsp), %rdi
callq 0x3400
testl %eax, %eax
je 0x12424
movq (%r12), %rsi
movq 0x8(%r12), %rdx
leaq 0xbc(%rsp), %rdi
callq 0x3090
testl %eax, %eax
je 0x12442
movq (%rbx), %rsi
movq 0x10(%rbx), %rdx
leaq 0xbc(%rsp), %rdi
callq 0x3090
testl %eax, %eax
je 0x12460
movq (%rsp), %rdi
leaq 0xbc(%rsp), %rsi
callq 0x3270
testl %eax, %eax
je 0x1247e
leaq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movl $0x10d, %esi            # imm = 0x10D
xorl %ecx, %ecx
callq 0x13ed4
movq 0x10(%rbx), %rdx
addq 0x8(%r12), %rdx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %rdx
ja 0x1231a
leaq 0x18(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x13f3a
jmp 0x12329
leaq 0x18(%rsp), %rdi
movl $0x10e, %esi            # imm = 0x10E
callq 0x1425a
leaq 0x18(%rsp), %rdi
movq %rsp, %rdx
movl $0x3ec, %esi            # imm = 0x3EC
callq 0x147c8
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %r15
ja 0x12359
leaq 0x18(%rsp), %rdi
movl $0x3ef, %esi            # imm = 0x3EF
movl %r15d, %edx
callq 0x13f3a
jmp 0x1236b
leaq 0x18(%rsp), %rdi
movl $0x10f, %esi            # imm = 0x10F
movq %r15, %rdx
callq 0x1425a
leaq 0x98(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0x3e, %edx
callq 0x142c8
leaq 0x98(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x32e0
movq (%r15), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x123aa
callq 0x32f0
xorl %r15d, %r15d
subl 0x8(%r14), %r15d
andl $0x7, %r15d
je 0x123c6
movq %r14, %rdi
xorl %esi, %esi
callq 0x3680
decq %r15
jne 0x123b7
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x123d4
callq 0x32f0
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x123e7
callq 0x32f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x123fb
callq 0x32f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1240f
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 0x8ad6(%rip), %rsi      # 0x1af0e
movq %rax, %rdi
callq 0x3190
jmp 0x1249a
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8aca(%rip), %rsi      # 0x1af20
movq %rax, %rdi
callq 0x3190
jmp 0x1249a
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8aac(%rip), %rsi      # 0x1af20
movq %rax, %rdi
callq 0x3190
jmp 0x1249a
movl $0x10, %edi
callq 0x3240
movq %rax, %r15
leaq 0x8aa2(%rip), %rsi      # 0x1af34
movq %rax, %rdi
callq 0x3190
movq 0xcb47(%rip), %rsi      # 0x1efe8
movq 0xcb38(%rip), %rdx      # 0x1efe0
movq %r15, %rdi
callq 0x3360
jmp 0x124b6
jmp 0x124b6
jmp 0x124b6
movq %rax, %r14
movq %r15, %rdi
callq 0x34f0
jmp 0x124da
jmp 0x124d7
jmp 0x124d7
jmp 0x124c9
movq %rax, %r14
jmp 0x12503
movq %rax, %r14
jmp 0x124f0
jmp 0x124d7
jmp 0x124d7
movq %rax, %r14
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x124e8
callq 0x32f0
movq %rbx, %rdi
callq 0x14844
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12503
callq 0x32f0
leaq 0x18(%rsp), %rdi
callq 0x145be
movq %r14, %rdi
callq 0x3370