// File: /workspace/github_c_makefile_star2_O0/sheneman[P]clearcut/clearcut.c
// Function: NJ_dup_dmat
DMAT *
NJ_dup_dmat(DMAT *src) {
  
  long int i;
  DMAT *dest;
  
  /* allocate the resulting distance matrix */
  dest = (DMAT *)calloc(1, sizeof(DMAT));
  if(!dest) {
    fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
    goto XIT_BAD;
  }

  dest->ntaxa = src->ntaxa;
  dest->size  = src->size;
  
  /* allocate space for array of pointers to taxanames */
  dest->taxaname = (char **)calloc(dest->ntaxa, sizeof(char *));
  if(!dest->taxaname) {
    fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
    goto XIT_BAD;
  }

  /* allocate space for the taxanames themselves */
  for(i=0;i<src->ntaxa;i++) {
    dest->taxaname[i] = (char *)calloc(strlen(src->taxaname[i])+1, sizeof(char));
    if(!dest->taxaname[i]) {
      fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
      goto XIT_BAD;
    }
  }
  
  /* allocate space for the distance values */
  dest->val = (float *)calloc(NJ_NCELLS(src->ntaxa), sizeof(float));
  if(!dest->val) {
    fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
    goto XIT_BAD;
  }
  
  /* allocate space for the r and r2 vectors */
  dest->r  = (float *)calloc(src->ntaxa, sizeof(float));
  dest->r2 = (float *)calloc(src->ntaxa, sizeof(float));
  
  /* copy titles */
  for(i=0;i<src->ntaxa;i++) {
    strcpy(dest->taxaname[i], src->taxaname[i]);
  }
  
  /* copy values */
  memcpy(dest->val, src->valhandle, NJ_NCELLS(src->ntaxa)*sizeof(float));
  
  /* copy r and r2 */
  memcpy(dest->r,  src->rhandle,  src->ntaxa*sizeof(float));
  memcpy(dest->r2, src->r2handle, src->ntaxa*sizeof(float));
  
  /* track some memory addresses */
  dest->valhandle = dest->val;
  dest->rhandle   = dest->r;
  dest->r2handle  = dest->r2;
  
  return(dest);
  
 XIT_BAD:
  
  /* free what we may have allocated */
  NJ_free_dmat(dest);
  
  return(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x1, %edi
movl $0x48, %esi
callq 0x2130
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x26d3
movq 0xc93b(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x8c4c(%rip), %rsi      # 0xb313
movb $0x0, %al
callq 0x2150
jmp 0x295c
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movl $0x8, %esi
callq 0x2130
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x2735
movq 0xc8d9(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x8bea(%rip), %rsi      # 0xb313
movb $0x0, %al
callq 0x2150
jmp 0x295c
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x27c6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20c0
movq %rax, %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0x2130
movq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x27b3
movq 0xc85b(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x8b6c(%rip), %rsi      # 0xb313
movb $0x0, %al
callq 0x2150
jmp 0x295c
jmp 0x27b5
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x273d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rdi
movl $0x4, %esi
callq 0x2130
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x2826
movq 0xc7e8(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x8af9(%rip), %rsi      # 0xb313
movb $0x0, %al
callq 0x2150
jmp 0x295c
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x4, %esi
callq 0x2130
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x4, %esi
callq 0x2130
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x28a6
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2070
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x2866
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rdx
shlq $0x2, %rdx
callq 0x2180
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
shlq $0x2, %rdx
callq 0x2180
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
shlq $0x2, %rdx
callq 0x2180
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x296d
movq -0x20(%rbp), %rdi
callq 0x3370
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)