// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/PathUtil.cpp
// Function: t2::PathFormatPartial(char (&) [512], t2::PathBuffer const*, int, int)
void PathFormatPartial(char (&output)[kMaxPathLength], const PathBuffer* buffer, int start_seg, int end_seg)
{
  char *cursor = &output[0];
  char pathsep = PathType::kWindows == buffer->m_Type ? '\\' : '/';

  if (start_seg == 0 &&
      PathBuffer::kFlagAbsolute ==
      (buffer->m_Flags & (PathBuffer::kFlagAbsolute|PathBuffer::kFlagWindowsDevicePath)))
  {
    *cursor++ = pathsep;
  }

  // Emit all leading ".." tokens we've got left
  for (int i = 0, count = buffer->m_LeadingDotDots; i < count; ++i)
  {
    *cursor++ = '.';
    *cursor++ = '.';
    *cursor++ = pathsep;
  }

  // Emit all remaining tokens.
  uint16_t off = 0;

  for (int i = 0; i < start_seg; ++i)
  {
    off += buffer->SegLength(i);
  }

  for (int i = start_seg; i <= end_seg; ++i)
  {
    uint16_t len = buffer->SegLength(i);

    if ((cursor - &output[0]) + len + 1 >= kMaxPathLength)
      Croak("Path too long");

    if (i > start_seg)
      *cursor++ = pathsep;

    memcpy(cursor, buffer->m_Data + off, len);
    cursor += len;
    off += len;
  }
  *cursor = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edx
movl $0x1, %ecx
movb $0x5c, %al
movb $0x2f, %sil
movb %sil, -0x3c(%rbp)
cmpl %edx, %ecx
movb %al, -0x3b(%rbp)
je 0x1962f
movb -0x3c(%rbp), %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
movb %al, -0x21(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x19663
movq -0x10(%rbp), %rax
movzwl 0x4(%rax), %ecx
andl $0x3, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x19663
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x196c0
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x2e, (%rax)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x2e, (%rax)
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x19675
movw $0x0, -0x2e(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x196f9
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x7490
movzwl %ax, %ecx
movzwl -0x2e(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x2e(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x196cd
movl -0x14(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x197b4
movq -0x10(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x7490
movw %ax, -0x3a(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movzwl -0x3a(%rbp), %ecx
addq %rcx, %rax
addq $0x1, %rax
cmpq $0x200, %rax            # imm = 0x200
jl 0x19747
leaq 0xba65(%rip), %rdi      # 0x251a5
movb $0x0, %al
callq 0x75a0
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x19763
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x8a, %rsi
movzwl -0x2e(%rbp), %eax
cltq
addq %rax, %rsi
movzwl -0x3a(%rbp), %eax
movl %eax, %edx
callq 0x32a0
movzwl -0x3a(%rbp), %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movzwl -0x3a(%rbp), %ecx
movzwl -0x2e(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x2e(%rbp)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x196ff
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)