// File: mh0fm4[P]SCDC/src/components/common/common.cc
// Function: normalize_path(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
void normalize_path(const char *path, string &normalized)
{
  SCDC_TRACE("normalize_path: path: '" << ((path)?path:"") << "'");

  normalized = "";

  if (!path) return;

  vector<string> parts;

  const char *p, *s = path;

  while (1)
  {
    p = strchr(s, '/');
    if (!p) p = s + strlen(s);

    string t(s, p - s);

    if (t == ".");
    else if (t == ".." && !parts.empty() && parts.back() != "..") parts.pop_back();
    else if (t.size() > 0) parts.push_back(t);
    
    if (p[0] == '\0') break;

    s = p + 1;
  }

  for (vector<string>::iterator i = parts.begin(); i != parts.end(); ++i)
  {
    if (path[0] == '/' || i != parts.begin()) normalized += "/";

    normalized += *i;
  }

  SCDC_TRACE("normalize_path: normalized: '" << normalized << "'");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
jmp 0x2ac35
movq -0x10(%rbp), %rdi
leaq 0x7b964(%rip), %rsi     # 0xa65a4
callq 0xc920
cmpq $0x0, -0x8(%rbp)
jne 0x2ac51
jmp 0x2aeec
leaq -0x28(%rbp), %rdi
callq 0x2b0c0
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x2ac64
movq -0x38(%rbp), %rdi
movl $0x2f, %esi
callq 0xc220
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x2aca2
movq -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rdi
callq 0xc280
movq %rax, %rcx
movq -0x90(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xa0(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0xcbc0
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
movq -0x98(%rbp), %rcx
leaq -0x58(%rbp), %rdi
callq 0xc7a0
jmp 0x2aceb
leaq -0x59(%rbp), %rdi
callq 0xc730
leaq 0x7b675(%rip), %rsi     # 0xa6370
leaq -0x58(%rbp), %rdi
callq 0x25b80
movb %al, -0xa9(%rbp)
jmp 0x2ad0c
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x2ad18
jmp 0x2ad51
jmp 0x2addd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0xc730
jmp 0x2aef5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xc3e0
jmp 0x2aef5
leaq 0x7b617(%rip), %rsi     # 0xa636f
leaq -0x58(%rbp), %rdi
callq 0x25b80
movb %al, -0xaa(%rbp)
jmp 0x2ad69
movb -0xaa(%rbp), %al
testb $0x1, %al
jne 0x2ad75
jmp 0x2adb9
leaq -0x28(%rbp), %rdi
callq 0x2b0e0
testb $0x1, %al
jne 0x2adb9
leaq -0x28(%rbp), %rdi
callq 0x2b150
movq %rax, %rdi
leaq 0x7b5da(%rip), %rsi     # 0xa636f
callq 0x2b120
movb %al, -0xab(%rbp)
jmp 0x2ada2
movb -0xab(%rbp), %al
testb $0x1, %al
jne 0x2adae
jmp 0x2adb9
leaq -0x28(%rbp), %rdi
callq 0x2b190
jmp 0x2addb
leaq -0x58(%rbp), %rdi
callq 0xc460
cmpq $0x0, %rax
jbe 0x2add9
leaq -0x28(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2b1c0
jmp 0x2add7
jmp 0x2add9
jmp 0x2addb
jmp 0x2addd
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2adf2
movl $0x5, -0x70(%rbp)
jmp 0x2ae05
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x70(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xc3e0
movl -0x70(%rbp), %eax
testl %eax, %eax
je 0x2ae19
jmp 0x2ae17
jmp 0x2ae1e
jmp 0x2ac62
leaq -0x28(%rbp), %rdi
callq 0x2b230
movq %rax, -0x78(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2b2a0
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2b260
testb $0x1, %al
jne 0x2ae4e
jmp 0x2aedd
movq -0x8(%rbp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x2f, %ecx
movb %al, -0xac(%rbp)
je 0x2ae88
leaq -0x28(%rbp), %rdi
callq 0x2b230
movq %rax, -0x88(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x2b260
movb %al, -0xac(%rbp)
movb -0xac(%rbp), %al
testb $0x1, %al
jne 0x2ae94
jmp 0x2aeb6
movq -0x10(%rbp), %rdi
leaq 0x7b4ce(%rip), %rsi     # 0xa636d
callq 0xc630
jmp 0x2aea6
jmp 0x2aeb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2aef5
leaq -0x78(%rbp), %rdi
callq 0x2b2d0
movq %rax, %rsi
movq -0x10(%rbp), %rdi
callq 0xc8a0
jmp 0x2aecd
jmp 0x2aecf
leaq -0x78(%rbp), %rdi
callq 0x2b2f0
jmp 0x2ae2b
jmp 0x2aedf
jmp 0x2aee1
jmp 0x2aee3
leaq -0x28(%rbp), %rdi
callq 0x2b310
addq $0xb0, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x2b310
movq -0x68(%rbp), %rdi
callq 0xcba0
nopw (%rax,%rax)