// File: /workspace/github_c_makefile_star2_O3/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, 0x1c56c(%rip)     # 0x21b48
je 0x57f8
movq %rsi, %rbx
movq (%rsp), %r14
leaq 0x5efd(%r14), %r8
leaq 0xce15(%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 0x33f8
cmpl $0x2, %eax
jl 0x570e
movq %r15, %rdi
callq 0x3394
testq %rax, %rax
je 0x570e
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 0xcd92(%rip), %rdx      # 0x1240c
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2140
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2370
cmpl $-0x1, %eax
je 0x56c6
movq 0x1ecbd(%rip), %r12     # 0x24358
testq %r12, %r12
je 0x56fa
cmpl $0x0, 0x1bc45(%rip)     # 0x212ec
jle 0x56fa
callq 0x7f05
testl %eax, %eax
movq 0x8(%rsp), %rsi
movl $0x0, %eax
cmoveq %rax, %rsi
movq %r14, %rdi
callq *%r12
jmp 0x56fa
callq 0x2060
movl (%rax), %edi
cmpl $0x11, %edi
je 0x56fa
callq 0x23b0
leaq 0xe28c(%rip), %rdi      # 0x1396a
leaq 0xccfa(%rip), %rsi      # 0x123df
movl $0x879, %edx            # imm = 0x879
movq %r13, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc84f
movq %r15, %rdi
callq 0x3394
movq %rax, %r14
testq %rax, %rax
jne 0x5653
movq (%rsp), %rax
leaq 0x15ec8(%rax), %r15
movq %r15, %rdi
callq 0x33f8
cmpl $0x2, %eax
jl 0x57f8
movq %r15, %rdi
callq 0x3394
testq %rax, %rax
je 0x57f8
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 0xccaa(%rip), %rdx      # 0x1240c
movq %rbx, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x2140
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2370
cmpl $-0x1, %eax
je 0x57b0
movq 0x1ebd2(%rip), %r12     # 0x24358
testq %r12, %r12
je 0x57e4
cmpl $0x0, 0x1bb5a(%rip)     # 0x212ec
jle 0x57e4
callq 0x7f05
testl %eax, %eax
movq (%rsp), %rsi
movl $0x0, %eax
cmoveq %rax, %rsi
movq %r14, %rdi
callq *%r12
jmp 0x57e4
callq 0x2060
movl (%rax), %edi
cmpl $0x11, %edi
je 0x57e4
callq 0x23b0
leaq 0xe1a2(%rip), %rdi      # 0x1396a
leaq 0xcc10(%rip), %rsi      # 0x123df
movl $0x897, %edx            # imm = 0x897
movq %r13, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc84f
movq %r15, %rdi
callq 0x3394
movq %rax, %r14
testq %rax, %rax
jne 0x5753
xorl %eax, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq