// File: /workspace/github_c_makefile_star2_O3/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 0x229a
cmpl $0x40, %eax
je 0x20d0
incq %r13
jmp 0x20b9
cmpb $0x40, -0x3(%r13)
jne 0x22a7
movq %rcx, (%rsp)
xorl %r15d, %r15d
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl %ebx, %ecx
callq 0x233f
movl %eax, %ebp
testl %ebx, %ebx
jle 0x2101
movb $0x28, (%r14)
movl $0x1, %r15d
cmpb $0x59, -0x2(%r13)
jne 0x22f2
cmpb $0x41, -0x1(%r13)
jne 0x22f2
cmpl %ebx, %r15d
jge 0x2302
xorl %r8d, %r8d
movzbl (%r13), %ecx
testb $-0x41, %cl
je 0x2302
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 0x215a
cmpb $0x0, 0x2(%r12)
sete %al
subl $0x1, %r8d
jb 0x216f
testb %al, %al
jne 0x216f
movslq %r15d, %rsi
incl %r15d
movb $0x2c, (%r14,%rsi)
cmpb $0x5f, %cl
jne 0x2198
movzbl (%rdx), %ecx
leal -0x44(%rcx), %edx
cmpl $0x16, %edx
ja 0x21f6
leaq 0x349a(%rip), %rsi      # 0x5620
movslq (%rsi,%rdx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
leaq 0x35b0(%rip), %rdi      # 0x5746
jmp 0x21bc
movb (%r13), %cl
addb $-0x43, %cl
leaq 0x35a0(%rip), %rdi      # 0x5746
cmpb $0x18, %cl
jae 0x21bc
movzbl %cl, %ecx
leaq 0x34c7(%rip), %rdx      # 0x567c
movslq (%rdx,%rcx,4), %rdi
addq %rdx, %rdi
testb %al, %al
jne 0x2330
incq %r12
movq %r14, %rsi
movl %r15d, %edx
movl %ebx, %ecx
movl %r8d, %r15d
callq 0x233f
movl %r15d, %r8d
movl %eax, %r15d
movq %r12, %r13
cmpl %ebx, %eax
jl 0x2123
jmp 0x2302
leaq 0x355b(%rip), %rdi      # 0x574f
jmp 0x21bc
leaq 0x3556(%rip), %rdi      # 0x5753
cmpl $0x24, %ecx
jne 0x218f
jmp 0x21bc
leaq 0x35a0(%rip), %rdi      # 0x57ab
jmp 0x21bc
leaq 0x34fc(%rip), %rdi      # 0x5710
jmp 0x21bc
leaq 0x3543(%rip), %rdi      # 0x5760
jmp 0x21bc
leaq 0x3572(%rip), %rdi      # 0x5798
jmp 0x21bc
leaq 0x34d9(%rip), %rdi      # 0x5708
jmp 0x21bc
leaq 0x356a(%rip), %rdi      # 0x57a2
jmp 0x21bc
leaq 0x3552(%rip), %rdi      # 0x5793
jmp 0x21bc
leaq 0x353d(%rip), %rdi      # 0x578a
jmp 0x21bc
leaq 0x3500(%rip), %rdi      # 0x5759
jmp 0x21bc
leaq 0x3513(%rip), %rdi      # 0x5778
jmp 0x21bc
leaq 0x34f7(%rip), %rdi      # 0x5768
jmp 0x21bc
leaq 0x34a0(%rip), %rdi      # 0x571d
jmp 0x21bc
leaq 0x34f8(%rip), %rdi      # 0x5781
jmp 0x21bc
leaq 0x34db(%rip), %rdi      # 0x5770
jmp 0x21bc
xorl %ebp, %ebp
testl %ebx, %ebx
jle 0x231f
movb $0x0, (%r12)
jmp 0x231f
addq $-0x3, %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movl %ebx, %r8d
callq 0x209e
cmpl %ebx, %eax
jge 0x22ca
movslq %eax, %rcx
incl %eax
movb $0x3a, (%r12,%rcx)
cmpl %ebx, %eax
jge 0x22d8
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 0x233f
cmpl %ebx, %r15d
jge 0x2302
movl %r15d, %eax
incl %r15d
movb $0x3f, (%r14,%rax)
cmpl %ebx, %r15d
jge 0x2312
movslq %r15d, %rax
incl %r15d
movb $0x29, (%r14,%rax)
cmpl %ebx, %r15d
jge 0x231f
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 0x233f
jmp 0x2302