// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rdx, %rbp
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
andq $0x0, 0x10(%rax)
movq %rsi, %r12
movq %rdi, %rbx
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
leaq 0x80(%rsp), %rdx
callq 0x3130
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rsi
pushq $0x14
popq %rdx
callq 0x10f51
movq 0x10(%rbp), %r15
movq %rbp, %rdi
movq %r13, %rsi
callq 0x10e0f
movq %rbx, %rdi
movq %r13, %rsi
callq 0x12c6e
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
pushq $0x10
popq %rsi
callq 0x12d8c
leaq 0xbc(%rsp), %rdi
callq 0x33f0
testl %eax, %eax
je 0x111e7
movq (%r12), %rsi
movq 0x8(%r12), %rdx
leaq 0xbc(%rsp), %rdi
callq 0x3080
testl %eax, %eax
je 0x11203
movq (%rbx), %rsi
movq 0x10(%rbx), %rdx
leaq 0xbc(%rsp), %rdi
callq 0x3080
testl %eax, %eax
je 0x1121f
movq (%rsp), %rdi
leaq 0xbc(%rsp), %rsi
callq 0x3260
testl %eax, %eax
je 0x1123b
leaq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movl $0x10d, %esi            # imm = 0x10D
xorl %ecx, %ecx
callq 0x125da
movq 0x10(%rbx), %rdx
addq 0x8(%r12), %rdx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %rdx
ja 0x11118
leaq 0x18(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1263a
jmp 0x11127
leaq 0x18(%rsp), %rdi
movl $0x10e, %esi            # imm = 0x10E
callq 0x12996
leaq 0x18(%rsp), %rdi
movq %rsp, %rdx
movl $0x3ec, %esi            # imm = 0x3EC
callq 0x12db8
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, %r15
ja 0x11157
leaq 0x18(%rsp), %rdi
movl $0x3ef, %esi            # imm = 0x3EF
movl %r15d, %edx
callq 0x1263a
jmp 0x11169
leaq 0x18(%rsp), %rdi
movl $0x10f, %esi            # imm = 0x10F
movq %r15, %rdx
callq 0x12996
leaq 0x98(%rsp), %rdi
leaq 0x18(%rsp), %rsi
pushq $0x3e
popq %rdx
callq 0x129fc
leaq 0x98(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x32d0
movq %r15, %rdi
callq 0x33a0
xorl %r15d, %r15d
subl 0x8(%r14), %r15d
andl $0x7, %r15d
subq $0x1, %r15
jb 0x111b6
movq %r14, %rdi
xorl %esi, %esi
callq 0x3660
jmp 0x111a4
movq %rsp, %rdi
callq 0x143fc
leaq 0x60(%rsp), %rdi
callq 0x33a0
leaq 0x18(%rsp), %rdi
callq 0x12be2
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3230
movq %rax, %r15
leaq 0x7d15(%rip), %rsi      # 0x18f0e
movq %rax, %rdi
callq 0x3180
jmp 0x11255
pushq $0x10
popq %rdi
callq 0x3230
movq %rax, %r15
leaq 0x7d0b(%rip), %rsi      # 0x18f20
movq %rax, %rdi
callq 0x3180
jmp 0x11255
pushq $0x10
popq %rdi
callq 0x3230
movq %rax, %r15
leaq 0x7cef(%rip), %rsi      # 0x18f20
movq %rax, %rdi
callq 0x3180
jmp 0x11255
pushq $0x10
popq %rdi
callq 0x3230
movq %rax, %r15
leaq 0x7ce7(%rip), %rsi      # 0x18f34
movq %rax, %rdi
callq 0x3180
movq 0xcd8c(%rip), %rsi      # 0x1dfe8
movq 0xcd7d(%rip), %rdx      # 0x1dfe0
movq %r15, %rdi
callq 0x3350
jmp 0x11271
jmp 0x11271
jmp 0x11271
movq %rax, %r14
movq %r15, %rdi
callq 0x34f0
jmp 0x11295
jmp 0x11292
jmp 0x11292
jmp 0x11284
movq %rax, %r14
jmp 0x112af
movq %rax, %r14
jmp 0x112a5
jmp 0x11292
jmp 0x11292
movq %rax, %r14
movq %rsp, %rdi
callq 0x143fc
movq %rbx, %rdi
callq 0x12e30
leaq 0x60(%rsp), %rdi
callq 0x33a0
leaq 0x18(%rsp), %rdi
callq 0x12be2
movq %r14, %rdi
callq 0x3360