// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/6/simp.c
// Function: simpucon
static Node *
simpucon(Simp *s, Node *n, Node *dst)
{
	Node *tmp, *u, *tag, *elt, *sz;
	Node *r;
	Type *ty;
	Ucon *uc;
	size_t o;

	/* find the ucon we're constructing here */
	ty = tybase(exprtype(n));
	uc = finducon(ty, n->expr.args[0]);
	if (!uc)
		die("Couldn't find union constructor");

	if (dst)
		tmp = dst;
	else
		tmp = temp(s, n);

	if (isenum(ty)) {
		/* enums are treated as integers
		 * by the backend */
		append(s, set(tmp, n));
		return tmp;
	}

	/* Set the tag on the ucon */
	u = addr(s, tmp, mktype(n->loc, Tyuint));
	tag = mkintlit(n->loc, uc->id);
	tag->expr.type = mktype(n->loc, Tyuint);
	append(s, set(deref(u, tyword), tag));


	/* fill the value, if needed */
	if (!uc->etype)
		return tmp;
	elt = rval(s, n->expr.args[1], NULL);
	o = alignto(Wordsz, uc->etype);
	u = addk(u, o);
	if (isstacktype(uc->etype)) {
		elt = addr(s, elt, uc->etype);
		sz = disp(n->loc, tysize(uc->etype));
		r = mkexpr(n->loc, Oblit, u, elt, sz, NULL);
	} else {
		r = set(deref(u, uc->etype), elt);
	}
	append(s, r);
	return tmp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x30340
movq %rax, %rdi
callq 0x36a30
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rsi
callq 0x377a0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x18ac9
leaq 0x358f5(%rip), %rdi     # 0x4e3b7
movb $0x0, %al
callq 0x1df20
cmpq $0x0, -0x20(%rbp)
je 0x18ada
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x18aeb
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x16940
movq %rax, -0x28(%rbp)
movq -0x58(%rbp), %rdi
callq 0x36ab0
cmpl $0x0, %eax
je 0x18b27
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x17580
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0x17710
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x18cdd
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0xc, %esi
callq 0x36c10
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rax, %rdx
callq 0x16af0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq -0x60(%rbp), %rcx
movq 0x8(%rcx), %rsi
movq (%rax), %rdi
callq 0x2f3c0
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0xc, %esi
callq 0x36c10
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rdi
movq 0x642a7(%rip), %rsi     # 0x7ce50
callq 0x17670
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x17580
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x17710
movq -0x60(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x18bde
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x18cdd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x177e0
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rsi
movl $0x4, %edi
callq 0x16770
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x18400
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x369d0
cmpl $0x0, %eax
je 0x18ca7
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rdx
callq 0x16af0
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x1c0f0
movq %rax, %rcx
movq -0x90(%rbp), %rax
movl %ecx, %esi
movq (%rax), %rdi
callq 0x17540
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r8
movq (%rax), %rdi
movl $0x46, %esi
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x2f400
movq %rax, -0x50(%rbp)
jmp 0x18cc8
movq -0x30(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x17670
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x17580
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x17710
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)