// File: /workspace/github_c_makefile_star2_O2/Ihsoh[P]ilang/compiler/backend/asmgen_gas32.c
// Function: be_asmgen_gas32_new_context
ASMGeneratorGas32Context * be_asmgen_gas32_new_context(
	ParserContext *psrctx,
	FILE *out,
	int platform
) {
	assert(psrctx);
	assert(psrctx->ast);
	assert(out);
	assert(
		platform == BE_ASMGEN_PLATFORM_WINDOWS
			|| platform == BE_ASMGEN_PLATFORM_SYSTEM_V
			|| platform == BE_ASMGEN_PLATFORM_ISYSTEM
	);
	
	ASMGeneratorGas32Context *ctx = (ASMGeneratorGas32Context *)malloc(sizeof(ASMGeneratorGas32Context));
	if (ctx == NULL) {
		_error("cannot allocate memory for a new context!");
	}

	ctx->psrctx = psrctx;
	ctx->out = out;

	ctx->global = rstr_new();
	ctx->head = rstr_new();
	ctx->body = rstr_new();
	ctx->foot = rstr_new();
	ctx->local_var_defs = NULL;

	ctx->local_var_address_counter = 0;
	ctx->local_var_size = 0;

	rstr_init(ctx->global);
	rstr_init(ctx->head);
	rstr_init(ctx->body);
	rstr_init(ctx->foot);

	ctx->counter = 0;
	ctx->func_symbol = NULL;

	ctx->platform = platform;

	size_t reg_alloc_table_count = sizeof(ctx->_reg_alloc_table) / sizeof(ctx->_reg_alloc_table[0]);
	for (int i = 0; i < reg_alloc_table_count; i++) {
		ctx->_reg_alloc_table[i] = false;
	}

	return ctx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xb4ef
movq %rdi, %r12
cmpq $0x0, 0x8(%rdi)
je 0xb50e
movq %rsi, %r15
testq %rsi, %rsi
je 0xb52d
leal -0x1(%rdx), %eax
cmpl $0x3, %eax
jae 0xb54c
movq %rdx, -0x30(%rbp)
pushq $0x68
popq %rdi
callq 0x3110
testq %rax, %rax
je 0xb56b
movq %rax, %r14
movq %r12, (%rax)
movq %r15, 0x8(%rax)
callq 0x71d5
movq %rax, %r15
movq %rax, 0x10(%r14)
callq 0x71d5
movq %rax, %r12
movq %rax, 0x18(%r14)
callq 0x71d5
movq %rax, %r13
movq %rax, 0x20(%r14)
callq 0x71d5
movq %rax, %rbx
movq %rax, 0x28(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r14)
andq $0x0, 0x40(%r14)
movq %r15, %rdi
callq 0x6e1c
movq %r12, %rdi
callq 0x6e1c
movq %r13, %rdi
callq 0x6e1c
movq %rbx, %rdi
callq 0x6e1c
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r14)
movq -0x30(%rbp), %rax
movl %eax, 0x60(%r14)
pushq $0x64
popq %rax
cmpq $0x68, %rax
je 0xb4dd
movb $0x0, (%r14,%rax)
incq %rax
jmp 0xb4cd
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31fb1(%rip), %rdi     # 0x3d4a7
leaq 0x31f4b(%rip), %rsi     # 0x3d448
leaq 0x31fed(%rip), %rcx     # 0x3d4f1
movl $0x2cca, %edx           # imm = 0x2CCA
callq 0x30a0
leaq 0x31f9e(%rip), %rdi     # 0x3d4b3
leaq 0x31f2c(%rip), %rsi     # 0x3d448
leaq 0x31fce(%rip), %rcx     # 0x3d4f1
movl $0x2ccb, %edx           # imm = 0x2CCB
callq 0x30a0
leaq 0x31fb9(%rip), %rdi     # 0x3d4ed
leaq 0x31f0d(%rip), %rsi     # 0x3d448
leaq 0x31faf(%rip), %rcx     # 0x3d4f1
movl $0x2ccc, %edx           # imm = 0x2CCC
callq 0x30a0
leaq 0x31ff2(%rip), %rdi     # 0x3d545
leaq 0x31eee(%rip), %rsi     # 0x3d448
leaq 0x31f90(%rip), %rcx     # 0x3d4f1
movl $0x2cd1, %edx           # imm = 0x2CD1
callq 0x30a0
movq 0x4ba86(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x35e58(%rip), %rsi     # 0x413d4
leaq 0x3203e(%rip), %rdx     # 0x3d5c1
xorl %eax, %eax
callq 0x30e0
pushq $0x1
popq %rdi
callq 0x3160