// File: Nallantli[P]Rossa/main/rossa/global/global.cpp
// Function: global::convertToMediator(symbol_t const&, token_t const*, std::vector<std::pair<token_t, function_t>, std::allocator<std::pair<token_t, function_t>>>&)
const mediator_t global::convertToMediator(const symbol_t &s, const token_t *token, trace_t &stack_trace)
{
	switch (s.getValueType())
	{
	case NIL:
		return mediator_t();
	case BOOLEAN_D:
		return mediator_t(
			MEDIATOR_BOOLEAN_D,
			std::make_shared<bool>(s.getBool(token, stack_trace)));
	case NUMBER:
		return mediator_t(
			MEDIATOR_NUMBER,
			std::make_shared<number_t>(s.getNumber(token, stack_trace)));
	case STRING:
		return mediator_t(
			MEDIATOR_STRING,
			std::make_shared<std::string>(s.getString(token, stack_trace)));
	case POINTER:
		return mediator_t(
			MEDIATOR_POINTER,
			s.getPointer(token, stack_trace));
	case FUNCTION:
		return MAKE_POINTER(s.getFunction({}, token, stack_trace));
	case ARRAY:
	{
		std::vector<mediator_t> mv;
		for (auto &e : s.getVector(token, stack_trace))
		{
			mv.push_back(convertToMediator(e, token, stack_trace));
		}
		return mediator_t(
			MEDIATOR_ARRAY,
			std::make_shared<std::vector<mediator_t>>(mv));
	}
	case DICTIONARY:
	{
		std::map<const std::string, const mediator_t> md;
		for (auto &e : s.getDictionary(token, stack_trace))
		{
			md.insert({e.first, convertToMediator(e.second, token, stack_trace)});
		}
		return MAKE_DICTIONARY(md);
	}
	default:
		throw rossa_error_t("[this shouldn't happen] Improper symbol_t to mediator_t conversion: " + s.toCodeString(), *token, stack_trace);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rdi, -0x2d0(%rbp)
movq %rdi, %rax
movq %rax, -0x2c8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x883e0
addl $0xa, %eax
movl %eax, %ecx
movq %rcx, -0x2c0(%rbp)
subl $0x9, %eax
ja 0xc9329
movq -0x2c0(%rbp), %rax
leaq 0x8a63c(%rip), %rcx     # 0x1531e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x2d0(%rbp), %rdi
callq 0x127e00
jmp 0xc9408
movl $0xfffffffd, -0x24(%rbp) # imm = 0xFFFFFFFD
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x881f0
movb %al, -0x49(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
leaq -0x49(%rbp), %rsi
callq 0xc9e60
movq -0x2e0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0xc9ed0
movq -0x2d0(%rbp), %rdi
movq -0x2d8(%rbp), %rdx
leaq -0x24(%rbp), %rsi
callq 0x127e30
jmp 0xc8c21
leaq -0x38(%rbp), %rdi
callq 0x8e610
leaq -0x48(%rbp), %rdi
callq 0xc9f00
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x8e610
leaq -0x48(%rbp), %rdi
callq 0xc9f00
jmp 0xc9418
movl $0xfffffffe, -0x60(%rbp) # imm = 0xFFFFFFFE
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x87a00
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0xc9f20
movq -0x2f0(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
callq 0xc9f90
movq -0x2d0(%rbp), %rdi
movq -0x2e8(%rbp), %rdx
leaq -0x60(%rbp), %rsi
callq 0x127e30
jmp 0xc8cb6
leaq -0x70(%rbp), %rdi
callq 0x8e610
leaq -0x80(%rbp), %rdi
callq 0xc9fc0
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x8e610
leaq -0x80(%rbp), %rdi
callq 0xc9fc0
jmp 0xc9418
movl $0xfffffffc, -0x84(%rbp) # imm = 0xFFFFFFFC
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x880d0
movq -0x2f8(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0xc9fe0
jmp 0xc8d2e
leaq -0x98(%rbp), %rdi
movq %rdi, -0x300(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0xca050
movq -0x2d0(%rbp), %rdi
movq -0x300(%rbp), %rdx
leaq -0x84(%rbp), %rsi
callq 0x127e30
jmp 0xc8d64
leaq -0x98(%rbp), %rdi
callq 0x8e610
leaq -0xa8(%rbp), %rdi
callq 0xca080
leaq -0xc8(%rbp), %rdi
callq 0x11360
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc8dbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x8e610
leaq -0xa8(%rbp), %rdi
callq 0xca080
leaq -0xc8(%rbp), %rdi
callq 0x11360
jmp 0xc9418
movl $0xfffffff6, -0xcc(%rbp) # imm = 0xFFFFFFF6
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x87af0
movq -0x2d0(%rbp), %rdi
movq -0x308(%rbp), %rdx
leaq -0xcc(%rbp), %rsi
callq 0x127e30
jmp 0xc8e15
leaq -0xe0(%rbp), %rdi
callq 0x8e610
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x8e610
jmp 0xc9418
movl $0xfffffff6, -0xe4(%rbp) # imm = 0xFFFFFFF6
movq -0x10(%rbp), %rax
movq %rax, -0x318(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x120(%rbp)
movq $0x0, -0x110(%rbp)
leaq -0x120(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x2cc30
movq -0x318(%rbp), %rsi
movq -0x310(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq -0x108(%rbp), %rdi
callq 0x88920
jmp 0xc8ea4
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x320(%rbp)
leaq -0x108(%rbp), %rsi
callq 0xca0a0
movq -0x2d0(%rbp), %rdi
movq -0x320(%rbp), %rdx
leaq -0xe4(%rbp), %rsi
callq 0x127e30
jmp 0xc8eda
leaq -0xf8(%rbp), %rdi
callq 0x8e610
leaq -0x108(%rbp), %rdi
callq 0x85eb0
leaq -0x120(%rbp), %rdi
callq 0x2cf10
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc8f35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8e610
leaq -0x108(%rbp), %rdi
callq 0x85eb0
leaq -0x120(%rbp), %rdi
callq 0x2cf10
jmp 0xc9418
leaq -0x138(%rbp), %rdi
callq 0xca0d0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x87fe0
movq %rax, -0x328(%rbp)
jmp 0xc8f6c
movq -0x328(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rdi
callq 0x24ba0
movq %rax, -0x148(%rbp)
movq -0x140(%rbp), %rdi
callq 0x24bd0
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x24c00
testb $0x1, %al
jne 0xc8fbc
jmp 0xc9049
leaq -0x148(%rbp), %rdi
callq 0x24c40
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x170(%rbp), %rdi
callq 0xc8b50
jmp 0xc8fec
leaq -0x138(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xca0f0
jmp 0xc9001
leaq -0x170(%rbp), %rdi
callq 0xca160
leaq -0x148(%rbp), %rdi
callq 0x24e20
jmp 0xc8fa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc90eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0xca160
jmp 0xc90eb
movl $0xfffffffb, -0x174(%rbp) # imm = 0xFFFFFFFB
leaq -0x198(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xca180
jmp 0xc9068
leaq -0x188(%rbp), %rdi
movq %rdi, -0x330(%rbp)
leaq -0x198(%rbp), %rsi
callq 0xca1f0
movq -0x2d0(%rbp), %rdi
movq -0x330(%rbp), %rdx
leaq -0x174(%rbp), %rsi
callq 0x127e30
jmp 0xc909e
leaq -0x188(%rbp), %rdi
callq 0x8e610
leaq -0x198(%rbp), %rdi
callq 0xca220
leaq -0x138(%rbp), %rdi
callq 0xca240
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x8e610
leaq -0x198(%rbp), %rdi
callq 0xca220
leaq -0x138(%rbp), %rdi
callq 0xca240
jmp 0xc9418
leaq -0x1c8(%rbp), %rdi
callq 0xca2a0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x87c10
movq %rax, -0x338(%rbp)
jmp 0xc9122
movq -0x338(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x1d0(%rbp), %rdi
callq 0x8c0f0
movq %rax, -0x1d8(%rbp)
movq -0x1d0(%rbp), %rdi
callq 0x8bff0
movq %rax, -0x1e0(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x8bf90
testb $0x1, %al
jne 0xc9172
jmp 0xc9276
leaq -0x1d8(%rbp), %rdi
callq 0x8c120
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rsi
movq %rsi, -0x340(%rbp)
addq $0x20, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x238(%rbp), %rdi
callq 0xc8b50
jmp 0xc91ad
movq -0x340(%rbp), %rsi
leaq -0x220(%rbp), %rdi
leaq -0x238(%rbp), %rdx
callq 0xca300
jmp 0xc91c9
leaq -0x1c8(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0xca2c0
movb %dl, -0x349(%rbp)
movq %rax, -0x348(%rbp)
jmp 0xc91eb
movb -0x349(%rbp), %al
movq -0x348(%rbp), %rcx
movq %rcx, -0x248(%rbp)
movb %al, -0x240(%rbp)
leaq -0x220(%rbp), %rdi
callq 0xca340
leaq -0x238(%rbp), %rdi
callq 0xca160
leaq -0x1d8(%rbp), %rdi
callq 0x8c140
jmp 0xc9156
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc9318
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc9265
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0xca340
leaq -0x238(%rbp), %rdi
callq 0xca160
jmp 0xc9318
movl $0xfffffff9, -0x24c(%rbp) # imm = 0xFFFFFFF9
leaq -0x270(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0xca370
jmp 0xc9295
leaq -0x260(%rbp), %rdi
movq %rdi, -0x358(%rbp)
leaq -0x270(%rbp), %rsi
callq 0xca3e0
movq -0x2d0(%rbp), %rdi
movq -0x358(%rbp), %rdx
leaq -0x24c(%rbp), %rsi
callq 0x127e30
jmp 0xc92cb
leaq -0x260(%rbp), %rdi
callq 0x8e610
leaq -0x270(%rbp), %rdi
callq 0xca410
leaq -0x1c8(%rbp), %rdi
callq 0xca430
jmp 0xc9408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x8e610
leaq -0x270(%rbp), %rdi
callq 0xca410
leaq -0x1c8(%rbp), %rdi
callq 0xca430
jmp 0xc9418
movb $0x1, -0x2b1(%rbp)
movl $0xa8, %edi
callq 0x112b0
movq %rax, -0x360(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x2b0(%rbp), %rdi
callq 0x89eb0
jmp 0xc9353
leaq 0x89fc7(%rip), %rsi     # 0x153321
leaq -0x290(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
callq 0x24f40
jmp 0xc936f
movq -0x360(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x290(%rbp), %rsi
callq 0x9c360
jmp 0xc938c
movq -0x360(%rbp), %rdi
movb $0x0, -0x2b1(%rbp)
leaq 0x1178df(%rip), %rsi    # 0x1e0c80
leaq -0x6ea08(%rip), %rdx    # 0x5a9a0
callq 0x11970
jmp 0xc9421
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc93ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc93e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x11360
leaq -0x2b0(%rbp), %rdi
callq 0x11360
testb $0x1, -0x2b1(%rbp)
jne 0xc93fa
jmp 0xc9406
movq -0x360(%rbp), %rdi
callq 0x11420
jmp 0xc9418
movq -0x2c8(%rbp), %rax
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x119c0
nopw %cs:(%rax,%rax)