// File: /workspace/github_c_makefile_star2_O3/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), %rax
cmpb $0x2d, (%rax)
jne 0x2f82
cmpb $0x0, 0x1(%rax)
je 0x2fbd
movq %rsp, %rsi
movq %rax, %rdi
callq 0x2240
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
je 0x2faa
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 0x2fd9
movq (%rbx), %rax
movq %rbx, %rdi
movq %rax, %rsi
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f0e
movq 0x1d018(%rip), %rax     # 0x1fff8
movq (%rax), %rcx
leaq 0xf3fc(%rip), %rdi      # 0x123e6
movl $0x25, %esi
movl $0x1, %edx
callq 0x2390
movq (%rbx), %rdi
callq 0x2100
testq %rax, %rax
je 0x2f96
movq %rax, %r14
movq %rax, %rdi
callq 0x2280
testq %rax, %rax
je 0x30be
leaq 0xf3eb(%rip), %r15      # 0x1240c
leaq 0x90(%rsp), %r12
movq %rsp, %r13
xorl %ebp, %ebp
cmpb $0x2e, 0x13(%rax)
jne 0x3046
cmpb $0x0, 0x14(%rax)
je 0x30ab
cmpb $0x2e, 0x14(%rax)
jne 0x3046
cmpb $0x0, 0x15(%rax)
je 0x30ab
addq $0x13, %rax
movq (%rbx), %rcx
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
movq %r15, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x2140
movq %r12, %rdi
movq %r13, %rsi
callq 0x2240
testl %eax, %eax
jne 0x30ab
movl 0x18(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x30ab
movq 0x1cf46(%rip), %rax     # 0x1ffd0
movq (%rax), %rdi
leaq 0xf37e(%rip), %rsi      # 0x12412
movq %r12, %rdx
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2f0e
movl %eax, %ebp
movq %r14, %rdi
callq 0x2280
testq %rax, %rax
jne 0x302e
jmp 0x30c0
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x21b0
jmp 0x2f96