// File: /workspace/github_c_makefile_star2_O2/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 0x2e70
cmpb $0x0, 0x1(%rax)
je 0x2ea9
movq %rsp, %rsi
movq %rax, %rdi
callq 0x2240
pushq $-0x1
popq %rbp
testl %eax, %eax
je 0x2e96
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 0x2ec5
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 0x2dfe
movq 0x1c12c(%rip), %rax     # 0x1eff8
movq (%rax), %rcx
leaq 0xe510(%rip), %rdi      # 0x113e6
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x23a0
movq (%rbx), %rdi
callq 0x2100
testq %rax, %rax
je 0x2e82
movq %rax, %r14
leaq 0xe514(%rip), %r15      # 0x1140c
leaq 0x90(%rsp), %r12
movq %rsp, %r13
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x2280
testq %rax, %rax
je 0x2f98
cmpb $0x2e, 0x13(%rax)
jne 0x2f2e
cmpb $0x0, 0x14(%rax)
je 0x2f05
cmpb $0x2e, 0x14(%rax)
jne 0x2f2e
cmpb $0x0, 0x15(%rax)
je 0x2f05
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 0x2f05
movl 0x18(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x2f05
movq 0x1c05e(%rip), %rax     # 0x1efd0
movq (%rax), %rdi
leaq 0xe496(%rip), %rsi      # 0x11412
movq %r12, %rdx
xorl %eax, %eax
callq 0x2210
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2dfe
movl %eax, %ebp
jmp 0x2f05
movq %r14, %rdi
callq 0x21b0
jmp 0x2e82