// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/inline.c
// Function: inline_function
int inline_function(struct expression *expr, struct symbol *sym)
{
	struct symbol_list * fn_symbol_list;
	struct symbol *fn = sym->ctype.base_type;
	struct statement *stmt;
	struct symbol_list *arg_decl;
	struct symbol *name;
	struct expression *arg;

	if (!fn->inline_stmt) {
		sparse_error(fn->pos, "marked inline, but without a definition");
		return 0;
	}
	if (fn->expanding)
		return 0;

	stmt = alloc_statement(expr->pos, STMT_COMPOUND);
	expr->type = EXPR_STATEMENT;
	expr->statement = stmt;
	expr->ctype = fn->ctype.base_type;

	fn_symbol_list = create_symbol_list(sym->inline_symbol_list);

	arg_decl = NULL;
	PREPARE_PTR_LIST(fn->arguments, name);
	FOR_EACH_PTR(expr->args, arg) {
		struct symbol *a = alloc_symbol(arg->pos, SYM_NODE);

		if (name) {
			*a = *name;
			set_replace(name, a);
			add_symbol(&fn_symbol_list, a);
			a->initializer = arg;
			add_symbol(&arg_decl, a);
		} else {
			// This may create a node of a node but it will
			// be resolved later when the corresponding
			// STMT_DECLARATION will be evaluated.
			a->ctype.base_type = arg->ctype;
		}

		NEXT_PTR_LIST(name);
	} END_FOR_EACH_PTR(arg);
	FINISH_PTR_LIST(name);

	copy_statement(fn->inline_stmt, stmt);

	if (arg_decl) {
		struct statement *decl = alloc_statement(expr->pos, STMT_DECLARATION);
		decl->declaration = arg_decl;
		stmt->args = decl;
	}
	stmt->inline_fn = sym;

	unset_replace_list(fn_symbol_list);
	free_ptr_list(&fn_symbol_list);

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
jne 0x1509f
movq -0x28(%rbp), %rax
movq 0x4(%rax), %rdi
leaq 0x4d334(%rip), %rsi     # 0x623c0
movb $0x0, %al
callq 0x16f90
movl $0x0, -0x4(%rbp)
jmp 0x153b7
movq -0x28(%rbp), %rax
movl 0x54(%rax), %eax
shrl $0xc, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x150bd
movl $0x0, -0x4(%rbp)
jmp 0x153b7
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x3, %esi
callq 0x23020
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl $0x13, %ecx
movl %ecx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0x153d0
movq %rax, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x151a7
jmp 0x1514b
movl -0x5c(%rbp), %eax
movq -0x58(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x15184
movq -0x58(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
andq $-0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x151a5
movq $0x0, -0x40(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq -0x50(%rbp), %rax
jne 0x1514b
jmp 0x151a7
jmp 0x151a9
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x151d1
jmp 0x1533e
jmp 0x151d3
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x70(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x15326
movq -0x70(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x70(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x15225
cmpq $0x0, -0x48(%rbp)
jne 0x15225
jmp 0x15318
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x3, %esi
callq 0x3f4d0
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x1529e
movq -0x88(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl $0xe0, %edx
callq 0x111d0
movq -0x40(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x154a0
movq -0x88(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x15020
movq -0x48(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x88(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x15020
jmp 0x152b1
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x60(%rax)
cmpq $0x0, -0x40(%rbp)
je 0x15316
jmp 0x152ba
movl -0x5c(%rbp), %eax
movq -0x58(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x152f3
movq -0x58(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
andq $-0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x15314
movq $0x0, -0x40(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq -0x50(%rbp), %rax
jne 0x152ba
jmp 0x15316
jmp 0x15318
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x151da
jmp 0x15328
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq -0x68(%rbp), %rax
jne 0x151d3
jmp 0x15340
movq -0x28(%rbp), %rax
movq 0xa0(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x154d0
cmpq $0x0, -0x38(%rbp)
je 0x15392
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x23020
movq %rax, -0x90(%rbp)
movq -0x38(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rdi
callq 0x155f0
leaq -0x20(%rbp), %rdi
callq 0x31cd0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)