// File: /workspace/github_c_makefile_star2_O1/inflex[P]ripMIME/ripmime.c
// Function: RIPMIME_unpack
int RIPMIME_unpack( struct RIPMIME_globals *glb )
{
   struct stat st;
   int stat_result = 0;
   int result = 0;
   int input_is_directory = 0;

   /** If we're not inputting from STDIN, check to see if the
     ** input is a directory **/
   if (strcmp(glb->inputfile,"-")!=0) {
       stat_result = stat(glb->inputfile, &st);
       if (stat_result != 0) return -1;

       if (S_ISDIR(st.st_mode)) input_is_directory = 1;
   }

   if (input_is_directory == 1) {
       /** Unpack all files in directory **/
       DIR *dir;
       struct dirent *dir_entry;

       fprintf(stderr,"input file is a directory, recursing\n");
       dir = opendir(glb->inputfile);
       if (dir == NULL) return -1;

       do {
           /** Check every entry in the directory provided and if it's a file
             ** try to unpack it **/
           char fullfilename[1024];

           dir_entry = readdir( dir );
           if (dir_entry == NULL) break;

           if (strcmp(dir_entry->d_name, ".")==0) continue;
           if (strcmp(dir_entry->d_name, "..")==0) continue;

           snprintf(fullfilename,sizeof(fullfilename),"%s/%s", glb->inputfile, dir_entry->d_name);
           stat_result = stat( fullfilename, &st );
           if (stat_result != 0) continue;
           if (S_ISREG(st.st_mode)) {
               /** If the directory entry is a file, then unpack it **/
               fprintf(stdout,"Unpacking mailpack %s\n",fullfilename);
               result = RIPMIME_unpack_single(glb, fullfilename);
           }
       } while (dir_entry != NULL); /** While more files in the directory **/

       closedir( dir );

   } else {
       /** If the supplied file was actually a normal file, then decode normally **/
       result = RIPMIME_unpack_single( glb, glb->inputfile );
   }
   return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x498, %rsp            # imm = 0x498
movq %rdi, %rbx
movq (%rdi), %r14
leaq 0x123d7(%rip), %rsi     # 0x15365
movq %r14, %rdi
callq 0x2200
testl %eax, %eax
je 0x2fd2
movq %rsp, %rsi
movq %r14, %rdi
callq 0x2250
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x2fc2
movl %ebp, %eax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
je 0x2fee
movq (%rbx), %rsi
movq %rbx, %rdi
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f1e
movq 0x1d003(%rip), %rax     # 0x1fff8
movq (%rax), %rcx
leaq 0xf3e7(%rip), %rdi      # 0x123e6
movl $0x25, %esi
movl $0x1, %edx
callq 0x23a0
movq (%rbx), %rdi
callq 0x2100
testq %rax, %rax
je 0x2fae
movq %rax, %r14
leaq 0x10f01(%rip), %r15     # 0x13f26
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x2290
movq %rax, %r12
testq %rax, %rax
je 0x30f6
leaq 0x13(%r12), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x2200
testl %eax, %eax
je 0x30f6
movq %r13, %rdi
leaq 0x10ec8(%rip), %rsi     # 0x13f25
callq 0x2200
testl %eax, %eax
je 0x30f6
movq (%rbx), %rcx
movl $0x400, %esi            # imm = 0x400
leaq 0x90(%rsp), %r15
movq %r15, %rdi
leaq 0xf388(%rip), %rdx      # 0x1240c
movq %r13, %r8
xorl %eax, %eax
callq 0x2140
movq %r15, %rdi
movq %rsp, %rsi
callq 0x2250
testl %eax, %eax
je 0x30a6
leaq 0x10e82(%rip), %r15     # 0x13f26
jmp 0x30f6
movl 0x18(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x8000, %eax           # imm = 0x8000
leaq 0x10e69(%rip), %r15     # 0x13f26
jne 0x30f6
movq 0x1cf0a(%rip), %rax     # 0x1ffd0
movq (%rax), %rdi
leaq 0xf342(%rip), %rsi      # 0x12412
leaq 0x90(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x2220
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x10e37(%rip), %r15     # 0x13f26
callq 0x2f1e
movl %eax, %ebp
testq %r12, %r12
jne 0x3027
movq %r14, %rdi
callq 0x21b0
jmp 0x2fae