// File: CobaltXII[P]cxcc/./compiler/compiler.hpp
// Function: compiler_t::compile_function(function_t, symbol_table_t&)
void compile_function(function_t function, symbol_table_t& symbols) {
		#ifdef __APPLE__
		emit(".globl _%s\n", function.identifier.c_str());
		emit("_%s:\n", function.identifier.c_str());
		#else
		emit(".globl %s\n", function.identifier.c_str());
		emit("%s:\n", function.identifier.c_str());
		#endif

		emit("    pushq   %%rbp\n");
		emit("    movq    %%rsp, %%rbp\n");
		emit("    subq    $%ld, %%rsp\n", aligned_offset(function, symbols));
		emit("    andq    $-16, %%rsp\n");

		symbol_table_t new_symbols(&symbols);
		const char* registers[6] = {"%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9"};
		for (int i = 0; i < function.parameters.size() && i < 6; i++) {
			emit("    movq    %s, %d(%%rbp)\n", registers[i], i * -8 - 8);
			new_symbols.add_symbol(symbol_t(
				function.parameters[i].type,
				function.parameters[i].identifier,
				i * -8 - 8
			));
			new_symbols.offset -= 8;
		}
		if (function.parameters.size() > 6) {
			for (int i = 6; i < function.parameters.size(); i++) {
				new_symbols.add_symbol(symbol_t(
					function.parameters[i].type,
					function.parameters[i].identifier,
					(i - 6) * 8 + 16
				));
			}
		}
		for (int i = 0; i < function.body.size(); i++) {
			compile_statement(function.body[i], new_symbols);
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rsi, -0x240(%rbp)
movq %rdi, %rax
movq -0x240(%rbp), %rdi
movq %rdi, -0x228(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x220(%rbp)
addq $0x8, %rdi
movq %rdi, -0x238(%rbp)
callq 0x3120
movq -0x220(%rbp), %rdi
movq %rax, %rdx
leaq 0x4d56(%rip), %rsi      # 0x28a61
xorl %eax, %eax
movb %al, -0x229(%rbp)
callq 0x245e0
movq -0x238(%rbp), %rdi
callq 0x3120
movq -0x220(%rbp), %rdi
movq %rax, %rdx
movb -0x229(%rbp), %al
leaq 0x4d31(%rip), %rsi      # 0x28a6c
callq 0x245e0
movb -0x229(%rbp), %al
movq -0x220(%rbp), %rdi
leaq 0x4d1d(%rip), %rsi      # 0x28a71
callq 0x245e0
movb -0x229(%rbp), %al
movq -0x220(%rbp), %rdi
leaq 0x4d17(%rip), %rsi      # 0x28a84
callq 0x245e0
movq -0x228(%rbp), %rsi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x19420
movq -0x220(%rbp), %rdi
movq -0x218(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x24680
movq %rax, -0x210(%rbp)
jmp 0x23da9
movq -0x220(%rbp), %rdi
movq -0x210(%rbp), %rdx
leaq 0x4ce0(%rip), %rsi      # 0x28a9e
movb $0x0, %al
callq 0x245e0
leaq -0x80(%rbp), %rdi
callq 0xd890
movq -0x220(%rbp), %rdi
leaq 0x4cdb(%rip), %rsi      # 0x28ab7
movb $0x0, %al
callq 0x245e0
movq -0x18(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x191a0
leaq -0x100(%rbp), %rdi
leaq 0x10f3f(%rip), %rsi     # 0x34d40
movl $0x30, %edx
callq 0x3250
movl $0x0, -0x104(%rbp)
movq -0x228(%rbp), %rdi
movslq -0x104(%rbp), %rax
movq %rax, -0x250(%rbp)
addq $0x28, %rdi
callq 0xf6c0
movq -0x250(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x241(%rbp)
jae 0x23e5a
cmpl $0x6, -0x104(%rbp)
setl %al
movb %al, -0x241(%rbp)
movb -0x241(%rbp), %al
testb $0x1, %al
jne 0x23e69
jmp 0x23fdb
movq -0x220(%rbp), %rdi
movslq -0x104(%rbp), %rax
movl %eax, %ecx
movq -0x100(%rbp,%rax,8), %rdx
notl %ecx
shll $0x3, %ecx
leaq 0x4c5f(%rip), %rsi      # 0x28aec
xorl %eax, %eax
callq 0x245e0
movq -0x228(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x258(%rbp)
movslq -0x104(%rbp), %rsi
callq 0x1c080
movq -0x258(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x160(%rbp)
movslq -0x104(%rbp), %rsi
callq 0x1c080
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x180(%rbp), %rdi
callq 0x3130
jmp 0x23ee4
movl -0x104(%rbp), %eax
notl %eax
shll $0x3, %eax
movslq %eax, %rcx
movq -0x160(%rbp), %rsi
leaq -0x158(%rbp), %rdi
leaq -0x180(%rbp), %rdx
callq 0x24810
jmp 0x23f0e
leaq -0xd0(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x19230
jmp 0x23f23
leaq -0x158(%rbp), %rdi
callq 0x193b0
leaq -0x180(%rbp), %rdi
callq 0x31c0
movq -0xa8(%rbp), %rax
subq $0x8, %rax
movq %rax, -0xa8(%rbp)
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x23e15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xd890
jmp 0x241ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x241c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x23fca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x193b0
leaq -0x180(%rbp), %rdi
callq 0x31c0
jmp 0x241c2
movq -0x228(%rbp), %rdi
addq $0x28, %rdi
callq 0xf6c0
cmpq $0x6, %rax
jbe 0x24134
movl $0x6, -0x184(%rbp)
movq -0x228(%rbp), %rdi
movslq -0x184(%rbp), %rax
movq %rax, -0x260(%rbp)
addq $0x28, %rdi
callq 0xf6c0
movq %rax, %rcx
movq -0x260(%rbp), %rax
cmpq %rcx, %rax
jae 0x24132
movq -0x228(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x268(%rbp)
movslq -0x184(%rbp), %rsi
callq 0x1c080
movq -0x268(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x1e0(%rbp)
movslq -0x184(%rbp), %rsi
callq 0x1c080
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x200(%rbp), %rdi
callq 0x3130
jmp 0x24080
movl -0x184(%rbp), %ecx
movl %ecx, %eax
leal -0x20(,%rax,8), %eax
movslq %eax, %rcx
movq -0x1e0(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
leaq -0x200(%rbp), %rdx
callq 0x24810
jmp 0x240ae
leaq -0xd0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x19230
jmp 0x240c3
leaq -0x1d8(%rbp), %rdi
callq 0x193b0
leaq -0x200(%rbp), %rdi
callq 0x31c0
movl -0x184(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x184(%rbp)
jmp 0x23fff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x24121
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x193b0
leaq -0x200(%rbp), %rdi
callq 0x31c0
jmp 0x241c2
jmp 0x24134
movl $0x0, -0x204(%rbp)
movq -0x228(%rbp), %rdi
movslq -0x204(%rbp), %rax
movq %rax, -0x270(%rbp)
addq $0x40, %rdi
callq 0x10c30
movq %rax, %rcx
movq -0x270(%rbp), %rax
cmpq %rcx, %rax
jae 0x241ad
movq -0x228(%rbp), %rdi
addq $0x40, %rdi
movslq -0x204(%rbp), %rsi
callq 0x1c130
movq -0x220(%rbp), %rdi
movq (%rax), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x248b0
jmp 0x2419a
jmp 0x2419c
movl -0x204(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x204(%rbp)
jmp 0x2413e
leaq -0xd0(%rbp), %rdi
callq 0x19c10
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
leaq -0xd0(%rbp), %rdi
callq 0x19c10
movq -0x88(%rbp), %rdi
callq 0x34c0
nopw (%rax,%rax)