// File: Alcaro[P]bridges/arlib/file.cpp
// Function: file::resolve(cstring)
string file::resolve(cstring path)
{
	array<cstring> parts = path.csplit("/");
	for (size_t i=0;i<parts.size();i++)
	{
		if (parts[i] == "" && i>0 && parts[i-1] != "")
		{
			parts.remove(i);
			i--;
			continue;
		}
		
		if (parts[i] == ".")
		{
			parts.remove(i);
			i--;
			continue;
		}
		
		if (parts[i] == ".." && i>0 && parts[i-1] != "..")
		{
			parts.remove(i);
			if (i>0) parts.remove(i-1);
			i-=2;
			continue;
		}
	}
	if (!parts) return ".";
	return parts.join("/");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x370, %rsp            # imm = 0x370
movq %rdi, -0x348(%rbp)
movq %rdi, %rax
movq %rax, -0x340(%rbp)
movq %rdi, -0x2f8(%rbp)
movq %rsi, -0x308(%rbp)
movq %rdx, -0x300(%rbp)
leaq -0x328(%rbp), %rdi
leaq 0x5247b(%rip), %rsi     # 0x63fda
callq 0x58c0
movq -0x328(%rbp), %rdx
movq -0x320(%rbp), %rcx
leaq -0x318(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x129e0
movq $0x0, -0x330(%rbp)
movq -0x330(%rbp), %rax
movq %rax, -0x350(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x12a40
movq %rax, %rcx
movq -0x350(%rbp), %rax
cmpq %rcx, %rax
jae 0x1208c
movq -0x330(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x26500
movq %rax, -0x240(%rbp)
leaq 0x5486b(%rip), %rax     # 0x66449
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
callq 0x40f0
movq %rax, -0x250(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
leaq -0xe8(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x358(%rbp)
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x11c70
movq -0x358(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5cc0
movq -0x358(%rbp), %rsi
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, %edx
leaq -0xe8(%rbp), %rdi
callq 0x5ed0
jmp 0x11c8b
movq -0x358(%rbp), %rax
movq (%rax), %rsi
movl 0x8(%rax), %eax
movl %eax, %edx
leaq -0xe8(%rbp), %rdi
callq 0x5ed0
movups -0xe8(%rbp), %xmm0
movaps %xmm0, -0xd0(%rbp)
movq -0xd0(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq %rcx, -0x260(%rbp)
movq %rax, -0x258(%rbp)
movq -0x248(%rbp), %rsi
movq -0x250(%rbp), %rdx
leaq -0x270(%rbp), %rdi
callq 0x5d70
movq -0x270(%rbp), %rsi
movq -0x268(%rbp), %rdx
leaq -0x260(%rbp), %rdi
callq 0x60c0
andb $0x1, %al
movb %al, -0x231(%rbp)
testb $0x1, -0x231(%rbp)
jne 0x11cfc
jmp 0x11d5c
cmpq $0x0, -0x330(%rbp)
jbe 0x11d5c
movq -0x330(%rbp), %rsi
subq $0x1, %rsi
leaq -0x318(%rbp), %rdi
callq 0x26500
movq %rax, %rdi
leaq 0x54722(%rip), %rsi     # 0x66449
callq 0x59e0
testb $0x1, %al
jne 0x11d32
jmp 0x11d5c
movq -0x330(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x26870
movq -0x330(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x330(%rbp)
jmp 0x12075
movq -0x330(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x26500
movq %rax, -0x280(%rbp)
leaq 0x54365(%rip), %rax     # 0x660e2
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
callq 0x40f0
movq %rax, -0x290(%rbp)
movq -0x280(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x360(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x11e0f
movq -0x360(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5cc0
movq -0x360(%rbp), %rsi
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, %edx
leaq -0xb8(%rbp), %rdi
callq 0x5ed0
jmp 0x11e2a
movq -0x360(%rbp), %rax
movq (%rax), %rsi
movl 0x8(%rax), %eax
movl %eax, %edx
leaq -0xb8(%rbp), %rdi
callq 0x5ed0
movups -0xb8(%rbp), %xmm0
movaps %xmm0, -0xa0(%rbp)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x2a0(%rbp)
movq %rax, -0x298(%rbp)
movq -0x288(%rbp), %rsi
movq -0x290(%rbp), %rdx
leaq -0x2b0(%rbp), %rdi
callq 0x5d70
movq -0x2b0(%rbp), %rsi
movq -0x2a8(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x60c0
andb $0x1, %al
movb %al, -0x271(%rbp)
testb $0x1, -0x271(%rbp)
jne 0x11e9b
jmp 0x11ec5
movq -0x330(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x26870
movq -0x330(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x330(%rbp)
jmp 0x12075
movq -0x330(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x26500
movq %rax, -0x2c0(%rbp)
leaq 0x541fb(%rip), %rax     # 0x660e1
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rdi
callq 0x40f0
movq %rax, -0x2d0(%rbp)
movq -0x2c0(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
leaq -0x88(%rbp), %rcx
movq %rcx, -0x58(%rbp)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x368(%rbp)
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x5cc0
movsbl %al, %eax
cmpl $0x0, %eax
jl 0x11f72
movq -0x368(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movq -0x368(%rbp), %rsi
movsbl %al, %eax
xorl $0xf, %eax
movzbl %al, %eax
movl %eax, %edx
leaq -0x88(%rbp), %rdi
callq 0x5ed0
jmp 0x11f8d
movq -0x368(%rbp), %rax
movq (%rax), %rsi
movl 0x8(%rax), %eax
movl %eax, %edx
leaq -0x88(%rbp), %rdi
callq 0x5ed0
movups -0x88(%rbp), %xmm0
movaps %xmm0, -0x70(%rbp)
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x2e0(%rbp)
movq %rax, -0x2d8(%rbp)
movq -0x2c8(%rbp), %rsi
movq -0x2d0(%rbp), %rdx
leaq -0x2f0(%rbp), %rdi
callq 0x5d70
movq -0x2f0(%rbp), %rsi
movq -0x2e8(%rbp), %rdx
leaq -0x2e0(%rbp), %rdi
callq 0x60c0
andb $0x1, %al
movb %al, -0x2b1(%rbp)
testb $0x1, -0x2b1(%rbp)
jne 0x11ff5
jmp 0x12073
cmpq $0x0, -0x330(%rbp)
jbe 0x12073
movq -0x330(%rbp), %rsi
subq $0x1, %rsi
leaq -0x318(%rbp), %rdi
callq 0x26500
movq %rax, %rdi
leaq 0x540c1(%rip), %rsi     # 0x660e1
callq 0x59e0
testb $0x1, %al
jne 0x1202b
jmp 0x12073
movq -0x330(%rbp), %rsi
leaq -0x318(%rbp), %rdi
callq 0x26870
cmpq $0x0, -0x330(%rbp)
jbe 0x1205f
movq -0x330(%rbp), %rsi
subq $0x1, %rsi
leaq -0x318(%rbp), %rdi
callq 0x26870
movq -0x330(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x330(%rbp)
jmp 0x12075
jmp 0x12075
movq -0x330(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x330(%rbp)
jmp 0x11b90
leaq -0x318(%rbp), %rdi
callq 0x12a60
testb $0x1, %al
jne 0x120ea
movq -0x348(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq 0x54031(%rip), %rax     # 0x660e2
movq %rax, -0x230(%rbp)
movq -0x228(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x5c00
movq -0x370(%rbp), %rdi
movq -0x230(%rbp), %rsi
callq 0x5c20
movl $0x1, -0x334(%rbp)
jmp 0x1210e
movq -0x348(%rbp), %rdi
leaq -0x318(%rbp), %rsi
leaq 0x51edb(%rip), %rdx     # 0x63fda
callq 0x12a80
movl $0x1, -0x334(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x26f60
movq -0x340(%rbp), %rax
addq $0x370, %rsp            # imm = 0x370
popq %rbp
retq
nopw (%rax,%rax)