// File: /workspace/github_c_makefile_star2_O2/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, 0x1b740(%rip)     # 0x20b48
je 0x560b
movq %rsi, %rbx
movq (%rsp), %r14
leaq 0x5efd(%r14), %r8
leaq 0xbfe9(%rip), %rdx      # 0x1140c
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 0x32cd
cmpl $0x2, %eax
jl 0x5530
movq (%rsp), %rax
addq $0x27fc, %rax           # imm = 0x27FC
movq %rax, 0x8(%rsp)
leaq 0x410(%rsp), %r13
leaq 0x10(%rsp), %r14
movq %r15, %rdi
callq 0x3269
testq %rax, %rax
je 0x5530
movq %rax, %rbp
movq %rax, %rdi
pushq $0x2f
popq %rsi
callq 0x2150
leaq 0x1(%rax), %r8
testq %rax, %rax
cmoveq %rbp, %r8
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
leaq 0xbf68(%rip), %rdx      # 0x1140c
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2140
movq %r14, %rdi
movq %r13, %rsi
callq 0x2380
cmpl $-0x1, %eax
je 0x54f3
movq 0x1de93(%rip), %r12     # 0x23358
testq %r12, %r12
je 0x546b
cmpl $0x0, 0x1ae1b(%rip)     # 0x202ec
jle 0x546b
callq 0x7c9c
testl %eax, %eax
movq 0x8(%rsp), %rsi
movl $0x0, %eax
cmoveq %rax, %rsi
movq %rbp, %rdi
callq *%r12
jmp 0x546b
callq 0x2060
movl (%rax), %edi
cmpl $0x11, %edi
je 0x546b
callq 0x23c0
leaq 0xd45b(%rip), %rdi      # 0x1296a
leaq 0xbec9(%rip), %rsi      # 0x113df
movl $0x879, %edx            # imm = 0x879
movq %r13, %rcx
movq %r14, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc2a1
jmp 0x546b
movq (%rsp), %rax
leaq 0x15ec8(%rax), %r15
movq %r15, %rdi
callq 0x32cd
cmpl $0x2, %eax
jl 0x560b
addq $0x27fc, (%rsp)         # imm = 0x27FC
leaq 0x410(%rsp), %r12
leaq 0x10(%rsp), %r13
movq %r15, %rdi
callq 0x3269
testq %rax, %rax
je 0x560b
movq %rax, %rbp
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
leaq 0xbe88(%rip), %rdx      # 0x1140c
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x2140
movq %r13, %rdi
movq %r12, %rsi
callq 0x2380
cmpl $-0x1, %eax
je 0x55d2
movq 0x1ddb0(%rip), %r14     # 0x23358
testq %r14, %r14
je 0x5561
cmpl $0x0, 0x1ad38(%rip)     # 0x202ec
jle 0x5561
callq 0x7c9c
testl %eax, %eax
movq (%rsp), %rsi
movl $0x0, %eax
cmoveq %rax, %rsi
movq %rbp, %rdi
callq *%r14
jmp 0x5561
callq 0x2060
movl (%rax), %edi
cmpl $0x11, %edi
je 0x5561
callq 0x23c0
leaq 0xd380(%rip), %rdi      # 0x1296a
leaq 0xbdee(%rip), %rsi      # 0x113df
movl $0x897, %edx            # imm = 0x897
movq %r12, %rcx
movq %r13, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xc2a1
jmp 0x5561
xorl %eax, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq