// File: /workspace/github_c_makefile_star2_O3/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 0x49e50
movq %rdx, %r15
testq %rdx, %rdx
je 0x49e50
movq %rsi, %r13
testq %rsi, %rsi
je 0x49e50
movq %rdi, %rbx
movq (%rdi), %r12
testq %r12, %r12
je 0x49e50
cmpb $0x0, (%r13)
je 0x49e55
movq %r15, %rdi
callq 0xb260
testq %rax, %rax
je 0x49e5a
movq %rax, %r14
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x49adb
testq %rax, %rax
je 0x49d97
movq %rax, %rbp
movq %rax, %rdi
callq 0xb260
movq (%rbx), %rdi
movq %rdi, %rdx
movq %rdx, %rcx
incq %rdx
cmpb $0x0, (%rcx)
jne 0x49d10
leaq 0x2(%rcx), %rdx
cmpb $0x0, 0x1(%rcx)
jne 0x49d10
movq %rdi, %rcx
notq %rcx
addq %rcx, %rdx
movq %rdx, 0x8(%rsp)
movq %r14, %r12
subq %rax, %r14
jae 0x49daa
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 0x9f709(%rip), %rdx     # 0xe948e
movl $0xb1, %ecx
callq 0x35a9d
movq %rax, (%rbx)
jmp 0x49e2f
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x499d4
jmp 0x49e41
movq %rax, 0x10(%rsp)
jne 0x49dc6
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xb520
movq 0x10(%rsp), %r13
jmp 0x49e2f
leaq (%r14,%rdx), %rsi
incq %rsi
leaq 0x9f6ba(%rip), %rdx     # 0xe948e
movl $0xb7, %ecx
callq 0x35a9d
movq %rax, (%rbx)
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x49adb
testq %rax, %rax
je 0x49e64
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 0x49e5f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x14750
callq 0x14717
callq 0x146de
callq 0x146a5
callq 0x1466c