// File: /workspace/github_cpp_makefile_star2_O1/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 0xff0(%rip), %rdi       # 0x5311
callq 0x2160
testq %rax, %rax
je 0x4b69
cmpl $0x2, %ebp
jne 0x4b7b
movq %rax, %rbx
movq 0x8(%r14), %rsi
leaq 0xa8(%rsp), %r14
leaq 0x1e8(%rsp), %rdx
movq %r14, %rdi
callq 0x4f14
leaq 0x1d8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x2c9a
leaq 0x1c8(%rsp), %rdi
callq 0x24c0
movl %eax, %ebp
movq 0x1c8(%rsp), %rdi
cmpq %r15, %rdi
je 0x43a6
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x2110
testb %bpl, %bpl
jne 0x4466
leaq 0x1b8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1a8(%rsp), %rdi
callq 0x2c9a
leaq 0x1a8(%rsp), %rdi
callq 0x2432
movq 0x1a8(%rsp), %rdi
cmpq %r14, %rdi
je 0x4405
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 0x2c9a
leaq 0x188(%rsp), %rdi
callq 0x24c0
movl %eax, %ebp
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x445d
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x2110
testb %bpl, %bpl
je 0x4c05
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 0x2d2a
leaq 0x1e8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x2dbc
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x44c2
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x2110
cmpb $0x1, 0x1e8(%rsp)
jne 0x4b8d
xorl %ebx, %ebx
leaq 0x1e8(%rsp), %r14
leaq 0x40(%rsp), %r13
leaq 0x20(%rsp), %r15
movq %r14, %rdi
callq 0x3b6a
cmpl %eax, %ebx
jge 0x4bf4
movq %r14, %rdi
movl %ebx, %esi
callq 0x3cc4
testl %eax, %eax
jle 0x4b62
movl %eax, %ebp
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0xe30(%rip), %rsi       # 0x5357
leaq 0xe2a(%rip), %rdx       # 0x5358
callq 0x2d2a
cmpl $0x1, %ebp
jne 0x4559
movq 0x90(%rsp), %rdx
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
leaq 0xc5b(%rip), %rcx       # 0x51ac
xorl %r8d, %r8d
callq 0x21c0
movq 0x3a70(%rip), %rcx      # 0x7fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x3a52(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x3b70
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x3a27(%rip), %rdi      # 0x7fd0
callq 0x2130
movq %rax, %r12
movl $0xd, %edx
movq %rax, %rdi
leaq 0xd99(%rip), %rsi       # 0x5359
callq 0x2130
movq %r12, %rdi
movl %ebp, %esi
callq 0x2220
movq %rax, %r12
movl $0x5, %edx
movq %rax, %rdi
leaq 0xd86(%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 0xa0d(%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 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4659
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2110
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x3bda
cmpl $0x2, %ebp
movl $0x1, %eax
cmovll %eax, %ebp
movl %ebp, 0x64(%rsp)
xorl %r13d, %r13d
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0x2c9a
movq %r12, %rdi
leaq 0xa6f(%rip), %rsi       # 0x5115
callq 0x2250
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3cf6
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x68(%rsp), %rdi
callq 0x2060
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x46eb
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2c9a
movq %r15, %rdi
leaq 0x9fb(%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 0x4758
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
leaq 0x118(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x2c9a
leaq 0x108(%rsp), %rdi
callq 0x2432
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x47b4
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2110
movq %r15, %rdi
leaq 0x957(%rip), %rsi       # 0x5115
callq 0x2250
movq %rsp, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3f18
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x2060
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x47ff
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
movq %r15, %rdi
leaq 0x9c4(%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 0x484a
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 0x2c9a
leaq 0xe8(%rsp), %rdi
callq 0x24f6
movq %rax, %r12
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x48a9
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2110
movl $0xa, %edx
movq 0x371b(%rip), %rdi      # 0x7fd0
leaq 0xab1(%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 0x36ef(%rip), %rdi      # 0x7fd0
callq 0x2130
movq %rax, %rbp
movl $0x6, %edx
movq %rax, %rdi
leaq 0xa80(%rip), %rsi       # 0x5378
callq 0x2130
leaq 0x148(%rsp), %rdi
movq %r14, %rsi
movl %r13d, %edx
movl %ebx, %ecx
callq 0x3e04
movq 0x148(%rsp), %rsi
movq 0x150(%rsp), %rdx
movq %rbp, %rdi
callq 0x2130
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0xa43(%rip), %rsi       # 0x537f
callq 0x2130
cvtsi2ss %r12, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8be(%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 0x9f8(%rip), %rsi       # 0x5382
callq 0x2130
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x49b4
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2110
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x49cf
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 0x2c9a
leaq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %r12
movq %r12, %rdi
callq 0x2c9a
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 0x4a62
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x4a87
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x2110
testb %bpl, %bpl
je 0x4aa4
movl $0xa, %edx
movq 0x3538(%rip), %rdi      # 0x7fd0
leaq 0x8e8(%rip), %rsi       # 0x5387
callq 0x2130
movq 0x3525(%rip), %rcx      # 0x7fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x3507(%rip), %rdi      # 0x7fd0
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4af2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x4b0e
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2110
incl %r13d
cmpl %r13d, 0x64(%rsp)
jne 0x4678
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4b38
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
leaq 0x40(%rsp), %r13
je 0x4b62
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2110
incl %ebx
jmp 0x44e4
movq (%r14), %rdi
callq 0x40b8
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4c89
movq (%r14), %rdi
callq 0x40b8
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
jmp 0x4c89
movq 0x345c(%rip), %rdi      # 0x7ff0
leaq 0x7a5(%rip), %rsi       # 0x5340
movl $0x16, %edx
callq 0x2130
movq %rbx, %rdi
callq 0x2070
movq 0x343c(%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 0x3410(%rip), %rdi      # 0x7ff0
callq 0x2040
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
movq %rax, %rdi
callq 0x20a0
jmp 0x4bf6
xorl %ebx, %ebx
leaq 0x1e8(%rsp), %rdi
callq 0x3244
jmp 0x4c68
movq 0x33e4(%rip), %rdi      # 0x7ff0
leaq 0x70c(%rip), %rsi       # 0x531f
movl $0x20, %edx
callq 0x2130
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x33bc(%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 0x4c89
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 0x4eea
movq 0x198(%rsp), %rsi
jmp 0x4d15
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
cmpq %r14, %rdi
je 0x4eea
movq 0x1b8(%rsp), %rsi
jmp 0x4d15
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r14, %rdi
je 0x4eea
movq 0x178(%rsp), %rsi
jmp 0x4d15
jmp 0x4d24
movq %rax, %rbx
movq 0x1c8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4eea
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x4eea
jmp 0x4d34
movq %rax, %rbx
jmp 0x4eea
jmp 0x4d3c
jmp 0x4d3c
jmp 0x4d34
jmp 0x4d34
movq %rax, %rbx
jmp 0x4edd
movq %rax, %rbx
jmp 0x4eb8
jmp 0x4ddf
movq %rax, %rbx
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x4d80
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x4d80
jmp 0x4e61
jmp 0x4e13
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x4e64
movq 0xd8(%rsp), %rsi
jmp 0x4e55
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x4e64
movq 0xf8(%rsp), %rsi
jmp 0x4e55
jmp 0x4dd3
jmp 0x4dd3
movq %rax, %rbx
jmp 0x4e80
jmp 0x4e13
jmp 0x4e13
movq %rax, %rbx
jmp 0x4e9c
jmp 0x4e61
jmp 0x4e61
jmp 0x4e13
jmp 0x4e61
jmp 0x4e61
movq %rax, %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x4e64
movq 0x118(%rsp), %rsi
jmp 0x4e55
movq %rax, %rbx
jmp 0x4e42
jmp 0x4e61
movq %rax, %rbx
movq 0x148(%rsp), %rdi
leaq 0x158(%rsp), %rax
cmpq %rax, %rdi
je 0x4e42
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x2110
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4e64
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2110
jmp 0x4e64
jmp 0x4e61
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4e80
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x4e9c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4eb8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2110
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x4edd
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 0x4f0b
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2110
movq %rbx, %rdi
callq 0x2230
nop