// File: jp-myk[P]WAVUtil/src/wav_split.cpp
// Function: main
int main(int argc, char *argv[]){
  if(argc<4){
    std::cout << argv[0] << " WAVFILE PREFIX SPLIT_TIME_SPAN[sec]" << std::endl;
    exit(0);
  }
  const char* wavFName=argv[1];
  std::string prefix(argv[2]);
  float splitTime=5.0;
  splitTime=atof(argv[3]);
  WAV wav;
  std::vector<WAV> wavList;
  std::vector<WAV>::iterator it;
  int res=0;
  res=wav.Read(wavFName);
  std::cout << "split!" << std::endl;
  wavList=SimpleWAV::split_wav(splitTime, wav); // extra 0.0 - 1.00[sec]
  
  int i=0;
  char outfname[100];
  for(it=wavList.begin();it!=wavList.end();++it){
    sprintf(outfname, "%s.%d.wav", prefix.c_str(), i);
    it->Write(outfname);
    i++;
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x4, -0x8(%rbp)
jge 0x5437
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0x3bc3(%rip), %rdi      # 0x8fd0
callq 0x2190
movq %rax, %rdi
leaq 0xf01(%rip), %rsi       # 0x631d
callq 0x2190
movq %rax, %rdi
movq 0x3b95(%rip), %rsi      # 0x8fc0
callq 0x21c0
xorl %edi, %edi
callq 0x2220
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x170(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x2310
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x56c0
jmp 0x547b
leaq -0x39(%rbp), %rdi
callq 0x21e0
movl $0x40a00000, -0x50(%rbp) # imm = 0x40A00000
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2240
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x4530
jmp 0x54af
leaq -0xc0(%rbp), %rdi
callq 0x43f0
leaq -0xc8(%rbp), %rdi
callq 0x5770
movl $0x0, -0xcc(%rbp)
movq -0x18(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x2f90
movl %eax, -0x174(%rbp)
jmp 0x54e9
movl -0x174(%rbp), %eax
movl %eax, -0xcc(%rbp)
movq 0x3ad4(%rip), %rdi      # 0x8fd0
leaq 0xe3f(%rip), %rsi       # 0x6342
callq 0x2190
movq %rax, -0x180(%rbp)
jmp 0x5511
movq -0x180(%rbp), %rdi
movq 0x3aa1(%rip), %rsi      # 0x8fc0
callq 0x21c0
jmp 0x5526
movss -0x50(%rbp), %xmm0
leaq -0xe8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3ca0
jmp 0x5540
leaq -0xc0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x5790
leaq -0xe8(%rbp), %rdi
callq 0x4620
movl $0x0, -0xec(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x52a0
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x5110
movq %rax, -0x160(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x57c0
testb $0x1, %al
jne 0x55b9
jmp 0x566f
leaq -0x38(%rbp), %rdi
callq 0x20c0
movq %rax, %rdx
movl -0xec(%rbp), %ecx
leaq 0xd77(%rip), %rsi       # 0x6349
xorl %eax, %eax
leaq -0x150(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x2060
leaq -0xc8(%rbp), %rdi
callq 0x5800
movq -0x188(%rbp), %rsi
movq %rax, %rdi
callq 0x2b30
jmp 0x5604
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5820
jmp 0x558a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x21e0
jmp 0x56ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x56a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4620
leaq -0xa8(%rbp), %rdi
callq 0x45f0
jmp 0x56a3
movl $0x0, -0x4(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x4620
leaq -0xa8(%rbp), %rdi
callq 0x45f0
leaq -0x38(%rbp), %rdi
callq 0x2110
movl -0x4(%rbp), %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x2110
movq -0x48(%rbp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)
nop