// File: /workspace/github_c_makefile_star2_O0/qpfiffer[P]lair/src/lair_std.c
// Function: lair_builtin_str
const struct _lair_type *_lair_builtin_str(LAIR_FUNCTION_SIG) {
	printf("ARGC IS %i", argc);
	check(r, argc == 1, ERR_RUNTIME, "Incorrect number of arguments to 'str' function.");

	struct _lair_type *new_string = calloc(1, sizeof(struct _lair_type));
	new_string->type = LR_STRING;

	if (argv[0] == NULL) {
		char buf[] = "(null)";
		char *ptr = calloc(1, sizeof(buf));
		memcpy(ptr, buf, sizeof(buf));
		new_string->value.str = ptr;
	} else {
		char *friendly = _friendly_enum(argv[0]->type);
		char buf[512] = {0};
		char *ptr = NULL;
		size_t siz = 0;

		switch (argv[0]->type) {
		case LR_STRING:
			siz = strlen(argv[0]->value.str);
			ptr = calloc(1, siz);
			memcpy(ptr, argv[0]->value.str, siz);
			new_string->value.str = ptr;
			break;
		case LR_NUM:
			snprintf(buf, sizeof(buf), "%i", argv[0]->value.num);

			siz = strlen(buf);
			ptr = calloc(1, siz);
			memcpy(ptr, buf, siz);
			new_string->value.str = ptr;
			break;
		case LR_FUNCTION_DEF:
		case LR_FUNCTION_CALL:
			snprintf(buf, sizeof(buf), "<%s: %s>", friendly, argv[0]->value.str);

			siz = strlen(buf);
			ptr = calloc(1, siz);
			memcpy(ptr, buf, siz);
			new_string->value.str = ptr;
			break;
		default:
			snprintf(buf, sizeof(buf), "<%s: %p>", friendly, argv[0]);

			siz = strlen(buf);
			ptr = calloc(1, siz);
			memcpy(ptr, buf, siz);
			new_string->value.str = ptr;
			break;
		}
	}

	return new_string;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %esi
leaq 0x415d(%rip), %rdi      # 0x630d
movb $0x0, %al
callq 0x1080
movq -0x8(%rbp), %rdi
cmpl $0x1, -0xc(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %esi
movl $0x2, %edx
leaq 0x4145(%rip), %rcx      # 0x6318
callq 0x1830
movl $0x1, %edi
movl $0x10, %esi
callq 0x1110
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl $0xa, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2257
movl 0x40b9(%rip), %eax      # 0x62be
movl %eax, -0x27(%rbp)
movw 0x40b3(%rip), %ax       # 0x62c2
movw %ax, -0x23(%rbp)
movb 0x40ab(%rip), %al       # 0x62c4
movb %al, -0x21(%rbp)
movl $0x1, %edi
movl $0x7, %esi
callq 0x1110
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl -0x27(%rbp), %ecx
movl %ecx, (%rax)
movw -0x23(%rbp), %cx
movw %cx, 0x4(%rax)
movb -0x21(%rbp), %cl
movb %cl, 0x6(%rax)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x24a3
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl (%rax), %edi
callq 0x3d10
movq %rax, -0x38(%rbp)
leaq -0x240(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x10b0
movq $0x0, -0x248(%rbp)
movq $0x0, -0x250(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x254(%rbp)
decl %eax
subl $0x2, %eax
jb 0x23a9
jmp 0x22ae
movl -0x254(%rbp), %eax
subl $0xa, %eax
je 0x22cb
jmp 0x22bb
movl -0x254(%rbp), %eax
subl $0xf, %eax
je 0x232c
jmp 0x2428
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
callq 0x1060
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rsi
movl $0x1, %edi
callq 0x1110
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq -0x250(%rbp), %rdx
callq 0x1140
movq -0x248(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x24a1
leaq -0x240(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
movl $0x200, %esi            # imm = 0x200
leaq 0x3fcc(%rip), %rdx      # 0x6315
movb $0x0, %al
callq 0x1090
leaq -0x240(%rbp), %rdi
callq 0x1060
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rsi
movl $0x1, %edi
callq 0x1110
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movq -0x250(%rbp), %rdx
callq 0x1140
movq -0x248(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x24a1
leaq -0x240(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %r8
movl $0x200, %esi            # imm = 0x200
leaq 0x3f7e(%rip), %rdx      # 0x6349
movb $0x0, %al
callq 0x1090
leaq -0x240(%rbp), %rdi
callq 0x1060
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rsi
movl $0x1, %edi
callq 0x1110
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movq -0x250(%rbp), %rdx
callq 0x1140
movq -0x248(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x24a1
leaq -0x240(%rbp), %rdi
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %r8
movl $0x200, %esi            # imm = 0x200
leaq 0x3e89(%rip), %rdx      # 0x62cf
movb $0x0, %al
callq 0x1090
leaq -0x240(%rbp), %rdi
callq 0x1060
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rsi
movl $0x1, %edi
callq 0x1110
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movq -0x250(%rbp), %rdx
callq 0x1140
movq -0x248(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x24a3
movq -0x20(%rbp), %rax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq