// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/PathUtil.cpp
// Function: void t2::PathConcatImpl<t2::PathBuffer>(t2::PathBuffer*, t2::PathBuffer const*)
static void PathConcatImpl(PathBuffer* buffer, const T* other)
{
  CHECK(!PathIsAbsolute(other));

  int seg_count = buffer->m_SegCount;

  int min_seg_count = (buffer->m_Flags & PathBuffer::kFlagWindowsDevicePath) ? 1 : 0;

  // Start by throwing away .. from the other path
  for (int i = 0, count = other->m_LeadingDotDots; i < count; ++i)
  {
    if (seg_count > min_seg_count)
    {
      seg_count--;
    }
    else if (seg_count == 0)
    {
      buffer->m_LeadingDotDots++;
    }
  }

  // Can't go higher than root directory. Just clamp to there.
  if (PathIsAbsolute(buffer))
  {
    buffer->m_LeadingDotDots = 0;
  }

  // Compute how much of our data buffer we need to keep
  int keep_buffer = BufferSize(buffer, seg_count);
  // Compute size of the other buffer.
  int other_buffer = BufferSize(other, other->m_SegCount);

  CHECK(seg_count + other->m_SegCount <= kMaxPathSegments);
  CHECK(keep_buffer + other_buffer <= kMaxPathLength);

  memcpy(buffer->m_Data + keep_buffer, other->m_Data, other_buffer);
  for (int i = 0, count = other->m_SegCount; i < count; ++i)
  {
    buffer->m_SegEnds[seg_count + i] = uint16_t(other->m_SegEnds[i] + keep_buffer);
  }
  
  buffer->m_SegCount = uint16_t(seg_count + other->m_SegCount);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
jmp 0x19472
movq -0x8(%rbp), %rax
movzwl 0x6(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %edx
andl $0x2, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x8(%rax), %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x194ea
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x194c5
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x194dd
cmpl $0x0, -0x14(%rbp)
jne 0x194db
movq -0x8(%rbp), %rax
movw 0x8(%rax), %cx
addw $0x1, %cx
movw %cx, 0x8(%rax)
jmp 0x194dd
jmp 0x194df
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x194aa
movq -0x8(%rbp), %rdi
callq 0x19810
testb $0x1, %al
jne 0x194f9
jmp 0x19503
movq -0x8(%rbp), %rax
movw $0x0, 0x8(%rax)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x197d0
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movzwl 0x6(%rax), %esi
callq 0x197d0
movl %eax, -0x28(%rbp)
jmp 0x19528
jmp 0x1952a
jmp 0x1952c
movq -0x8(%rbp), %rdi
addq $0x8a, %rdi
movslq -0x24(%rbp), %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
addq $0x8a, %rsi
movslq -0x28(%rbp), %rdx
callq 0x32a0
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x6(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1959c
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzwl 0xa(%rax,%rcx,2), %eax
addl -0x24(%rbp), %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movslq %ecx, %rcx
movw %dx, 0xa(%rax,%rcx,2)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x19564
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x6(%rcx), %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x6(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)