// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, %r13
movq %rdi, %r15
testl %esi, %esi
je 0x6ddd7
movq %r13, -0x30(%rbp)
cmpl $0x1, %esi
jne 0x6dff6
movabsq $0xfffffffffffc, %r13   # imm = 0xFFFFFFFFFFFC
movq %rdx, %rdi
callq 0xdaeb
leaq -0x38(%rbp), %rbx
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
movq %rbx, %r9
callq 0x359f1
movq (%rbx), %r14
movq 0x10(%r14), %rsi
leaq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x40c7e
cmpl $0x1, %eax
jne 0x6dde4
movq %rdx, %rdi
callq 0xdaeb
movq -0x60(%rbp), %rdi
movq %rax, %rdx
shrq $0x30, %rdx
andq %r13, %rax
leaq -0x40(%rbp), %r9
movq %r14, %rsi
movq %rax, %rcx
movq %rbx, %r8
callq 0x3fd43
movl %eax, %esi
movq (%rbx), %rdi
movq %rdx, %rax
andq %r13, %rax
sete %cl
testb $0x3, %dl
setne %r8b
orb %cl, %r8b
jne 0x6dce7
incl (%rax)
movq -0x40(%rbp), %r14
movq %rsi, -0x50(%rbp)
movq %rdx, -0x58(%rbp)
movq %rbx, %rcx
callq 0x2dc76
movq (%rbx), %r15
testl %eax, %eax
je 0x6de81
cmpl $0x1, %eax
jne 0x6dff6
movq %rdx, %rdi
callq 0xdaeb
movq %rax, %rcx
shrq $0x30, %rcx
andq %r13, %rax
cmpq $0x2, %rcx
je 0x6dfd9
cmpl $0x1, %ecx
je 0x6de75
testl %ecx, %ecx
jne 0x6dff6
movq 0x8(%rax), %rbx
decl (%rax)
jne 0x6dd4c
movq %rax, %rdi
callq 0x5030
leaq -0x40(%rbp), %r12
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x20d1b
movq (%r12), %r15
testb %al, %al
je 0x6de81
leaq -0x38(%rbp), %r12
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x52d67
movl %eax, %edi
movq %rdx, %rsi
callq 0xf770
movq (%r12), %r15
movl %eax, %ebx
movq %rdx, %rax
andq %r13, %rax
sete %cl
testb $0x3, %dl
setne %sil
orb %cl, %sil
jne 0x6ddbb
decl (%rax)
jne 0x6ddbb
movq %rbx, %rdi
shlq $0x30, %rdi
orq %rdx, %rdi
leaq 0xa750b(%rip), %rsi     # 0x1152c1
callq 0xd4e3
leaq 0x1(,%rbx,2), %rdi
movl $0x1, %esi
callq 0xec04
testl %eax, %eax
setne %al
jmp 0x6de83
movl $0x1, %r12d
xorl %ebx, %ebx
jmp 0x6def6
movq 0x10(%r14), %rbx
cmpq $0x0, 0x10ac320(%rip)   # 0x111a110
jne 0x6de21
movl $0x19, %edi
callq 0xf9f7
movq $0x19, 0x10(%rax)
movups 0x7d900(%rip), %xmm0    # 0xeb70b
movups %xmm0, 0x18(%rax)
movups 0x7d8fe(%rip), %xmm0    # 0xeb714
movups %xmm0, 0x21(%rax)
movq %rax, 0x10ac2ef(%rip)   # 0x111a110
movq 0x10ac2e8(%rip), %r15   # 0x111a110
andq %r15, %r13
sete %al
testb $0x3, %r15b
setne %cl
orb %al, %cl
jne 0x6de3d
incl (%r13)
movq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %r12
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1b861
movq (%r12), %rdi
leaq -0x38(%rbp), %rbx
movq %rax, %rsi
movq %r15, %rdx
movl $0x2, %ecx
movq %rbx, %r8
callq 0x1bf3a
movq (%rbx), %r15
xorl %r12d, %r12d
xorl %ebx, %ebx
jmp 0x6deea
decl (%rax)
jne 0x6de81
movq %rax, %rdi
callq 0x5030
xorl %eax, %eax
testb %al, %al
je 0x6df0f
movl (%r14), %eax
movl %eax, -0x44(%rbp)
movq 0x8(%r14), %r12
andq %r12, %r13
sete %al
testb $0x3, %r12b
setne %cl
orb %al, %cl
jne 0x6deaa
incl (%r13)
movl $0x1, %edi
movl $0x28, %esi
callq 0x50c0
testq %rax, %rax
je 0x6e026
movq %rax, %rbx
movl $0x1, (%rax)
movq -0x50(%rbp), %rax
movl %eax, 0x18(%rbx)
movq -0x58(%rbp), %rax
movq %rax, 0x20(%rbx)
movl -0x44(%rbp), %eax
movl %eax, 0x8(%rbx)
movq %r12, 0x10(%rbx)
movl $0x2, %r12d
movq -0x30(%rbp), %r13
movq %r14, %rdi
callq 0x3591c
movq %r15, (%r13)
movl %r12d, %eax
movq %rbx, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %rsi
cmpq $0x0, 0x10ac1ed(%rip)   # 0x111a108
jne 0x6df52
movl $0x1a, %edi
movq %rsi, %rbx
callq 0xf9f7
movq %rbx, %rsi
movq $0x1a, 0x10(%rax)
movups 0x7d7b4(%rip), %xmm0    # 0xeb6f0
movups %xmm0, 0x18(%rax)
movups 0x7d7b3(%rip), %xmm0    # 0xeb6fa
movups %xmm0, 0x22(%rax)
movq %rax, 0x10ac1b6(%rip)   # 0x111a108
movq 0x10ac1af(%rip), %r12   # 0x111a108
movq %r12, %rax
andq %r13, %rax
sete %cl
testb $0x3, %r12b
setne %dl
orb %cl, %dl
jne 0x6df6f
incl (%rax)
leaq -0x40(%rbp), %rbx
movq %r15, %rdi
movq %rbx, %rdx
callq 0x1b861
movq (%rbx), %rdi
leaq -0x38(%rbp), %rbx
movq %rax, %rsi
movq %r12, %rdx
movl $0x2, %ecx
movq %rbx, %r8
callq 0x1bf3a
movq (%rbx), %r15
movq -0x58(%rbp), %rdx
andq %rdx, %r13
sete %al
testb $0x3, %dl
setne %cl
orb %al, %cl
jne 0x6de6e
decl (%r13)
jne 0x6de6e
movq -0x50(%rbp), %rdi
shlq $0x30, %rdi
orq %rdx, %rdi
leaq 0xa7b1a(%rip), %rsi     # 0x115ae9
callq 0xd4e3
jmp 0x6de6e
movl 0x4(%rax), %ebx
decl (%rax)
jne 0x6dfe8
movq %rax, %rdi
callq 0x5030
andl $-0x2, %ebx
cmpl $0x14, %ebx
sete %al
jmp 0x6de83
movl $0x20, %edi
callq 0xf9f7
movq $0x20, 0x10(%rax)
movups 0x7673e(%rip), %xmm0    # 0xe474d
movups %xmm0, 0x18(%rax)
movups 0x76743(%rip), %xmm0    # 0xe475d
movups %xmm0, 0x28(%rax)
movq %rax, %rdi
callq 0x95a5
leaq 0x7d6f8(%rip), %rsi     # 0xeb725
movl $0x31, %edx
movl $0x2, %edi
callq 0x5060
callq 0x52be
movl $0x1, %edi
callq 0x5130