// File: /workspace/github_c_makefile_star2_O2/hsjoihs[P]c-compiler/typecheck_expression.c
// Function: from_name_to_expr
static struct Expr * /* nullable */
from_name_to_expr(struct AnalyzerState *ptr_ps, const char *name)
{
	if (strcmp(name, "__func__") == 0) {
		struct Expr *p_expr = calloc(1, sizeof(struct Expr));
		*p_expr = string_literal(ptr_ps->current_function_name);
		return p_expr;
	}
	if (!is_local_var(&ptr_ps->scope_chain, name)) {
		const struct EnumeratorAndValue *ptr_enum_and_value =
		    get_global_enumerator(&ptr_ps->global_enumerator_list, name);
		if (ptr_enum_and_value) {
			struct Expr expr;
			expr.details.type = INT_TYPE();
			expr.details.true_type = INT_TYPE();
			expr.category = INT_VALUE;
			expr.int_value = ptr_enum_and_value->value;

			struct Expr *p_expr = calloc(1, sizeof(struct Expr));
			*p_expr = expr;
			return p_expr;
		}

		struct Type type;

		if (isElem(ptr_ps->global_vars_type_map, name)) {
			struct Type *ptr_type = lookup(ptr_ps->global_vars_type_map, name);
			type = *ptr_type;
		} else if (isElem(ptr_ps->func_info_map, name)) {
			struct Type *ptr_type = lookup(ptr_ps->func_info_map, name);
			type = *ptr_type;
		} else {
			return 0;
		}

		struct Expr expr;
		struct Type t2 = type;
		if_array_convert_to_ptr_(&t2);

		expr.details.type = t2;
		expr.details.true_type = type;
		expr.category = GLOBAL_VAR_;
		expr.global_var_name = name;

		struct Expr *p_expr = calloc(1, sizeof(struct Expr));
		*p_expr = expr;
		return p_expr;
	} else {
		struct LocalVarInfo info =
		    resolve_name_locally(&ptr_ps->scope_chain, name);

		struct Expr expr;
		struct Type t2 = info.type;
		if_array_convert_to_ptr_(&t2);

		expr.details.type = t2;
		expr.details.true_type = info.type;
		expr.category = LOCAL_VAR_;
		expr.local_var_offset = info.offset;

		struct Expr *p_expr = calloc(1, sizeof(struct Expr));
		*p_expr = expr;
		return p_expr;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x8e8d(%rip), %rsi      # 0xee7a
movq %rbx, %rdi
callq 0x10e0
testl %eax, %eax
je 0x60e2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4be2
testl %eax, %eax
je 0x611d
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x9304
testl %eax, %eax
jne 0x604b
movq 0x8(%r14), %r14
testq %r14, %r14
jne 0x6010
movq 0xffc9(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0x8e4a(%rip), %rsi      # 0xee83
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10f0
pushq $0x1
popq %rdi
callq 0x1170
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x92a8
pushq $0xa
popq %rbx
leaq -0x78(%rbp), %r14
movq %rbx, %rcx
movq %r14, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl 0x50(%rax), %r13d
leaq -0x1c8(%rbp), %r15
movq %rbx, %rcx
movq %r15, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
callq 0x861c
leaq -0x178(%rbp), %r12
movq %rbx, %rcx
movq %r12, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x128(%rbp), %rdi
movq %rbx, %rcx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
pushq $0x1
popq %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x10d0
movq %rax, %r15
movl $0xa0, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1100
movl $0x7, 0xa0(%r15)
movl %r13d, 0xf0(%r15)
jmp 0x6257
pushq $0x1
popq %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x10d0
movq %rax, %r15
movq 0x98(%r14), %rsi
leaq -0x178(%rbp), %rbx
movq %rbx, %rdi
callq 0x6271
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1100
jmp 0x6257
leaq 0x88(%r14), %rdi
movq %rbx, %rsi
callq 0x4c1c
testq %rax, %rax
je 0x619a
movq %rax, %r15
leaq -0x178(%rbp), %rbx
movq %rbx, %rdi
callq 0x81b0
leaq -0x78(%rbp), %r14
movq %r14, %rdi
callq 0x81b0
leaq -0x128(%rbp), %rdi
pushq $0xa
popq %rcx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl 0x8(%r15), %r14d
pushq $0x1
popq %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x10d0
movq %rax, %r15
movl $0xa0, %edx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1100
movl $0x9, 0xa0(%r15)
movl %r14d, 0xc8(%r15)
jmp 0x6257
movq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x9304
testl %eax, %eax
je 0x61b0
addq $0x10, %r14
jmp 0x61c8
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0x9304
testl %eax, %eax
je 0x626c
addq $0x18, %r14
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x92a8
pushq $0xa
popq %r14
leaq -0x78(%rbp), %r15
movq %r14, %rcx
movq %r15, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x1c8(%rbp), %r12
movq %r14, %rcx
movq %r12, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
callq 0x861c
leaq -0x178(%rbp), %r13
movq %r14, %rcx
movq %r13, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x128(%rbp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
pushq $0x1
popq %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x10d0
movq %rax, %r15
movl $0xa0, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x1100
movl $0x8, 0xa0(%r15)
movq %rbx, 0xd0(%r15)
movq %r15, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x6257