// File: /workspace/github_c_makefile_star2_O0/Ihsoh[P]ilang/compiler/frontend/irgen_llvmir.c
// Function: new_string
static int _new_string(
	IRGeneratorLlvmirContext *ctx,
	ResizableString *name,
	const char *str,
	size_t len
) {
	assert(ctx);
	assert(str);

	// @.str.1 = private unnamed_addr constant [9 x i8] c"Person02\00", align 1

	size_t no = _next_no(ctx);

	if (name != NULL) {
		rstr_appendf(name, "@.str.%zu", no);
	}
	
	ResizableString unescaped_str;
	rstr_init(&unescaped_str);

	fe_lexer_unescape_string(
		ctx->psrctx->lexctx,
		&unescaped_str,
		str, len
	);
	int unescaped_str_len = RSTR_LEN(&unescaped_str);

	rstr_appendf(
		ctx->head,
		"@.str.%zu = private unnamed_addr constant [%d x i8] c\"",
		no, unescaped_str_len + 1
	);

	for (int i = 0; i < unescaped_str_len; i++) {
		char chr = RSTR_CHAR(&unescaped_str, i);
		if (isprint(chr)) {
			rstr_append_with_char(ctx->head, chr);
		} else {
			rstr_appendf(ctx->head, "\\%02X", chr);
		}
	}

	rstr_append_with_cstr(ctx->head, "\\00\", align 1\n");

	rstr_free(&unescaped_str);

	return unescaped_str_len + 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x2d261
jmp 0x2d280
leaq 0x4f2ee(%rip), %rdi     # 0x7c556
leaq 0x4ae61(%rip), %rsi     # 0x780d0
movl $0x11c, %edx            # imm = 0x11C
leaq 0x4b3e8(%rip), %rcx     # 0x78663
callq 0x30a0
cmpq $0x0, -0x18(%rbp)
je 0x2d289
jmp 0x2d2a8
leaq 0x458e9(%rip), %rdi     # 0x72b79
leaq 0x4ae39(%rip), %rsi     # 0x780d0
movl $0x11d, %edx            # imm = 0x11D
leaq 0x4b3c0(%rip), %rcx     # 0x78663
callq 0x30a0
movq -0x8(%rbp), %rdi
callq 0x2d400
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x2d2d2
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x4b3ed(%rip), %rsi     # 0x786b8
movb $0x0, %al
callq 0x94d0
leaq -0x38(%rbp), %rdi
callq 0x8c90
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0x38(%rbp), %rsi
callq 0x3ccd0
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rdx
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
leaq 0x4b3ad(%rip), %rsi     # 0x786c2
movb $0x0, %al
callq 0x94d0
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x2d3cc
movl -0x40(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x2d341
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x48(%rbp)
jmp 0x2d36c
cmpq $0x0, -0x30(%rbp)
jne 0x2d355
leaq 0x4a566(%rip), %rax     # 0x778b5
movq %rax, -0x50(%rbp)
jmp 0x2d35d
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movb %al, -0x41(%rbp)
callq 0x3190
movq (%rax), %rax
movsbl -0x41(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x2d3a2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movsbl -0x41(%rbp), %esi
callq 0x8ea0
jmp 0x2d3bc
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movsbl -0x41(%rbp), %edx
leaq 0x4b344(%rip), %rsi     # 0x786f9
movb $0x0, %al
callq 0x94d0
jmp 0x2d3be
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x2d323
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x4b324(%rip), %rsi     # 0x786ff
callq 0x8d70
leaq -0x38(%rbp), %rdi
callq 0x9310
movl -0x3c(%rbp), %eax
addl $0x1, %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)