// File: /workspace/github_cpp_makefile_star2_O3/BleuLlama[P]msf-tools/msf-autosave.cpp
// Function: main
int main( int argc, char ** argv )
{
	char * pth;

	pth = getenv( "VOICERECORDER" );
	if( !pth ) {
		usage( argv[0] );
		return -1;
	}

	if( argc != 2 ) {
		usage( argv[0] );
		return -3;
	}

	std::string targetDir( argv[1] );
	if( !DiskUtils::IsValidDir( targetDir ))
	{
		DiskUtils::MakeDir( targetDir );

		if( !DiskUtils::IsValidDir( targetDir ))
		{
			std::cerr << "Unable to use target directory: " << targetDir << std::endl;
			return -4;
		}
	}

	// NOTE: on windows, put in a scan for a drive with label "IC_RECORDER"

	VoiceFile vf( pth );
	if( !vf.Valid() ) {
		std::cerr << "Directory is invalid: " << pth << std::endl;
		return -2;
	}


	for( int f=0 ; f<vf.GetFolderCount() ; f++ )
	{
		int fc = vf.GetFileCountForFolder( f );
		if( fc > 0 ) {
			std::string plural = "s";
			if( fc == 1 ) plural = "";

			std::cout << std::endl;
			std::cout << vf.GetFolderName( f ) << ": Extracting " << fc << " item" << plural << "." << std::endl;
	
			std::string folderPath = vf.GetPathForFolder( f );

			for( int i=0 ; i < fc ; i ++ ) {
				std::string sourceFile( folderPath );
				sourceFile.append( "/" );
				sourceFile.append( vf.GetFileInFolder( i, f ));

				std::string destFile( targetDir );
				destFile.append( "/" );
				destFile.append( vf.GetFolderName( f ));

				DiskUtils::MakeDir( destFile );

				destFile.append( "/" );
				destFile.append( vf.SortableDateForFileInFolder( i, f ));
				destFile.append( "__" );
				destFile.append( vf.GetFileInFolder( i, f ) );

				float fs = ((float)DiskUtils::FileSize( sourceFile )) / 1024.0/1024.0; 
				std::cout << "  Copying " << vf.GetFileInFolder( i, f )
					  << "  --  " << vf.PrintableDateForFileInFolder( i, f ) 
					  << " (" << std::setprecision( 2 ) << fs << " MB)";

				bool skipped = DiskUtils::CopyFile( sourceFile, destFile );
				if( skipped ) {
					std::cout << " (skipped)";
				}
				std::cout << std::endl;
			}
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %r14
movl %edi, %ebp
leaq 0x1024(%rip), %rdi      # 0x5311
callq 0x2160
testq %rax, %rax
je 0x4b2c
cmpl $0x2, %ebp
jne 0x4b3e
movq %rax, %rbx
movq 0x8(%r14), %rsi
leaq 0xa8(%rsp), %r14
leaq 0x1e8(%rsp), %rdx
movq %r14, %rdi
callq 0x4ed6
leaq 0x1d8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x2c8e
leaq 0x1c8(%rsp), %rdi
callq 0x24c0
movl %eax, %ebp
movq 0x1c8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4372
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x2110
testb %bpl, %bpl
jne 0x4432
leaq 0x1b8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1a8(%rsp), %rdi
callq 0x2c8e
leaq 0x1a8(%rsp), %rdi
callq 0x2432
movq 0x1a8(%rsp), %rdi
cmpq %r14, %rdi
je 0x43d1
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x198(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x188(%rsp), %rdi
callq 0x2c8e
leaq 0x188(%rsp), %rdi
callq 0x24c0
movl %eax, %ebp
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x4429
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x2110
testb %bpl, %bpl
je 0x4bc8
leaq 0x178(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rbx, %rdi
callq 0x2070
movq %rbx, %rdx
addq %rax, %rdx
leaq 0x168(%rsp), %rdi
movq %rbx, %rsi
callq 0x2d24
leaq 0x1e8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x2dbc
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x448e
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2110
cmpb $0x1, 0x1e8(%rsp)
jne 0x4b50
xorl %ebx, %ebx
leaq 0x1e8(%rsp), %r14
leaq 0x48(%rsp), %r13
leaq 0x28(%rsp), %r15
movq %r14, %rdi
callq 0x3b6a
cmpl %eax, %ebx
jge 0x4bb7
movq %r14, %rdi
movl %ebx, %esi
callq 0x3cc4
movl %eax, 0x24(%rsp)
testl %eax, %eax
jle 0x4b25
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0xe62(%rip), %rsi       # 0x5357
leaq 0xe5c(%rip), %rdx       # 0x5358
callq 0x2d24
cmpl $0x1, 0x24(%rsp)
jne 0x4529
movq 0x90(%rsp), %rdx
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
leaq 0xc8b(%rip), %rcx       # 0x51ac
xorl %r8d, %r8d
callq 0x21c0
movq 0x3aa0(%rip), %rcx      # 0x7fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x3a82(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x3b70
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x3a57(%rip), %rdi      # 0x7fd0
callq 0x2130
movq %rax, %r12
movl $0xd, %edx
movq %rax, %rdi
leaq 0xdc9(%rip), %rsi       # 0x5359
callq 0x2130
movq %r12, %rdi
movl 0x24(%rsp), %esi
callq 0x2220
movq %rax, %r12
movl $0x5, %edx
movq %rax, %rdi
leaq 0xdb4(%rip), %rsi       # 0x5367
callq 0x2130
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq %r12, %rdi
callq 0x2130
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xa3b(%rip), %rsi       # 0x501d
callq 0x2130
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x462b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2110
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x3bda
xorl %r13d, %r13d
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0x2c8e
movq %r12, %rdi
leaq 0xaac(%rip), %rsi       # 0x5115
callq 0x2250
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3cf6
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x2060
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x46ae
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2c8e
movq %r15, %rdi
leaq 0xa38(%rip), %rsi       # 0x5115
callq 0x2250
movq %rsp, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x3b70
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x2060
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x471b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x2c8e
leaq 0x108(%rsp), %rdi
callq 0x2432
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x4777
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2110
movq %r15, %rdi
leaq 0x994(%rip), %rsi       # 0x5115
callq 0x2250
movq %rsp, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3f00
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x2060
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x47c2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
movq %r15, %rdi
leaq 0xa01(%rip), %rsi       # 0x51cd
callq 0x2250
movq %rsp, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3cf6
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x2060
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x480d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe8(%rsp), %rdi
callq 0x2c8e
leaq 0xe8(%rsp), %rdi
callq 0x24f6
movq %rax, %r12
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x486c
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2110
movl $0xa, %edx
movq 0x3758(%rip), %rdi      # 0x7fd0
leaq 0xaee(%rip), %rsi       # 0x536d
callq 0x2130
movq %rsp, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3cf6
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x372c(%rip), %rdi      # 0x7fd0
callq 0x2130
movq %rax, %rbp
movl $0x6, %edx
movq %rax, %rdi
leaq 0xabd(%rip), %rsi       # 0x5378
callq 0x2130
leaq 0x148(%rsp), %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3df8
movq 0x148(%rsp), %rsi
movq 0x150(%rsp), %rdx
movq %rbp, %rdi
callq 0x2130
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0xa80(%rip), %rsi       # 0x537f
callq 0x2130
cvtsi2ss %r12, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8fb(%rip), %xmm1      # 0x5210
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq (%rbp), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x8(%rbp,%rax)
cvtss2sd %xmm0, %xmm0
movq %rbp, %rdi
callq 0x2200
movl $0x4, %edx
movq %rax, %rdi
leaq 0xa35(%rip), %rsi       # 0x5382
callq 0x2130
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x4977
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2110
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4992
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0xd8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0x2c8e
leaq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %r12
movq %r12, %rdi
callq 0x2c8e
leaq 0xc8(%rsp), %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x2a18
movl %eax, %ebp
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x4a25
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x4a4a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2110
testb %bpl, %bpl
je 0x4a67
movl $0xa, %edx
movq 0x3575(%rip), %rdi      # 0x7fd0
leaq 0x925(%rip), %rsi       # 0x5387
callq 0x2130
movq 0x3562(%rip), %rcx      # 0x7fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x3544(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4ab5
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x4ad1
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2110
incl %r13d
cmpl %r13d, 0x24(%rsp)
jne 0x463b
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4afb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
leaq 0x48(%rsp), %r13
je 0x4b25
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2110
incl %ebx
jmp 0x44b0
movq (%r14), %rdi
callq 0x4084
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4c4c
movq (%r14), %rdi
callq 0x4084
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
jmp 0x4c4c
movq 0x3499(%rip), %rdi      # 0x7ff0
leaq 0x7e2(%rip), %rsi       # 0x5340
movl $0x16, %edx
callq 0x2130
movq %rbx, %rdi
callq 0x2070
movq 0x3479(%rip), %r14      # 0x7ff0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2130
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x344d(%rip), %rdi      # 0x7ff0
callq 0x2040
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movq %rax, %rdi
callq 0x20a0
jmp 0x4bb9
xorl %ebx, %ebx
leaq 0x1e8(%rsp), %rdi
callq 0x3244
jmp 0x4c2b
movq 0x3421(%rip), %rdi      # 0x7ff0
leaq 0x749(%rip), %rsi       # 0x531f
movl $0x20, %edx
callq 0x2130
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x33f9(%rip), %rdi      # 0x7ff0
callq 0x2130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movl $0xfffffffc, %ebx       # imm = 0xFFFFFFFC
movq %rax, %rdi
callq 0x20a0
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4c4c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2110
movl %ebx, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x4ead
movq 0x198(%rsp), %rsi
jmp 0x4cd8
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
cmpq %r14, %rdi
je 0x4ead
movq 0x1b8(%rsp), %rsi
jmp 0x4cd8
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x4ead
movq 0x178(%rsp), %rsi
jmp 0x4cd8
jmp 0x4ce7
movq %rax, %rbx
movq 0x1c8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4ead
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x4ead
jmp 0x4cf7
movq %rax, %rbx
jmp 0x4ead
jmp 0x4cff
jmp 0x4cff
jmp 0x4cf7
jmp 0x4cf7
movq %rax, %rbx
jmp 0x4ea0
movq %rax, %rbx
jmp 0x4e7b
jmp 0x4da2
movq %rax, %rbx
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x4d43
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x4d43
jmp 0x4e24
jmp 0x4dd6
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x4e27
movq 0xd8(%rsp), %rsi
jmp 0x4e18
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x4e27
movq 0xf8(%rsp), %rsi
jmp 0x4e18
jmp 0x4d96
jmp 0x4d96
movq %rax, %rbx
jmp 0x4e43
jmp 0x4dd6
jmp 0x4dd6
movq %rax, %rbx
jmp 0x4e5f
jmp 0x4e24
jmp 0x4e24
jmp 0x4dd6
jmp 0x4e24
jmp 0x4e24
movq %rax, %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x4e27
movq 0x118(%rsp), %rsi
jmp 0x4e18
movq %rax, %rbx
jmp 0x4e05
jmp 0x4e24
movq %rax, %rbx
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x4e05
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2110
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4e27
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x4e27
jmp 0x4e24
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4e43
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x4e5f
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x4e7b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x4ea0
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x1e8(%rsp), %rdi
callq 0x3244
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4ece
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2110
movq %rbx, %rdi
callq 0x2230