// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq $0x0, 0x8(%rsp)
testq %rdi, %rdi
je 0x4aa9d
movq %rdx, %r15
testq %rdx, %rdx
je 0x4aa9d
movq %rsi, %r13
testq %rsi, %rsi
je 0x4aa9d
movq %rdi, %rbx
movq (%rdi), %r12
testq %r12, %r12
je 0x4aa9d
cmpb $0x0, (%r13)
je 0x4aaa2
movq %r15, %rdi
callq 0xb260
testq %rax, %rax
je 0x4aaa7
movq %rax, %r14
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x4a733
testq %rax, %rax
je 0x4a9e4
movq %rax, %rbp
movq %rax, %rdi
callq 0xb260
movq (%rbx), %rdi
movq %rdi, %rdx
movq %rdx, %rcx
incq %rdx
cmpb $0x0, (%rcx)
jne 0x4a95d
leaq 0x2(%rcx), %rdx
cmpb $0x0, 0x1(%rcx)
jne 0x4a95d
movq %rdi, %rcx
notq %rcx
addq %rcx, %rdx
movq %rdx, 0x8(%rsp)
movq %r14, %r12
subq %rax, %r14
jae 0x4a9f7
movq %rbp, %rdi
movq %r15, %rsi
movq %rax, %r13
movq %r12, %rdx
callq 0xb520
movq %r12, %rdi
addq %rbp, %rdi
addq %r13, %rbp
movq 0x8(%rsp), %rax
movq (%rbx), %rcx
subq %rbp, %rax
leaq (%rax,%rcx), %rdx
incq %rdx
movq %rbp, %rsi
callq 0xba60
movq (%rbx), %rdi
movq 0x8(%rsp), %rax
leaq (%r14,%rax), %rsi
incq %rsi
leaq 0x9eb0e(%rip), %rdx     # 0xe94e0
movl $0xb1, %ecx
callq 0x36116
movq %rax, (%rbx)
jmp 0x4aa7c
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4a62c
jmp 0x4aa8e
movq %rax, 0x10(%rsp)
jne 0x4aa13
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xb520
movq 0x10(%rsp), %r13
jmp 0x4aa7c
leaq (%r14,%rdx), %rsi
incq %rsi
leaq 0x9eabf(%rip), %rdx     # 0xe94e0
movl $0xb7, %ecx
callq 0x36116
movq %rax, (%rbx)
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4a733
testq %rax, %rax
je 0x4aab1
movq %rax, %r14
movq %r12, %rdi
addq %rax, %rdi
movq %rax, %rsi
movq 0x10(%rsp), %r13
addq %r13, %rsi
movq 0x8(%rsp), %rax
movq (%rbx), %rcx
subq %rsi, %rax
leaq (%rax,%rcx), %rdx
incq %rdx
callq 0xba60
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xb520
movq 0x8(%rsp), %rax
subq %r13, %rax
addq (%rbx), %rax
cmpb $0x0, (%r12,%rax)
jne 0x4aaac
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1486b
callq 0x14832
callq 0x147f9
callq 0x147c0
callq 0x14787