// File: /workspace/github_c_makefile_star2_O2/mikeakohn[P]print_pe/build/../src/demangle.c
// Function: demangle_name
static int demangle_name(
  const char *name,
  char *demangled,
  char *params,
  char *return_type,
  int offset,
  int length)
{
  const char *s = name;
  int ptr = 0;

  while (s[ptr] != 0)
  {
    if (s[ptr] == '@')
    {
      if (s[ptr + 1] == '@')
      {
        offset = demangle_insert_name(name, demangled, offset, length);
        demangle_params(s + ptr + 2, params, return_type, 0, length);
        return offset;
      }
        else
      {
        offset = demangle_name(s + ptr + 1, demangled, params, return_type, offset, length);
        if (offset < length) { demangled[offset++] = ':'; }
        if (offset < length) { demangled[offset++] = ':'; }
        offset = demangle_insert_name(name, demangled, offset, length);
        return offset;
      }
    }

    ptr++;
  }

  if (offset < length) { demangled[offset] = 0; }

  return offset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbp
leaq 0x4(%rdi), %r13
movzbl -0x4(%r13), %eax
testl %eax, %eax
je 0x222b
cmpl $0x40, %eax
je 0x206e
incq %r13
jmp 0x2057
cmpb $0x40, -0x3(%r13)
jne 0x2238
movq %rcx, (%rsp)
xorl %r15d, %r15d
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl %ebx, %ecx
callq 0x22d0
movl %eax, %ebp
testl %ebx, %ebx
jle 0x209d
movb $0x28, (%r14)
pushq $0x1
popq %r15
cmpb $0x59, -0x2(%r13)
jne 0x2283
cmpb $0x41, -0x1(%r13)
jne 0x2283
xorl %r8d, %r8d
cmpl %ebx, %r15d
jge 0x2293
movzbl (%r13), %ecx
testb $-0x41, %cl
je 0x2293
leaq 0x1(%r13), %rdx
cmpb $0x5f, %cl
movq %r13, %r12
cmoveq %rdx, %r12
movb 0x1(%r12), %sil
cmpb $0x40, %sil
sete %al
cmpb $0x5a, %sil
jne 0x20f6
cmpb $0x0, 0x2(%r12)
sete %al
subl $0x1, %r8d
jb 0x210b
testb %al, %al
jne 0x210b
movslq %r15d, %rsi
incl %r15d
movb $0x2c, (%r14,%rsi)
cmpb $0x5f, %cl
jne 0x2134
movzbl (%rdx), %ecx
leal -0x44(%rcx), %edx
cmpl $0x16, %edx
ja 0x218a
leaq 0x24fe(%rip), %rsi      # 0x4620
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
leaq 0x2614(%rip), %rdi      # 0x4746
jmp 0x2158
movb (%r13), %cl
addb $-0x43, %cl
leaq 0x2604(%rip), %rdi      # 0x4746
cmpb $0x18, %cl
jae 0x2158
movzbl %cl, %ecx
leaq 0x252b(%rip), %rdx      # 0x467c
movslq (%rdx,%rcx,4), %rdi
addq %rdx, %rdi
testb %al, %al
jne 0x22c1
incq %r12
movq %r14, %rsi
movl %r15d, %edx
movl %ebx, %ecx
movl %r8d, %r15d
callq 0x22d0
movl %r15d, %r8d
movl %eax, %r15d
movq %r12, %r13
jmp 0x20b6
leaq 0x25c7(%rip), %rdi      # 0x474f
jmp 0x2158
leaq 0x25c2(%rip), %rdi      # 0x4753
cmpl $0x24, %ecx
jne 0x212b
jmp 0x2158
leaq 0x260c(%rip), %rdi      # 0x47ab
jmp 0x2158
leaq 0x2568(%rip), %rdi      # 0x4710
jmp 0x2158
leaq 0x25af(%rip), %rdi      # 0x4760
jmp 0x2158
leaq 0x25de(%rip), %rdi      # 0x4798
jmp 0x2158
leaq 0x2545(%rip), %rdi      # 0x4708
jmp 0x2158
leaq 0x25d6(%rip), %rdi      # 0x47a2
jmp 0x2158
leaq 0x25be(%rip), %rdi      # 0x4793
jmp 0x2158
leaq 0x25ac(%rip), %rdi      # 0x478a
jmp 0x2158
leaq 0x256f(%rip), %rdi      # 0x4759
jmp 0x2158
leaq 0x2582(%rip), %rdi      # 0x4778
jmp 0x2158
leaq 0x2566(%rip), %rdi      # 0x4768
jmp 0x2158
leaq 0x250f(%rip), %rdi      # 0x471d
jmp 0x2158
leaq 0x2567(%rip), %rdi      # 0x4781
jmp 0x2158
leaq 0x254a(%rip), %rdi      # 0x4770
jmp 0x2158
xorl %ebp, %ebp
testl %ebx, %ebx
jle 0x22b0
movb $0x0, (%r12)
jmp 0x22b0
addq $-0x3, %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebx, %r8d
callq 0x203c
cmpl %ebx, %eax
jge 0x225b
movslq %eax, %rcx
incl %eax
movb $0x3a, (%r12,%rcx)
cmpl %ebx, %eax
jge 0x2269
movslq %eax, %rcx
incl %eax
movb $0x3a, (%r12,%rcx)
movq %rbp, %rdi
movq %r12, %rsi
movl %eax, %edx
movl %ebx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22d0
cmpl %ebx, %r15d
jge 0x2293
movl %r15d, %eax
incl %r15d
movb $0x3f, (%r14,%rax)
cmpl %ebx, %r15d
jge 0x22a3
movslq %r15d, %rax
incl %r15d
movb $0x29, (%r14,%rax)
cmpl %ebx, %r15d
jge 0x22b0
movslq %r15d, %rax
movb $0x0, (%r14,%rax)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rsi
xorl %edx, %edx
movl %ebx, %ecx
callq 0x22d0
jmp 0x2293