// File: /workspace/github_c_makefile_star2_O2/mirth-lang[P]mirth/bin/mirth1.c
// Function: mw_mirth_mirth_zaMirth_resolvezeowner
static struct mirth_table_StateOwner mw_mirth_mirth_zaMirth_resolvezeowner (struct mirth_mirth_zaMirth* in_zaMirth_1, struct std_maybe_Maybe_1 in_Maybe_2, struct mirth_mirth_zaMirth* *out_zaMirth_3) {
	struct mirth_mirth_zaMirth* branch_zaMirth_5;
	struct mirth_table_StateOwner branch_StateOwner_6;
	switch ((in_Maybe_2).tag) {
		case std_maybe_Maybe_1_None: {
			struct mirth_table_StateOwner v7 = { .tag=mirth_table_StateOwner_Default };
			branch_StateOwner_6 = v7;
			branch_zaMirth_5 = in_zaMirth_1;
		} break;
		case std_maybe_Maybe_1_Some: {
			VAL v8 = mtp_std_maybe_Maybe_1_Some(in_Maybe_2);
			struct mirth_elab_zaTypeElab* v9;
			mw_mirth_elab_zaTypeElab_Startzx(V_mirth_token_Token(v8), &v9);
			uint64_t v10 = v9->mtoken;
			struct mirth_mirth_zaMirth* v11;
			struct std_maybe_Maybe_1 v12 = mw_mirth_token_Token_sigzeresourcezeconzy(in_zaMirth_1, v10, &v11);
			struct mirth_mirth_zaMirth* branch_zaMirth_13;
			struct mirth_elab_zaTypeElab* branch_zaTypeElab_14;
			struct mirth_table_StateOwner branch_StateOwner_15;
			switch ((v12).tag) {
				case std_maybe_Maybe_1_Some: {
					VAL v16 = mtp_std_maybe_Maybe_1_Some(v12);
					struct mirth_mirth_zaMirth* v17;
					struct mirth_elab_zaTypeElab* v18;
					struct mirth_type_Type v19 = mw_mirth_elab_zaTypeElab_elabzeresourcezeconzx(v11, v9, V_std_either_Either_2(v16), &v17, &v18);
					incref(MK_mirth_type_Type(v19));
					struct mirth_mirth_zaMirth* v20;
					bool v21 = mw_mirth_type_Resource_canzeownzestatezy(v17, v19, &v20);
					struct mirth_mirth_zaMirth* branch_zaMirth_22;
					struct mirth_elab_zaTypeElab* branch_zaTypeElab_23;
					struct mirth_table_StateOwner branch_StateOwner_24;
					if (v21) {
						struct std_list_List_1 v25 = v18->mctx;
						incref(MK_std_list_List_1(v25));
						struct mirth_table_StateOwner v26 = mtw_mirth_table_StateOwner_Resource(v25, v19);
						branch_StateOwner_24 = v26;
						branch_zaTypeElab_23 = v18;
						branch_zaMirth_22 = v20;
					} else {
						uint64_t v27 = v18->mtoken;
						STR* v28;
						STRLIT(v28, "Resource cannot own state.", 26);
						struct mirth_mirth_zaMirth* v29;
						mw_mirth_mirth_zaMirth_emitzeerrorzx(v20, v27, v28, &v29);
						decref(MK_mirth_type_Type(v19));
						struct mirth_table_StateOwner v30 = { .tag=mirth_table_StateOwner_Error };
						branch_StateOwner_24 = v30;
						branch_zaTypeElab_23 = v18;
						branch_zaMirth_22 = v29;
					}
					branch_StateOwner_15 = branch_StateOwner_24;
					branch_zaTypeElab_14 = branch_zaTypeElab_23;
					branch_zaMirth_13 = branch_zaMirth_22;
				} break;
				case std_maybe_Maybe_1_None: {
					uint64_t v31 = v9->mtoken;
					STR* v32;
					STRLIT(v32, "Expected a resource name.", 25);
					struct mirth_mirth_zaMirth* v33;
					mw_mirth_mirth_zaMirth_emitzeerrorzx(v11, v31, v32, &v33);
					struct mirth_table_StateOwner v34 = { .tag=mirth_table_StateOwner_Error };
					branch_StateOwner_15 = v34;
					branch_zaTypeElab_14 = v9;
					branch_zaMirth_13 = v33;
				} break;
				default: {
					do_panic(str_make("unexpected fallthrough in match\n", 32));
				}
			}
			mw_mirth_elab_zaTypeElab_rdrop(branch_zaTypeElab_14);
			branch_StateOwner_6 = branch_StateOwner_15;
			branch_zaMirth_5 = branch_zaMirth_13;
		} break;
		default: {
			do_panic(str_make("unexpected fallthrough in match\n", 32));
		}
	}
	*out_zaMirth_3 = branch_zaMirth_5;
	return branch_StateOwner_6;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
movq %rdi, %r12
testl %esi, %esi
je 0x66530
cmpl $0x1, %esi
jne 0x666c7
movabsq $0xfffffffffffc, %r15   # imm = 0xFFFFFFFFFFFC
movq %rdx, %rdi
callq 0xd491
leaq -0x80(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x31750
movq (%r14), %r13
movq 0x10(%r13), %rsi
leaq -0x58(%rbp), %rdx
movq %r12, %rdi
callq 0x3c460
cmpl $0x1, %eax
jne 0x6653c
movq %rdx, %rdi
callq 0xd491
movq -0x58(%rbp), %rdi
movq %rax, %rdx
shrq $0x30, %rdx
andq %r15, %rax
leaq -0x70(%rbp), %r8
leaq -0x40(%rbp), %r9
movq %r13, %rsi
movq %rax, %rcx
callq 0x3c542
movl %eax, %r14d
movq %rdx, %rcx
andq %r15, %rcx
setne %al
testb $0x3, %dl
sete %r13b
andb %al, %r13b
cmpb $0x1, %r13b
jne 0x6644a
incl (%rcx)
movq %rcx, -0x38(%rbp)
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rcx
movl %r14d, %esi
movq %rdx, -0x48(%rbp)
callq 0x666fd
testl %eax, %eax
movq %r14, -0x50(%rbp)
je 0x66593
cmpl $0x1, %eax
jne 0x666c7
movq %rdx, %rdi
callq 0xd491
movq -0x60(%rbp), %r12
movq %rax, %rcx
shrq $0x30, %rcx
andq %r15, %rax
cmpq $0x2, %rcx
je 0x665a6
cmpl $0x1, %ecx
je 0x6659c
testl %ecx, %ecx
jne 0x666c7
movq %rax, %rdi
callq 0x17c94
movq %rax, %r14
leaq -0x30(%rbp), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x1e4f2
testb %al, %al
je 0x66621
movq -0x30(%rbp), %rdi
leaq -0x78(%rbp), %rdx
movq %r14, %rsi
callq 0x66726
movl %eax, %r14d
movq %rdx, %rax
andq %r15, %rax
sete %cl
testb $0x3, %dl
setne %sil
orb %cl, %sil
jne 0x6650c
decl (%rax)
jne 0x6650c
movq %r14, %rdi
shlq $0x30, %rdi
orq %rdx, %rdi
leaq 0xa1dba(%rip), %rsi     # 0x1082c1
callq 0xce94
movq %r14, %rdi
callq 0xd86d
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0xd759
movq -0x78(%rbp), %r12
testb %al, %al
je 0x665b6
jmp 0x66625
pushq $0x1
popq %r15
xorl %r14d, %r14d
jmp 0x666af
movq 0x10(%r13), %r14
movq 0x10a6bc9(%rip), %rdx   # 0x110d110
testq %rdx, %rdx
jne 0x66565
leaq 0x7527a(%rip), %rdi     # 0xdb7cd
pushq $0x19
popq %rsi
callq 0x8a21
movq %rax, %rdx
movq %rax, 0x10a6bab(%rip)   # 0x110d110
andq %rdx, %r15
sete %al
testb $0x3, %dl
setne %cl
orb %al, %cl
jne 0x66578
incl (%r15)
movq -0x58(%rbp), %rdi
leaq -0x30(%rbp), %r15
movq %r14, %rsi
movq %r15, %rcx
callq 0x2ceb4
movq (%r15), %r12
jmp 0x666a1
movq -0x60(%rbp), %r12
jmp 0x66625
movq %rax, %rdi
callq 0x17cb1
jmp 0x66625
movq %rax, %rdi
callq 0x17cce
andl $-0x2, %eax
cmpl $0x14, %eax
jne 0x66625
movq -0x40(%rbp), %r13
movl (%r13), %eax
movl %eax, -0x38(%rbp)
movq 0x8(%r13), %rcx
andq %rcx, %r15
sete %al
movq %rcx, -0x68(%rbp)
testb $0x3, %cl
setne %cl
orb %al, %cl
jne 0x665dc
incl (%r15)
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x50c0
testq %rax, %rax
je 0x666de
movq %rax, %r14
movl $0x1, (%rax)
movq -0x50(%rbp), %rax
movl %eax, 0x18(%r14)
movq -0x48(%rbp), %rax
movq %rax, 0x20(%r14)
movl -0x38(%rbp), %eax
movl %eax, 0x8(%r14)
movq -0x68(%rbp), %rax
movq %rax, 0x10(%r14)
pushq $0x2
popq %r15
jmp 0x666a7
movq -0x30(%rbp), %r12
movq -0x40(%rbp), %rax
movq 0x10(%rax), %r14
movq 0x10a6ad4(%rip), %rdx   # 0x110d108
testq %rdx, %rdx
jne 0x66652
leaq 0x75172(%rip), %rdi     # 0xdb7b2
pushq $0x1a
popq %rsi
callq 0x8a21
movq %rax, %rdx
movq %rax, 0x10a6ab6(%rip)   # 0x110d108
andq %rdx, %r15
sete %al
testb $0x3, %dl
setne %cl
orb %al, %cl
jne 0x66665
incl (%r15)
leaq -0x30(%rbp), %rcx
movq %r12, %rdi
movq %r14, %rsi
callq 0x2ceb4
testb %r13b, %r13b
je 0x66699
movq -0x38(%rbp), %rax
decl (%rax)
jne 0x66699
movq -0x50(%rbp), %rdi
shlq $0x30, %rdi
orq -0x48(%rbp), %rdi
leaq 0xa2455(%rip), %rsi     # 0x108ae9
callq 0xce94
movq -0x40(%rbp), %r13
movq -0x30(%rbp), %r12
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %r13, %rdi
callq 0x31b94
movq %r12, (%rbx)
movl %r15d, %eax
movq %r14, %rdx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6e13f(%rip), %rdi     # 0xd480d
pushq $0x20
popq %rsi
callq 0x8a21
movq %rax, %rdi
callq 0x8cc6
leaq 0x75102(%rip), %rsi     # 0xdb7e7
pushq $0x2
popq %rdi
pushq $0x31
popq %rdx
callq 0x5060
callq 0x52ae
pushq $0x1
popq %rdi
callq 0x5130