// File: /workspace/github_cpp_makefile_star2_O1/Silica[P]PSL/PSLc.cpp
// Function: compile(_IO_FILE*, char const*)
void compile(FILE *exe, const char *filename)
{
	PSLVM p;
	if (p.loadScript(filename))
		return;

	string exename = filename;
	int period = exename.rfind('.');
	if (period > 0)
		exename /= period;
	exename += EXT;
	FILE *fp = fopen(exename, "wb");
	if (!fp)
		return;
	fseek(exe, 0, SEEK_END);
	int end = ftell(exe);
	variable::buffer byte(end);
	fseek(exe, 0, SEEK_SET);
	fread(byte.get(), 1, end, exe);
	fwrite(byte.get(), 1, end, fp);
	p.writeCompiledCode(fp);
	dword l = 0xDEADC0DE;
	fwrite(&end, 1, sizeof(dword), fp);
	fwrite(&l, 1, sizeof(dword), fp);

	fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0xcdbc
leaq 0x1c2c0(%rip), %r14     # 0x286f2
movl $0x6, %edi
movq %r14, %rsi
callq 0xc180
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xc8dc
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xc87c
movl %eax, %ebp
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc46c
callq 0xfdec
testl %ebp, %ebp
jne 0xc5f4
movq %rsp, %rdi
movq %r15, %rsi
callq 0xc8dc
movq (%rsp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xc4bc
movq 0x18(%rax), %rdx
testl %edx, %edx
jle 0xc4bc
movq 0x8(%rax), %rsi
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
decq %rdx
cmpb $0x2e, (%rsi,%rdx)
je 0xc4ba
leaq -0x1(%rdx), %rdi
incq %rdx
cmpq $0x1, %rdx
movq %rdi, %rdx
jg 0xc4a2
jmp 0xc4bc
movl %edx, %ecx
testl %ecx, %ecx
jle 0xc4e1
testq %rax, %rax
je 0xc4e1
movl %ecx, %r15d
movq 0x18(%rax), %rsi
cmpq %r15, %rsi
jbe 0xc4e1
movq %rsp, %rdi
callq 0x11358
movq (%rsp), %rax
movq %r15, 0x18(%rax)
leaq 0x1bf2c(%rip), %rsi     # 0x28414
movq %rsp, %rdi
callq 0xc95c
movq (%rsp), %rax
testq %rax, %rax
je 0xc509
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rdx
movb $0x0, (%rcx,%rdx)
movq 0x8(%rax), %r14
leaq 0x1bf09(%rip), %rsi     # 0x28419
movq %r14, %rdi
callq 0xc200
testq %rax, %rax
je 0xc5e6
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xc1f0
movq %rbx, %rdi
callq 0xc030
movq %rax, %r15
movl %r15d, 0xc(%rsp)
movslq %r15d, %rsi
leaq 0x10(%rsp), %rdi
callq 0xca2a
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc1f0
movq 0x10(%rsp), %rdi
movslq %r15d, %r15
movl $0x1, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xc230
movq 0x10(%rsp), %rdi
movl $0x1, %esi
movq %r15, %rdx
movq %r14, %rcx
callq 0xc2c0
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0xca7a
movl $0xdeadc0de, %eax       # imm = 0xDEADC0DE
leaq 0x28(%rsp), %rbx
movq %rax, (%rbx)
leaq 0xc(%rsp), %rdi
movl $0x1, %esi
movl $0x8, %edx
movq %r14, %rcx
callq 0xc2c0
movl $0x1, %esi
movl $0x8, %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0xc2c0
movq %r14, %rdi
callq 0xc1b0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc5e6
callq 0xc210
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xc5f4
callq 0xfdec
leaq 0x30(%rsp), %rdi
callq 0x1300c
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc624
callq 0xc210
jmp 0xc624
jmp 0xc621
jmp 0xc63e
movq %rax, %rbx
movq (%rsp), %rdi
jmp 0xc632
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc641
callq 0xfdec
jmp 0xc641
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x1300c
movq %rbx, %rdi
callq 0xc290