// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/tag_value_map.c
// Function: gt_tag_value_map_set
void gt_tag_value_map_set(GtTagValueMap *map, const char *tag,
                          const char *new_value)
{
  size_t old_value_len, new_value_len, map_len = 0;
  char *old_value;
  gt_assert(map && *map && tag && new_value);
  gt_assert(strlen(tag));
  new_value_len = strlen(new_value);
  gt_assert(new_value_len);
  /* determine current map length */
  old_value = get_value(*map, tag, &map_len);
  if (!old_value)
    return gt_tag_value_map_add(map, tag, new_value);
  /* tag already used -> replace it */
  old_value_len = strlen(old_value);
  map_len = get_map_len(*map);
  if (new_value_len < old_value_len) {
    memcpy(old_value, new_value, new_value_len);
    memmove(old_value + new_value_len, old_value + old_value_len,
            map_len - ((size_t) old_value - (size_t) *map + old_value_len) + 1);
    *map = gt_realloc(*map, map_len - (old_value_len - new_value_len) + 1);
  }
  else if (new_value_len == old_value_len) {
    memcpy(old_value, new_value, new_value_len);
  }
  else { /* (new_value_len > old_value_len)  */
    *map = gt_realloc(*map, map_len + (new_value_len - old_value_len) + 1);
    /* determine old_value again, realloc() might have moved it */
    old_value = get_value(*map, tag, &map_len);
    gt_assert(old_value);
    memmove(old_value + new_value_len, old_value + old_value_len,
            map_len - ((size_t) old_value - (size_t) *map + old_value_len) + 1);
    memcpy(old_value, new_value, new_value_len);
  }
  gt_assert((*map)[map_len - old_value_len + new_value_len] == '\0');
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
andq $0x0, 0x8(%rsp)
testq %rdi, %rdi
je 0x275f0
movq %rdx, %r14
testq %rdx, %rdx
je 0x275f0
movq %rsi, %r13
testq %rsi, %rsi
je 0x275f0
movq %rdi, %rbx
movq (%rdi), %r12
testq %r12, %r12
je 0x275f0
cmpb $0x0, (%r13)
je 0x27621
movq %r14, %rdi
callq 0xb260
testq %rax, %rax
je 0x27652
movq %rax, %r15
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x271b8
testq %rax, %rax
je 0x27528
movq %rax, %rbp
movq %r14, 0x18(%rsp)
movq %rax, %rdi
callq 0xb260
movq %rbx, %r12
movq %rax, %rbx
movq (%r12), %rdi
movq %rdi, 0x20(%rsp)
callq 0x273f1
movq %rax, 0x8(%rsp)
movq %r15, %r14
movq %rbx, 0x10(%rsp)
subq %rbx, %r14
jae 0x2753b
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0xb520
movq %r15, %rdi
addq %rbp, %rdi
movq 0x10(%rsp), %rbx
addq %rbx, %rbp
movq 0x8(%rsp), %rax
movq (%r12), %rcx
subq %rbp, %rax
leaq (%rax,%rcx), %rdx
incq %rdx
movq %rbp, %rsi
callq 0xba50
movq (%r12), %rdi
movq 0x8(%rsp), %rax
leaq (%r14,%rax), %rsi
incq %rsi
leaq 0xaaf6c(%rip), %rdx     # 0xd247e
movl $0xb1, %ecx
callq 0xcfc2
movq %rax, (%r12)
movq %rbx, %r14
jmp 0x275ca
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x27035
jmp 0x275e1
jne 0x27554
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0xb520
movq 0x10(%rsp), %r14
jmp 0x275ca
leaq (%r14,%rax), %rsi
incq %rsi
leaq 0xaaf1c(%rip), %rdx     # 0xd247e
movq 0x20(%rsp), %rdi
movl $0xb7, %ecx
callq 0xcfc2
movq %rax, (%r12)
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x271b8
testq %rax, %rax
je 0x276ae
movq %rax, %r13
movq %r15, %rdi
addq %rax, %rdi
movq %rax, %rsi
movq 0x10(%rsp), %r14
addq %r14, %rsi
movq 0x8(%rsp), %rax
movq (%r12), %rcx
subq %rsi, %rax
leaq (%rax,%rcx), %rdx
incq %rdx
callq 0xba50
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0xb520
movq 0x8(%rsp), %rax
subq %r14, %rax
addq (%r12), %rax
cmpb $0x0, (%r15,%rax)
jne 0x27680
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1069c1(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xa2a65(%rip), %rsi     # 0xca066
leaq 0xaaf6d(%rip), %rdx     # 0xd2575
leaq 0xaaf86(%rip), %rcx     # 0xd2595
leaq 0xaae68(%rip), %r8      # 0xd247e
movl $0xa2, %r9d
jmp 0x276da
movq 0x106990(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xa2a34(%rip), %rsi     # 0xca066
leaq 0xaafc5(%rip), %rdx     # 0xd25fe
leaq 0xaaf55(%rip), %rcx     # 0xd2595
leaq 0xaae37(%rip), %r8      # 0xd247e
movl $0xa3, %r9d
jmp 0x276da
movq 0x10695f(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xa2a03(%rip), %rsi     # 0xca066
leaq 0xaaf40(%rip), %rdx     # 0xd25aa
leaq 0xaaf24(%rip), %rcx     # 0xd2595
leaq 0xaae06(%rip), %r8      # 0xd247e
movl $0xa5, %r9d
jmp 0x276da
movq 0x106931(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xa29d5(%rip), %rsi     # 0xca066
leaq 0xaaf20(%rip), %rdx     # 0xd25b8
leaq 0xaaef6(%rip), %rcx     # 0xd2595
leaq 0xaadd8(%rip), %r8      # 0xd247e
movl $0xbf, %r9d
jmp 0x276da
movq 0x106903(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xa29a7(%rip), %rsi     # 0xca066
leaq 0xca86d(%rip), %rdx     # 0xf1f33
leaq 0xaaec8(%rip), %rcx     # 0xd2595
leaq 0xaadaa(%rip), %r8      # 0xd247e
movl $0xba, %r9d
xorl %eax, %eax
callq 0xb8c0
callq 0xb300