// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/mime.c
// Function: MIME_generate_multiple_hardlink_filenames
int MIME_generate_multiple_hardlink_filenames(struct MIMEH_header_info *hinfo, char *unpackdir)
{
    char *name;
    char oldname[1024];

    if (glb.multiple_filenames == 0) return 0;

    //LOGGER_log("%s:%d:MIME_generate_multiple_hardlink_filenames:DEBUG: Generating hardlinks for %s",FL, hinfo->filename);
    snprintf(oldname,sizeof(oldname),"%s/%s",unpackdir, hinfo->filename);

    if (SS_count(&(hinfo->ss_names)) > 1){
        do {

            name = SS_pop(&(hinfo->ss_names));
            if (name != NULL)
            {
                char *np;
                char newname[1024];
                int rv;

                /** Strip off any leading path **/
                np = strrchr(name, '/');
                if (np) np++; else np = name;

                snprintf(newname,sizeof(newname),"%s/%s",unpackdir, np);
                //LOGGER_log("%s:%d:MIME_generate_multiple_hardlink_filenames:DEBUG: Linking %s->%s",FL,newname, oldname);
                rv = link(oldname, newname);
                if (rv == -1)
                {
                    if (errno != EEXIST)
                    {
                        LOGGER_log("%s:%d:MIME_generate_multiple_hardlink_filenames:WARNING: While trying to create '%s' link to '%s' (%s)",FL, newname, oldname,strerror(errno));
                    }

                } else {
                    if ((glb.filename_decoded_reporter != NULL)&&(MIME_VERBOSE))
                    {
                        glb.filename_decoded_reporter( name, (MIMEH_get_verbosity_contenttype()?hinfo->content_type_string:NULL));
                    }
                }
            }

        } while(name != NULL);
    }

    if (SS_count(&(hinfo->ss_filenames)) > 1) {
        do {

            name = SS_pop(&(hinfo->ss_filenames));
            if (name != NULL)
            {
                char newname[1024];
                int rv;

                snprintf(newname,sizeof(newname),"%s/%s",unpackdir, name);
                //LOGGER_log("%s:%d:MIME_generate_multiple_hardlink_filenames:DEBUG: Linking %s->%s",FL,newname, oldname);
                rv = link(oldname, newname);
                if (rv == -1)
                {
                    if (errno != EEXIST)
                    {
                        LOGGER_log("%s:%d:MIME_generate_multiple_hardlink_filenames:WARNING: While trying to create '%s' link to '%s' (%s)",FL, newname, oldname,strerror(errno));
                    }

                } else {
                    if ((glb.filename_decoded_reporter != NULL)&&(MIME_VERBOSE))
                    {
                        glb.filename_decoded_reporter( name, (MIMEH_get_verbosity_contenttype()?hinfo->content_type_string:NULL));
                    }
                }
            }

        } while(name != NULL);
    }

    return 0;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movq %rdi, (%rsp)
cmpl $0x0, 0x1c4f0(%rip)     # 0x21b48
je 0x5874
movq %rsi, %rbx
movq (%rsp), %r14
leaq 0x5efd(%r14), %r8
leaq 0xcd99(%rip), %rdx      # 0x1240c
leaq 0x10(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2140
leaq 0x162e0(%r14), %r15
movq %r15, %rdi
callq 0x342c
cmpl $0x2, %eax
jl 0x578a
movq %r15, %rdi
callq 0x33c8
testq %rax, %rax
je 0x578a
movq %rax, %r14
movq (%rsp), %rax
addq $0x27fc, %rax           # imm = 0x27FC
movq %rax, 0x8(%rsp)
leaq 0x410(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r14, %rdi
movl $0x2f, %esi
callq 0x2150
leaq 0x1(%rax), %r8
testq %rax, %rax
cmoveq %r14, %r8
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
leaq 0xcd16(%rip), %rdx      # 0x1240c
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2140
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2380
cmpl $-0x1, %eax
je 0x5742
movq 0x1ec41(%rip), %r12     # 0x24358
testq %r12, %r12
je 0x5776
cmpl $0x0, 0x1bbc9(%rip)     # 0x212ec
jle 0x5776
callq 0x7fbd
testl %eax, %eax
movq 0x8(%rsp), %rsi
movl $0x0, %eax
cmoveq %rax, %rsi
movq %r14, %rdi
callq *%r12
jmp 0x5776
callq 0x2060
movl (%rax), %edi
cmpl $0x11, %edi
je 0x5776
callq 0x23c0
leaq 0xe1e0(%rip), %rdi      # 0x1393a
leaq 0xcc7e(%rip), %rsi      # 0x123df
movl $0x879, %edx            # imm = 0x879
movq %r13, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc960
movq %r15, %rdi
callq 0x33c8
movq %rax, %r14
testq %rax, %rax
jne 0x56cf
movq (%rsp), %rax
leaq 0x15ec8(%rax), %r15
movq %r15, %rdi
callq 0x342c
cmpl $0x2, %eax
jl 0x5874
movq %r15, %rdi
callq 0x33c8
testq %rax, %rax
je 0x5874
movq %rax, %r14
addq $0x27fc, (%rsp)         # imm = 0x27FC
leaq 0x410(%rsp), %r13
leaq 0x10(%rsp), %rbp
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
leaq 0xcc2e(%rip), %rdx      # 0x1240c
movq %rbx, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x2140
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2380
cmpl $-0x1, %eax
je 0x582c
movq 0x1eb56(%rip), %r12     # 0x24358
testq %r12, %r12
je 0x5860
cmpl $0x0, 0x1bade(%rip)     # 0x212ec
jle 0x5860
callq 0x7fbd
testl %eax, %eax
movq (%rsp), %rsi
movl $0x0, %eax
cmoveq %rax, %rsi
movq %r14, %rdi
callq *%r12
jmp 0x5860
callq 0x2060
movl (%rax), %edi
cmpl $0x11, %edi
je 0x5860
callq 0x23c0
leaq 0xe0f6(%rip), %rdi      # 0x1393a
leaq 0xcb94(%rip), %rsi      # 0x123df
movl $0x897, %edx            # imm = 0x897
movq %r13, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc960
movq %r15, %rdi
callq 0x33c8
movq %rax, %r14
testq %rax, %rax
jne 0x57cf
xorl %eax, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq