// File: jp-myk[P]WAVUtil/src/SimpleWAV/WAVUtil.cpp
// Function: SimpleWAV::cat_wav(WAV&)
int cat_wav(WAV& wav){
  //void* data;
  //int res=0;
  if(wav.getChannels() == 1){
    if(wav.getBit() == 8){
      Monoral8* data=(Monoral8*)wav.getData();
      for(unsigned long i=0;i<wav.getSampleCount();i++){
	printf("%d\n",(unsigned char)data[i]);
      }
    }else if(wav.getBit() == 16){
      Monoral16* data=(Monoral16*)wav.getData();
      for(unsigned long i=0;i<wav.getSampleCount();i++){
	printf("%d\n",(signed short)data[i]);
      }
    }else{
      printLOG("error bit must be 8 or 16");
      exit(-1);
    }
  }else if(wav.getChannels() == 2){
    if(wav.getBit() == 8){
      Stereo8* data=(Stereo8*)wav.getData();
      for(unsigned long i=0;i<wav.getSampleCount();i++){
	printf("%d\t%d\n",(unsigned char)data[i].l, (unsigned char)data[i].r);
      }
    }else if(wav.getBit() == 16){
      Stereo16* data=(Stereo16*)wav.getData();
      for(unsigned long i=0;i<wav.getSampleCount();i++){
	printf("%d\t%d\n",(signed short)data[i].l, (signed short)data[i].r);
      }
    }else{
      printLOG("error bit must be 8 or 16");
      exit(-1);
    }

  }else{
    printLOG("wav channel must set monoral");
    return -1;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x38a0
movzwl %ax, %eax
cmpl $0x1, %eax
jne 0x4129
movq -0x10(%rbp), %rdi
callq 0x38e0
movzwl %ax, %eax
cmpl $0x8, %eax
jne 0x4082
movq -0x10(%rbp), %rdi
callq 0x2720
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x42b0
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x407d
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %esi
leaq 0x226a(%rip), %rdi      # 0x62d2
movb $0x0, %al
callq 0x2030
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x4037
jmp 0x4124
movq -0x10(%rbp), %rdi
callq 0x38e0
movzwl %ax, %eax
cmpl $0x10, %eax
jne 0x40f0
movq -0x10(%rbp), %rdi
callq 0x2720
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x42b0
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x40ee
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movswl (%rax,%rcx,2), %esi
leaq 0x21f9(%rip), %rdi      # 0x62d2
movb $0x0, %al
callq 0x2030
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x40a8
jmp 0x4122
leaq 0x1f0d(%rip), %rdi      # 0x6004
leaq 0x2105(%rip), %rsi      # 0x6203
leaq 0x21a8(%rip), %rdx      # 0x62ad
movl $0x77, %ecx
leaq 0x21a4(%rip), %r8       # 0x62b5
movb $0x0, %al
callq 0x2030
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2150
jmp 0x4124
jmp 0x42a0
movq -0x10(%rbp), %rdi
callq 0x38a0
movzwl %ax, %eax
cmpl $0x2, %eax
jne 0x426d
movq -0x10(%rbp), %rdi
callq 0x38e0
movzwl %ax, %eax
cmpl $0x8, %eax
jne 0x41bc
movq -0x10(%rbp), %rdi
callq 0x2720
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x42b0
movl %eax, %ecx
movq -0x68(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x41b7
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl (%rax,%rcx,2), %esi
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movzbl 0x1(%rax,%rcx,2), %edx
leaq 0x212d(%rip), %rdi      # 0x62cf
movb $0x0, %al
callq 0x2030
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x4164
jmp 0x426b
movq -0x10(%rbp), %rdi
callq 0x38e0
movzwl %ax, %eax
cmpl $0x10, %eax
jne 0x4237
movq -0x10(%rbp), %rdi
callq 0x2720
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x42b0
movl %eax, %ecx
movq -0x70(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x4235
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movswl (%rax,%rcx,4), %esi
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movswl 0x2(%rax,%rcx,4), %edx
leaq 0x20af(%rip), %rdi      # 0x62cf
movb $0x0, %al
callq 0x2030
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x41e2
jmp 0x4269
leaq 0x1dc6(%rip), %rdi      # 0x6004
leaq 0x1fbe(%rip), %rsi      # 0x6203
leaq 0x2061(%rip), %rdx      # 0x62ad
movl $0x86, %ecx
leaq 0x205d(%rip), %r8       # 0x62b5
movb $0x0, %al
callq 0x2030
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2150
jmp 0x426b
jmp 0x429e
leaq 0x1d90(%rip), %rdi      # 0x6004
leaq 0x1f88(%rip), %rsi      # 0x6203
leaq 0x202b(%rip), %rdx      # 0x62ad
movl $0x8b, %ecx
leaq 0x2048(%rip), %r8       # 0x62d6
movb $0x0, %al
callq 0x2030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x42a7
jmp 0x42a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq