// File: Alcaro[P]bridges/arlib/bmlwrite.cpp
// Function: bmlwriter::escape(cstring)
string bmlwriter::escape(cstring val)
{
	string esc = "-";
	bool needescape = (val.startswith("-"));
	for (uint8_t c : val.bytes())
	{
		if (isalnum(c) || c=='.') esc+=c;
		else if (c=='-') esc+="--";
		else { esc+="-"+tostringhex<2>((uint8_t)c); needescape=true; }
	}
	if (needescape) return esc;
	else return val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x160(%rbp)
movq %rdi, %rax
movq %rax, -0x158(%rbp)
movq %rdi, -0x80(%rbp)
movq %rsi, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
leaq -0xa0(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x57fb5(%rip), %rax     # 0x630e5
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x5c00
movq -0x150(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x5c20
leaq -0xb8(%rbp), %rdi
leaq 0x57f83(%rip), %rsi     # 0x630e5
callq 0x58c0
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x37e20
andb $0x1, %al
movb %al, -0xa1(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
leaq -0x68(%rbp), %rcx
movq %rcx, -0x18(%rbp)
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x148(%rbp)
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0xb1f5
movq -0x148(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movq -0x148(%rbp), %rsi
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, %edx
leaq -0x68(%rbp), %rdi
callq 0x5ed0
jmp 0xb20d
movq -0x148(%rbp), %rax
movq (%rax), %rsi
movl 0x8(%rax), %eax
movl %eax, %edx
leaq -0x68(%rbp), %rdi
callq 0x5ed0
movups -0x68(%rbp), %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0xbac0
movq %rax, -0xd8(%rbp)
movq -0xc0(%rbp), %rdi
callq 0xbae0
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rax
cmpq -0xe0(%rbp), %rax
je 0xb39a
movq -0xd8(%rbp), %rax
movb (%rax), %al
movb %al, -0xe1(%rbp)
movzbl -0xe1(%rbp), %edi
callq 0xb450
testb $0x1, %al
jne 0xb29e
movzbl -0xe1(%rbp), %eax
cmpl $0x2e, %eax
jne 0xb2b6
leaq -0xa0(%rbp), %rdi
movzbl -0xe1(%rbp), %esi
callq 0x9f60
jmp 0xb381
movzbl -0xe1(%rbp), %eax
cmpl $0x2d, %eax
jne 0xb2da
leaq -0xa0(%rbp), %rdi
leaq 0x57ddd(%rip), %rsi     # 0x630ad
callq 0x5ce0
jmp 0xb37f
leaq -0x128(%rbp), %rdi
movzbl -0xe1(%rbp), %esi
callq 0xbb00
movq -0x128(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x118(%rbp), %rdx
movq -0x110(%rbp), %rcx
leaq -0x108(%rbp), %rdi
leaq 0x57dc0(%rip), %rsi     # 0x630e5
callq 0x57e0
movq -0x108(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x5e00
leaq -0x108(%rbp), %rdi
callq 0x5870
leaq -0x128(%rbp), %rdi
callq 0x5870
movb $0x1, -0xa1(%rbp)
jmp 0xb381
jmp 0xb383
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0xb25f
testb $0x1, -0xa1(%rbp)
je 0xb3c2
movq -0x160(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x5d40
movl $0x1, -0x12c(%rbp)
jmp 0xb429
movq -0x160(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, -0x140(%rbp)
movq -0x88(%rbp), %rcx
movq %rcx, -0x138(%rbp)
movq -0x140(%rbp), %rdx
movq -0x138(%rbp), %rcx
movq %rdx, -0x30(%rbp)
movq %rcx, -0x28(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x5c00
movq -0x168(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x37020
movl $0x1, -0x12c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5870
movq -0x158(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw %cs:(%rax,%rax)