// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %r14
cmpl $0x3, %edi
jle 0x3ca5
movq 0x8(%r14), %rbx
movq 0x10(%r14), %rsi
leaq 0x20(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x3d0c
movq 0x18(%r14), %rdi
callq 0x21e0
movsd %xmm0, 0x18(%rsp)
xorl %eax, %eax
leaq 0x58(%rsp), %rdi
movl %eax, 0x4(%rdi)
movabsq $0x2000100000010, %rcx  # imm = 0x2000100000010
movq %rcx, 0x10(%rdi)
movabsq $0x7d000000ac44, %rcx   # imm = 0x7D000000AC44
movq %rcx, 0x18(%rdi)
movl $0x100002, 0x20(%rdi)   # imm = 0x100002
movl %eax, 0x28(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x40(%rdi)
movq %rax, 0x50(%rdi)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq %rbx, %rsi
callq 0x2ae0
movq 0x244f(%rip), %rbx      # 0x5fd0
leaq 0x7a6(%rip), %rsi       # 0x432e
movl $0x6, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq 0x241d(%rip), %rdi      # 0x5fd0
callq 0x2030
movq %rax, %rdi
callq 0x2110
xorps %xmm0, %xmm0
cvtsd2ss 0x18(%rsp), %xmm0
leaq 0x40(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x3247
movq 0x10(%rsp), %rax
leaq 0x40(%rsp), %rbx
movaps (%rbx), %xmm0
movq 0x10(%rbx), %rcx
movq %rcx, 0x10(%rsp)
movaps (%rsp), %xmm1
movaps %xmm0, (%rsp)
leaq 0xb0(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x37c0
movq %rbx, %rdi
callq 0x37c0
movq (%rsp), %rbx
cmpq 0x8(%rsp), %rbx
je 0x3c68
leaq 0x703(%rip), %r14       # 0x4335
leaq 0xb0(%rsp), %r15
xorl %ebp, %ebp
movq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2060
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2838
incl %ebp
addq $0x58, %rbx
cmpq 0x8(%rsp), %rbx
jne 0x3c3c
movq %rsp, %rdi
callq 0x37c0
leaq 0x58(%rsp), %rdi
callq 0x278e
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3c95
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rsi
movq 0x2321(%rip), %rdi      # 0x5fd0
callq 0x2180
leaq 0x64e(%rip), %rsi       # 0x4309
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x20e0
xorl %edi, %edi
callq 0x21d0
jmp 0x3d04
jmp 0x3cd8
jmp 0x3cd8
movq %rax, %rbx
movq %rsp, %rdi
callq 0x37c0
leaq 0x58(%rsp), %rdi
callq 0x278e
leaq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x237a
movq %rbx, %rdi
callq 0x22a0
movq %rax, %rdi
callq 0x37ef