// File: /workspace/github_c_makefile_star2_O2/mirth-lang[P]mirth/bin/mirth1.c
// Function: mw_mirth_elab_zaTypeElab_elabzeresourcezeargzx
static struct mirth_type_Type mw_mirth_elab_zaTypeElab_elabzeresourcezeargzx (struct mirth_mirth_zaMirth* in_zaMirth_1, struct mirth_elab_zaTypeElab* in_zaTypeElab_2, struct mirth_mirth_zaMirth* *out_zaMirth_3, struct mirth_elab_zaTypeElab* *out_zaTypeElab_4) {
	uint64_t v6 = in_zaTypeElab_2->mtoken;
	struct mirth_mirth_zaMirth* v7;
	struct mirth_elab_zaTypeElab* v8;
	struct mirth_type_StackTypePart v9 = mw_mirth_elab_zaTypeElab_elabzestackzetypezepartzx(in_zaMirth_1, in_zaTypeElab_2, &v7, &v8);
	struct mirth_mirth_zaMirth* branch_zaMirth_10;
	struct mirth_elab_zaTypeElab* branch_zaTypeElab_11;
	struct mirth_type_Type branch_Resource_12;
	switch ((v9).tag) {
		case mirth_type_StackTypePart_Cons: {
			struct mirth_type_Type v13 = mtp_mirth_type_StackTypePart_Cons(v9);
			decref(MK_mirth_type_Type(v13));
			STR* v14;
			STRLIT(v14, "Expected resource, not type.", 28);
			struct mirth_mirth_zaMirth* v15;
			mw_mirth_mirth_zaMirth_emitzeerrorzx(v7, v6, v14, &v15);
			struct mirth_type_Type v16 = { .tag=mirth_type_Type_Error };
			branch_Resource_12 = v16;
			branch_zaTypeElab_11 = v8;
			branch_zaMirth_10 = v15;
		} break;
		case mirth_type_StackTypePart_ConsLabel: {
			uint64_t v17;
			struct mirth_type_Type v18 = mtp_mirth_type_StackTypePart_ConsLabel(v9, &v17);
			decref(MK_mirth_type_Type(v18));
			STR* v19;
			STRLIT(v19, "Expected resource, not label.", 29);
			struct mirth_mirth_zaMirth* v20;
			mw_mirth_mirth_zaMirth_emitzeerrorzx(v7, v6, v19, &v20);
			struct mirth_type_Type v21 = { .tag=mirth_type_Type_Error };
			branch_Resource_12 = v21;
			branch_zaTypeElab_11 = v8;
			branch_zaMirth_10 = v20;
		} break;
		case mirth_type_StackTypePart_With: {
			struct mirth_type_Type v22 = mtp_mirth_type_StackTypePart_With(v9);
			branch_Resource_12 = v22;
			branch_zaTypeElab_11 = v8;
			branch_zaMirth_10 = v7;
		} break;
		case mirth_type_StackTypePart_WithLabel: {
			uint64_t v23;
			struct mirth_type_Type v24 = mtp_mirth_type_StackTypePart_WithLabel(v9, &v23);
			decref(MK_mirth_type_Type(v24));
			STR* v25;
			STRLIT(v25, "Expected resource, not label.", 29);
			struct mirth_mirth_zaMirth* v26;
			mw_mirth_mirth_zaMirth_emitzeerrorzx(v7, v6, v25, &v26);
			struct mirth_type_Type v27 = { .tag=mirth_type_Type_Error };
			branch_Resource_12 = v27;
			branch_zaTypeElab_11 = v8;
			branch_zaMirth_10 = v26;
		} break;
		default: {
			do_panic(str_make("unexpected fallthrough in match\n", 32));
		}
	}
	uint64_t v28 = branch_zaTypeElab_11->mtoken;
	struct mirth_mirth_zaMirth* v29;
	bool v30 = mw_mirth_token_Token_argzeendzy(branch_zaMirth_10, v28, &v29);
	struct mirth_mirth_zaMirth* branch_zaMirth_31;
	struct mirth_elab_zaTypeElab* branch_zaTypeElab_32;
	if (v30) {
		branch_zaTypeElab_32 = branch_zaTypeElab_11;
		branch_zaMirth_31 = v29;
	} else {
		uint64_t v33 = branch_zaTypeElab_11->mtoken;
		STR* v34;
		STRLIT(v34, "Unexpected token after resource.", 32);
		struct mirth_mirth_zaMirth* v35;
		mw_mirth_mirth_zaMirth_emitzeerrorzx(v29, v33, v34, &v35);
		branch_zaTypeElab_32 = branch_zaTypeElab_11;
		branch_zaMirth_31 = v35;
	}
	*out_zaTypeElab_4 = branch_zaTypeElab_32;
	*out_zaMirth_3 = branch_zaMirth_31;
	return branch_Resource_12;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, -0x58(%rbp)
movq %rdx, %r13
movabsq $0xfffffffffffc, %rbx   # imm = 0xFFFFFFFFFFFC
movq 0x10(%rsi), %r15
leaq -0x40(%rbp), %rdx
leaq -0x38(%rbp), %rcx
callq 0x3ac59
movq %rdx, %rdi
movl %eax, %eax
leaq 0x962e7(%rip), %rcx     # 0xd2b9c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x3aac9
movq %rdx, %rcx
andq %rbx, %rcx
sete %sil
testb $0x3, %dl
setne %dil
orb %sil, %dil
jne 0x3c8f3
decl (%rcx)
jne 0x3c8f3
shlq $0x30, %rax
orq %rdx, %rax
leaq 0xcc1fe(%rip), %rsi     # 0x108ae9
movq %rax, %rdi
callq 0xce94
movq 0x10d004e(%rip), %rdx   # 0x110c948
testq %rdx, %rdx
jne 0x3c918
leaq 0x9cc3b(%rip), %rdi     # 0xd9541
pushq $0x1c
popq %rsi
callq 0x8a21
movq %rax, %rdx
movq %rax, 0x10d0030(%rip)   # 0x110c948
movq %rdx, %rax
andq %rbx, %rax
sete %cl
testb $0x3, %dl
setne %sil
orb %cl, %sil
jne 0x3c92f
incl (%rax)
movq -0x40(%rbp), %rdi
leaq -0x30(%rbp), %r12
jmp 0x3ca31
callq 0x3ab5d
movl %eax, %r15d
movq %rdx, %r12
movq -0x38(%rbp), %r14
movq -0x40(%rbp), %rdi
jmp 0x3ca4a
leaq -0x30(%rbp), %rsi
callq 0x3ab9d
movq %rdx, %rcx
andq %rbx, %rcx
sete %sil
testb $0x3, %dl
setne %dil
orb %sil, %dil
jne 0x3c98d
decl (%rcx)
jne 0x3c98d
shlq $0x30, %rax
orq %rdx, %rax
leaq 0xcc164(%rip), %rsi     # 0x108ae9
movq %rax, %rdi
callq 0xce94
movq 0x10cffc4(%rip), %rdx   # 0x110c958
testq %rdx, %rdx
jne 0x3ca12
leaq 0x9cbbe(%rip), %rdi     # 0xd955e
pushq $0x1d
popq %rsi
callq 0x8a21
movq %rax, %rdx
movq %rax, 0x10cffa6(%rip)   # 0x110c958
jmp 0x3ca12
leaq -0x30(%rbp), %rsi
callq 0x3ab09
movq %rdx, %rcx
andq %rbx, %rcx
sete %sil
testb $0x3, %dl
setne %dil
orb %sil, %dil
jne 0x3c9ed
decl (%rcx)
jne 0x3c9ed
shlq $0x30, %rax
orq %rdx, %rax
leaq 0xcc104(%rip), %rsi     # 0x108ae9
movq %rax, %rdi
callq 0xce94
movq 0x10cff5c(%rip), %rdx   # 0x110c950
testq %rdx, %rdx
jne 0x3ca12
leaq 0x9cb5e(%rip), %rdi     # 0xd955e
pushq $0x1d
popq %rsi
callq 0x8a21
movq %rax, %rdx
movq %rax, 0x10cff3e(%rip)   # 0x110c950
movq %rdx, %rax
andq %rbx, %rax
sete %cl
testb $0x3, %dl
setne %sil
orb %cl, %sil
jne 0x3ca29
incl (%rax)
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %r12
movq %r15, %rsi
movq %r12, %rcx
callq 0x2ceb4
movq -0x38(%rbp), %r14
movq (%r12), %rdi
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x10(%r14), %rsi
leaq -0x30(%rbp), %rdx
callq 0x258e2
testb %al, %al
je 0x3ca61
movq -0x30(%rbp), %rax
jmp 0x3caba
movq %r13, -0x50(%rbp)
movq 0x10(%r14), %r13
movq 0x10cfef0(%rip), %rdx   # 0x110c960
testq %rdx, %rdx
jne 0x3ca8e
leaq 0x9cb00(%rip), %rdi     # 0xd957c
pushq $0x20
popq %rsi
callq 0x8a21
movq %rax, %rdx
movq %rax, 0x10cfed2(%rip)   # 0x110c960
andq %rdx, %rbx
sete %al
testb $0x3, %dl
setne %cl
orb %al, %cl
jne 0x3caa0
incl (%rbx)
movq -0x30(%rbp), %rdi
leaq -0x48(%rbp), %rbx
movq %r13, %rsi
movq %rbx, %rcx
callq 0x2ceb4
movq (%rbx), %rax
movq -0x50(%rbp), %r13
movq -0x58(%rbp), %rcx
movq %r14, (%rcx)
movq %rax, (%r13)
movl %r15d, %eax
movq %r12, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq