//////////////////////////////////////////////////////////////////////////////
//                                                                           /
// IAR ARM ANSI C/C++ Compiler V4.40A/W32 EVALUATION   28/Mar/2008  19:05:03 /
// Copyright 1999-2005 IAR Systems. All rights reserved.                     /
//                                                                           /
//    Cpu mode        =  interwork                                           /
//    Endian          =  little                                              /
//    Stack alignment =  4                                                   /
//    Source file     =  E:\Ivo\arm\IVOPLAY\medialibrary.c                   /
//    Command line    =  E:\Ivo\arm\IVOPLAY\medialibrary.c -D NEWSGOLD -lC   /
//                       E:\Ivo\arm\IVOPLAY\NewSGold\List\ -lA               /
//                       E:\Ivo\arm\IVOPLAY\NewSGold\List\ -o                /
//                       E:\Ivo\arm\IVOPLAY\NewSGold\Obj\ -s9 --no_cse       /
//                       --no_unroll --no_inline --no_code_motion --no_tbaa  /
//                       --no_clustering --no_scheduling --cpu_mode arm      /
//                       --endian little --cpu ARM926EJ-S --stack_align 4    /
//                       --interwork -e --fpu None --dlib_config             /
//                       D:\arm\ARM\LIB\dl5tpainl8n.h -I D:\arm\ARM\INC\     /
//    List file       =  E:\Ivo\arm\IVOPLAY\NewSGold\List\medialibrary.s79   /
//                                                                           /
//                                                                           /
//////////////////////////////////////////////////////////////////////////////

        NAME medialibrary

        RTMODEL "StackAlign4", "USED"
        RTMODEL "__cpu_mode", "__pcs__interwork"
        RTMODEL "__data_model", "absolute"
        RTMODEL "__endian", "little"
        RTMODEL "__rt_version", "6"

        RSEG CSTACK:DATA:NOROOT(2)

        MULTWEAK ??BEER??rT
        MULTWEAK ??CreateMediaLibrary??rT
??DataTable0 EQU 0
??DataTable1 EQU 0
        MULTWEAK ??IsFile??rA
        MULTWEAK ??strcmp_nocase??rA
        PUBWEAK ?init?tab?DATA_Z
        PUBLIC BEER
        FUNCTION BEER,0203H
        LOCFRAME CSTACK, 1348, STACK
        PUBLIC CreateMediaLibrary
        FUNCTION CreateMediaLibrary,0203H
        LOCFRAME CSTACK, 1308, STACK
        PUBLIC nname
        
        CFI Names cfiNames0
        CFI StackFrame CFA R13 HUGEDATA
        CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32
        CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, CPSR:32, R13:32
        CFI Resource R14:32, SPSR:32
        CFI VirtualResource ?RET:32
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 2
        CFI DataAlign 4
        CFI ReturnAddress ?RET CODE
        CFI CFA R13+0
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI R8 SameValue
        CFI R9 SameValue
        CFI R10 SameValue
        CFI R11 SameValue
        CFI R12 Undefined
        CFI CPSR SameValue
        CFI R14 Undefined
        CFI SPSR SameValue
        CFI ?RET R14
        CFI EndCommon cfiCommon0
        
        
        CFI Common cfiCommon1 Using cfiNames0
        CFI CodeAlign 4
        CFI DataAlign 4
        CFI ReturnAddress ?RET CODE
        CFI CFA R13+0
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 SameValue
        CFI R5 SameValue
        CFI R6 SameValue
        CFI R7 SameValue
        CFI R8 SameValue
        CFI R9 SameValue
        CFI R10 SameValue
        CFI R11 SameValue
        CFI R12 Undefined
        CFI CPSR SameValue
        CFI R14 Undefined
        CFI SPSR SameValue
        CFI ?RET R14
        CFI EndCommon cfiCommon1
        
IsFile              SYMBOL "IsFile"
strcmp_nocase       SYMBOL "strcmp_nocase"
BEER                SYMBOL "BEER"
??BEER??rT          SYMBOL "??rT", BEER
CreateMediaLibrary  SYMBOL "CreateMediaLibrary"
??CreateMediaLibrary??rT SYMBOL "??rT", CreateMediaLibrary
??IsFile??rA        SYMBOL "??rA", IsFile
??strcmp_nocase??rA SYMBOL "??rA", strcmp_nocase

        EXTERN IsFile
        FUNCTION IsFile,0202H
        EXTERN format_1
        EXTERN format_2
        EXTERN format_3
        EXTERN format_4
        EXTERN strcmp_nocase
        FUNCTION strcmp_nocase,0202H

// E:\Ivo\arm\IVOPLAY\medialibrary.c
//    1 #include "../inc/swilib.h"
//    2 #include "conf_loader.h"
//    3 #include "main.h"
//    4 

        RSEG DATA_Z:DATA:SORT:NOROOT(2)
//    5 char nname[256];
nname:
        DS8 256

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock0 Using cfiCommon0
        CFI NoFunction
        THUMB
??BEER??rT:
        BX       PC
        Nop      
        CFI EndBlock cfiBlock0
        REQUIRE BEER
//    6 extern const char format_1[4],format_2[4],format_3[4],format_4[4];
//    7 

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock1 Using cfiCommon1
        CFI Function BEER
        ARM
//    8 void BEER(char *foldeer)
//    9 {
BEER:
        PUSH     {R4,R5,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R5 Frame(CFA, -8)
        CFI R4 Frame(CFA, -12)
        CFI CFA R13+12
        SUB      SP,SP,#+308
        CFI CFA R13+320
        SUB      SP,SP,#+1024
        CFI CFA R13+1344
//   10   DIR_ENTRY de;
//   11   unsigned int err;
//   12   char path[128],ddd[320];
//   13   sprintf(path,"%s\\*",foldeer);
        MOV      R2,R0
        LDR      R1,??BEER_0+0x4  ;; `?<Constant "%s\\\\*">`
        ADD      R0,SP,#+140
        ADD      R0,R0,#+1024
        SWI      +22
//   14   path[0]='0';
        MOV      R1,#+48
        STRB     R1,[SP, #+1164]
//   15   FSTATS stat;
//   16   if (FindFirstFile(&de,path,&err))
        MOV      R2,SP
        ADD      R1,SP,#+140
        ADD      R1,R1,#+1024
        ADD      R0,SP,#+8
        SWI      +107
        CMP      R0,#+0
        BEQ      ??BEER_1
//   17   {
//   18     do
//   19     {
//   20       if (!IsFile(de.file_name))
??BEER_2:
        ADD      R0,SP,#+189
        _BLF     IsFile,??IsFile??rA
        CMP      R0,#+0
        ADD      R3,SP,#+189
        ADD      R2,SP,#+60
        LDR      R1,??DataTable2  ;; `?<Constant "%s\\\\%s">`
        ADD      R0,SP,#+844
        BNE      ??BEER_3
//   21       {
//   22         sprintf(ddd,"%s\\%s",de.folder_name,de.file_name);
        SWI      +22
//   23         BEER(ddd);
        ADD      R0,SP,#+844
        BL       BEER
//   24         rmdir(ddd,&err);
        MOV      R1,SP
        ADD      R0,SP,#+844
        SWI      +143
        B        ??BEER_4
//   25       }
//   26       else
//   27       {
//   28         sprintf(ddd,"%s\\%s",de.folder_name,de.file_name);
??BEER_3:
        SWI      +22
//   29         ddd[0]='4';
        MOV      R1,#+52
        STRB     R1,[SP, #+844]
//   30         char extension[3];
//   31         sprintf(extension,"%c%c%c",de.file_name[strlen(de.file_name)-3],de.file_name[strlen(de.file_name)-2],de.file_name[strlen(de.file_name)-1]);
        ADD      R0,SP,#+189
        SWI      +27
        MOV      R4,R0
        ADD      R0,SP,#+189
        SWI      +27
        MOV      R5,R0
        ADD      R0,SP,#+189
        SWI      +27
        ADD      R1,SP,#+8
        ADD      R1,R4,R1
        LDRB     R1,[R1, #+180]
        PUSH     {R1}
        CFI CFA R13+1348
        ADD      R1,SP,#+12
        ADD      R1,R5,R1
        LDRB     R3,[R1, #+179]
        ADD      R1,SP,#+12
        ADD      R0,R0,R1
        LDRB     R2,[R0, #+178]
        LDR      R1,??DataTable3  ;; `?<Constant "%c%c%c">`
        ADD      R0,SP,#+8
        SWI      +22
//   32         if (strcmp_nocase(extension,"imy")==0)
        ADR      R1,??BEER_0      ;; "imy"
        ADD      R0,SP,#+8
        _BLF     strcmp_nocase,??strcmp_nocase??rA
        CMP      R0,#+0
        ADD      SP,SP,#+4        ;; stack cleaning
        CFI CFA R13+1344
        BNE      ??BEER_4
//   33         {
//   34           ddd[strlen(ddd)-4]=0;
        ADD      R0,SP,#+844
        SWI      +27
        ADD      R1,SP,#+844
        ADD      R0,R0,R1
        MOV      R1,#+0
        STRB     R1,[R0, #-4]
//   35           if (GetFileStats(ddd, &stat, &err))
        MOV      R2,SP
        ADD      R1,SP,#+268
        ADD      R1,R1,#+1024
        ADD      R0,SP,#+844
        SWI      +132
        CMP      R0,#+0
        BEQ      ??BEER_4
//   36             {
//   37               ddd[0]='0';
        MOV      R1,#+48
        STRB     R1,[SP, #+844]
//   38               sprintf(ddd,"%s.imy",ddd);
        ADD      R2,SP,#+844
        LDR      R1,??BEER_0+0x8  ;; `?<Constant "%s.imy">`
        ADD      R0,SP,#+844
        SWI      +22
//   39               unlink(ddd,&err);
        MOV      R1,SP
        ADD      R0,SP,#+844
        SWI      +363
//   40             }
//   41         }
//   42       }
//   43     }
//   44     while(FindNextFile(&de,&err));
??BEER_4:
        MOV      R1,SP
        ADD      R0,SP,#+8
        SWI      +108
        CMP      R0,#+0
        BNE      ??BEER_2
//   45   }
//   46   FindClose(&de,&err);
??BEER_1:
        MOV      R1,SP
        ADD      R0,SP,#+8
        SWI      +109
//   47 }
        ADD      SP,SP,#+308      ;; stack cleaning
        CFI CFA R13+1036
        ADD      SP,SP,#+1024
        CFI CFA R13+12
        POP      {R4,R5,PC}       ;; return
        DATA
??BEER_0:
        DC8      "imy"
        DC32     `?<Constant "%s\\\\*">`
        DC32     `?<Constant "%s.imy">`
        CFI EndBlock cfiBlock1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock2 Using cfiCommon0
        CFI NoFunction
        THUMB
??CreateMediaLibrary??rT:
        BX       PC
        Nop      
        CFI EndBlock cfiBlock2
        REQUIRE CreateMediaLibrary
//   48 

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock3 Using cfiCommon1
        CFI Function CreateMediaLibrary
        ARM
//   49 int CreateMediaLibrary(char *foldeer)
//   50 {
CreateMediaLibrary:
        PUSH     {R4,R5,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R5 Frame(CFA, -8)
        CFI R4 Frame(CFA, -12)
        CFI CFA R13+12
        SUB      SP,SP,#+268
        CFI CFA R13+280
        SUB      SP,SP,#+1024
        CFI CFA R13+1304
//   51   DIR_ENTRY de;
//   52   unsigned int err;
//   53   int f;
//   54   char path[128],ddd[320];
//   55   sprintf(path,"%s%c",foldeer,'\\');
        MOV      R3,#+92
        MOV      R2,R0
        LDR      R1,??CreateMediaLibrary_0+0x4  ;; `?<Constant "%s%c">`
        ADD      R0,SP,#+140
        ADD      R0,R0,#+1024
        SWI      +22
//   56   strcpy(nname,path);
        ADD      R1,SP,#+140
        ADD      R1,R1,#+1024
        LDR      R0,??CreateMediaLibrary_0+0x8  ;; nname
        SWI      +26
//   57   strcat(nname,"*");
        ADR      R1,??CreateMediaLibrary_0  ;; "*"
        LDR      R0,??CreateMediaLibrary_0+0x8  ;; nname
        SWI      +23
//   58   if (FindFirstFile(&de,nname,&err))
        MOV      R2,SP
        LDR      R1,??CreateMediaLibrary_0+0x8  ;; nname
        ADD      R0,SP,#+8
        SWI      +107
        CMP      R0,#+0
        BEQ      ??CreateMediaLibrary_1
//   59   {
//   60     do
//   61     {
//   62       if (!IsFile(de.file_name))
??CreateMediaLibrary_2:
        ADD      R0,SP,#+189
        _BLF     IsFile,??IsFile??rA
        CMP      R0,#+0
        BNE      ??CreateMediaLibrary_3
//   63       {
//   64         sprintf(ddd,"%s\\%s",de.folder_name,de.file_name);
        ADD      R3,SP,#+189
        ADD      R2,SP,#+60
        LDR      R1,??DataTable2  ;; `?<Constant "%s\\\\%s">`
        ADD      R0,SP,#+844
        SWI      +22
//   65         ddd[0]='0';
        MOV      R1,#+48
        STRB     R1,[SP, #+844]
//   66         mkdir(ddd,&err);
        MOV      R1,SP
        ADD      R0,SP,#+844
        SWI      +16
//   67         ddd[0]='4';
        MOV      R1,#+52
        STRB     R1,[SP, #+844]
//   68         CreateMediaLibrary(ddd);
        ADD      R0,SP,#+844
        BL       CreateMediaLibrary
        B        ??CreateMediaLibrary_4
//   69       }
//   70       else
//   71       {
//   72       char extension[3];
//   73       sprintf(extension,"%c%c%c",de.file_name[strlen(de.file_name)-3],de.file_name[strlen(de.file_name)-2],de.file_name[strlen(de.file_name)-1]);
??CreateMediaLibrary_3:
        ADD      R0,SP,#+189
        SWI      +27
        MOV      R4,R0
        ADD      R0,SP,#+189
        SWI      +27
        MOV      R5,R0
        ADD      R0,SP,#+189
        SWI      +27
        ADD      R1,SP,#+8
        ADD      R1,R4,R1
        LDRB     R1,[R1, #+180]
        PUSH     {R1}
        CFI CFA R13+1308
        ADD      R1,SP,#+12
        ADD      R1,R5,R1
        LDRB     R3,[R1, #+179]
        ADD      R1,SP,#+12
        ADD      R0,R0,R1
        LDRB     R2,[R0, #+178]
        LDR      R1,??DataTable3  ;; `?<Constant "%c%c%c">`
        ADD      R0,SP,#+8
        SWI      +22
//   74       if ((strcmp_nocase(extension,format_1)==0)||(strcmp_nocase(extension,format_2)==0)||(strcmp_nocase(extension,format_3)==0)||(strcmp_nocase(extension,format_4)==0))
        LDR      R1,??CreateMediaLibrary_0+0xC  ;; format_1
        ADD      R0,SP,#+8
        _BLF     strcmp_nocase,??strcmp_nocase??rA
        CMP      R0,#+0
        ADD      SP,SP,#+4        ;; stack cleaning
        CFI CFA R13+1304
        BEQ      ??CreateMediaLibrary_5
        LDR      R1,??CreateMediaLibrary_0+0x10  ;; format_2
        ADD      R0,SP,#+4
        _BLF     strcmp_nocase,??strcmp_nocase??rA
        CMP      R0,#+0
        BEQ      ??CreateMediaLibrary_5
        LDR      R1,??CreateMediaLibrary_0+0x14  ;; format_3
        ADD      R0,SP,#+4
        _BLF     strcmp_nocase,??strcmp_nocase??rA
        CMP      R0,#+0
        BEQ      ??CreateMediaLibrary_5
        LDR      R1,??CreateMediaLibrary_0+0x18  ;; format_4
        ADD      R0,SP,#+4
        _BLF     strcmp_nocase,??strcmp_nocase??rA
        CMP      R0,#+0
        BNE      ??CreateMediaLibrary_4
//   75         {
//   76           sprintf(ddd,"%s\\%s.imy",de.folder_name,de.file_name);
??CreateMediaLibrary_5:
        ADD      R3,SP,#+189
        ADD      R2,SP,#+60
        LDR      R1,??CreateMediaLibrary_0+0x1C  ;; `?<Constant "%s\\\\%s.imy">`
        ADD      R0,SP,#+844
        SWI      +22
//   77           ddd[0]='0';
        MOV      R1,#+48
        STRB     R1,[SP, #+844]
//   78           f=fopen(ddd, A_WriteOnly+A_Create, P_WRITE, & err );
        MOV      R3,SP
        MOV      R2,#+256
        ADD      R1,R1,#+209
        ADD      R0,SP,#+844
        SWI      +10
//   79           fclose(f,&err);
        MOV      R1,SP
        SWI      +13
//   80         }
//   81       }
//   82     }
//   83     while(FindNextFile(&de,&err));
??CreateMediaLibrary_4:
        MOV      R1,SP
        ADD      R0,SP,#+8
        SWI      +108
        CMP      R0,#+0
        BNE      ??CreateMediaLibrary_2
//   84   }
//   85   FindClose(&de,&err);
??CreateMediaLibrary_1:
        MOV      R1,SP
        ADD      R0,SP,#+8
        SWI      +109
//   86   return(0);
        MOV      R0,#+0
        ADD      SP,SP,#+268      ;; stack cleaning
        CFI CFA R13+1036
        ADD      SP,SP,#+1024
        CFI CFA R13+12
        POP      {R4,R5,PC}       ;; return
        DATA
??CreateMediaLibrary_0:
        DC8      "*",+0,+0
        DC32     `?<Constant "%s%c">`
        DC32     nname
        DC32     format_1
        DC32     format_2
        DC32     format_3
        DC32     format_4
        DC32     `?<Constant "%s\\\\%s.imy">`
        CFI EndBlock cfiBlock3
//   87 }

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable2:
        DC32     `?<Constant "%s\\\\%s">`

        RSEG CODE:CODE:NOROOT(2)
        DATA
??DataTable3:
        DC32     `?<Constant "%c%c%c">`

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock4 Using cfiCommon1
        CFI NoFunction
        ARM
??IsFile??rA:
        LDR      R12,??Subroutine2_0  ;; IsFile
        BX       R12
        DATA
??Subroutine2_0:
        DC32     IsFile
        CFI EndBlock cfiBlock4

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock5 Using cfiCommon1
        CFI NoFunction
        ARM
??strcmp_nocase??rA:
        LDR      R12,??Subroutine3_0  ;; strcmp_nocase
        BX       R12
        DATA
??Subroutine3_0:
        DC32     strcmp_nocase
        CFI EndBlock cfiBlock5

        RSEG INITTAB:CODE:ROOT(2)
        DATA
?init?tab?DATA_Z:
        DCD      sfe(DATA_Z) - sfb(DATA_Z), sfb(DATA_Z), sfb(DATA_Z)

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%s\\\\*">`:
        DATA
        DC8 "%s\\*"
        DC8 0, 0, 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%s\\\\%s">`:
        DATA
        DC8 "%s\\%s"
        DC8 0, 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%c%c%c">`:
        DATA
        DC8 "%c%c%c"
        DC8 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%s.imy">`:
        DATA
        DC8 "%s.imy"
        DC8 0

        RSEG DATA_C:CONST:SORT:NOROOT(2)
        DATA
        DC8 "imy"

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%s%c">`:
        DATA
        DC8 "%s%c"
        DC8 0, 0, 0

        RSEG DATA_C:CONST:SORT:NOROOT(0)
        DATA
        DC8 "*"

        RSEG DATA_C:CONST:SORT:NOROOT(2)
`?<Constant "%s\\\\%s.imy">`:
        DATA
        DC8 "%s\\%s.imy"
        DC8 0, 0

        END
// 
// 900 bytes in segment CODE
//  58 bytes in segment DATA_C
// 256 bytes in segment DATA_Z
//  12 bytes in segment INITTAB
// 
// 868 bytes of CODE  memory (+ 44 bytes shared)
//  58 bytes of CONST memory
// 256 bytes of DATA  memory
//
//Errors: none
//Warnings: none
