// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rcx, %rbx
movq %rdi, %r15
testl %esi, %esi
je 0x6c24b
movq %rbx, -0x40(%rbp)
cmpl $0x1, %esi
jne 0x6c453
movabsq $0xfffffffffffc, %rbx   # imm = 0xFFFFFFFFFFFC
movq %rdx, %rdi
callq 0xd745
leaq -0x38(%rbp), %r14
xorl %edi, %edi
xorl %esi, %esi
movq %rax, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
movq %r14, %r9
callq 0x348b3
movq (%r14), %r14
movq 0x10(%r14), %rsi
leaq -0x60(%rbp), %rdx
movq %r15, %rdi
callq 0x3f8cb
cmpl $0x1, %eax
jne 0x6c259
movq %rdx, %rdi
callq 0xd745
movq -0x60(%rbp), %rdi
movq %rax, %rdx
shrq $0x30, %rdx
andq %rbx, %rax
leaq -0x38(%rbp), %r15
leaq -0x48(%rbp), %r9
movq %r14, %rsi
movq %rax, %rcx
movq %r15, %r8
callq 0x3e9db
movl %eax, %r12d
movq %rdx, %r13
movq (%r15), %rdi
movq %rdx, %rcx
andq %rbx, %rcx
setne %al
testb $0x3, %r13b
sete %dl
andb %al, %dl
movb %dl, -0x2c(%rbp)
cmpb $0x1, %dl
jne 0x6c14d
incl (%rcx)
movq %rcx, -0x68(%rbp)
movq -0x48(%rbp), %r14
movl %r12d, %esi
movq %r13, %rdx
movq %r15, %rcx
callq 0x2cfb8
movq (%r15), %r15
testl %eax, %eax
movq %r12, -0x58(%rbp)
movq %r13, -0x50(%rbp)
je 0x6c373
cmpl $0x1, %eax
jne 0x6c453
movq %rdx, %rdi
callq 0xd745
movq %rax, %rcx
shrq $0x30, %rcx
andq %rbx, %rax
cmpq $0x2, %rcx
je 0x6c2f5
cmpl $0x1, %ecx
je 0x6c2e3
testl %ecx, %ecx
jne 0x6c453
movq 0x8(%rax), %r12
decl (%rax)
jne 0x6c1bc
movq %rax, %rdi
callq 0x5030
leaq -0x48(%rbp), %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x207b0
movq (%r13), %r15
testb %al, %al
je 0x6c373
leaq -0x38(%rbp), %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x51551
movl %eax, %edi
movq %rdx, %rsi
callq 0xf35d
movq (%r13), %r15
movl %eax, %r12d
movq %rdx, %rax
andq %rbx, %rax
sete %cl
testb $0x3, %dl
setne %sil
orb %cl, %sil
jne 0x6c22c
decl (%rax)
jne 0x6c22c
movq %r12, %rdi
shlq $0x30, %rdi
orq %rdx, %rdi
leaq 0xa509a(%rip), %rsi     # 0x1112c1
callq 0xd13d
leaq 0x1(,%r12,2), %rdi
movl $0x1, %esi
callq 0xe83a
testl %eax, %eax
jne 0x6c30f
jmp 0x6c373
movl $0x1, %r12d
xorl %r13d, %r13d
jmp 0x6c43b
movq 0x10(%r14), %r12
movq 0x10a9eac(%rip), %r15   # 0x1116110
testq %r15, %r15
jne 0x6c29b
movl $0x19, %edi
callq 0xf5e4
movq %rax, %r15
movq $0x19, 0x10(%rax)
movups 0x7b355(%rip), %xmm0    # 0xe75da
movups %xmm0, 0x18(%rax)
movups 0x7b353(%rip), %xmm0    # 0xe75e3
movups %xmm0, 0x21(%rax)
movq %rax, 0x10a9e75(%rip)   # 0x1116110
andq %r15, %rbx
sete %al
testb $0x3, %r15b
setne %cl
orb %al, %cl
jne 0x6c2ae
incl (%rbx)
movq -0x60(%rbp), %rdi
leaq -0x48(%rbp), %rbx
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1b59d
movq (%rbx), %rdi
leaq -0x38(%rbp), %rbx
movq %rax, %rsi
movq %r15, %rdx
movl $0x2, %ecx
movq %rbx, %r8
callq 0x1bc32
movq (%rbx), %r15
jmp 0x6c429
decl (%rax)
jne 0x6c373
movq %rax, %rdi
callq 0x5030
jmp 0x6c373
movl 0x4(%rax), %r12d
decl (%rax)
jne 0x6c305
movq %rax, %rdi
callq 0x5030
andl $-0x2, %r12d
cmpl $0x14, %r12d
jne 0x6c373
movl (%r14), %eax
movl %eax, -0x2c(%rbp)
movq 0x8(%r14), %r12
andq %r12, %rbx
sete %al
testb $0x3, %r12b
setne %cl
orb %al, %cl
jne 0x6c32c
incl (%rbx)
movl $0x1, %edi
movl $0x28, %esi
callq 0x50c0
testq %rax, %rax
je 0x6c483
movq %rax, %r13
movl $0x1, (%rax)
movq -0x58(%rbp), %rax
movl %eax, 0x18(%r13)
movq -0x50(%rbp), %rax
movq %rax, 0x20(%r13)
movl -0x2c(%rbp), %eax
movl %eax, 0x8(%r13)
movq %r12, 0x10(%r13)
movl $0x2, %r12d
jmp 0x6c42f
movq 0x10(%r14), %r12
movq 0x10a9d8a(%rip), %r13   # 0x1116108
testq %r13, %r13
jne 0x6c3b5
movl $0x1a, %edi
callq 0xf5e4
movq %rax, %r13
movq $0x1a, 0x10(%rax)
movups 0x7b220(%rip), %xmm0    # 0xe75bf
movups %xmm0, 0x18(%rax)
movups 0x7b21f(%rip), %xmm0    # 0xe75c9
movups %xmm0, 0x22(%rax)
movq %rax, 0x10a9d53(%rip)   # 0x1116108
andq %r13, %rbx
sete %al
testb $0x3, %r13b
setne %cl
orb %al, %cl
jne 0x6c3c8
incl (%rbx)
leaq -0x48(%rbp), %rbx
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1b59d
movq (%rbx), %rdi
leaq -0x38(%rbp), %rbx
movq %rax, %rsi
movq %r13, %rdx
movl $0x2, %ecx
movq %rbx, %r8
callq 0x1bc32
movq (%rbx), %r15
cmpb $0x0, -0x2c(%rbp)
je 0x6c429
movq -0x68(%rbp), %rax
decl (%rax)
movq -0x40(%rbp), %rbx
jne 0x6c421
movq -0x58(%rbp), %rdi
shlq $0x30, %rdi
orq -0x50(%rbp), %rdi
leaq 0xa56cd(%rip), %rsi     # 0x111ae9
callq 0xd13d
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x6c433
xorl %r12d, %r12d
xorl %r13d, %r13d
movq -0x40(%rbp), %rbx
movq %r14, %rdi
callq 0x347de
movq %r15, (%rbx)
movl %r12d, %eax
movq %r13, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0xf5e4
movq $0x20, 0x10(%rax)
movups 0x74261(%rip), %xmm0    # 0xe06cd
movups %xmm0, 0x18(%rax)
movups 0x74266(%rip), %xmm0    # 0xe06dd
movups %xmm0, 0x28(%rax)
movq %rax, %rdi
callq 0x9302
leaq 0x7b16a(%rip), %rsi     # 0xe75f4
movl $0x31, %edx
movl $0x2, %edi
callq 0x5060
callq 0x52b6
movl $0x1, %edi
callq 0x5130