// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/mi/flatten.c
// Function: compare
static Node *
compare(Flattenctx *s, Node *n, int fields)
{
	const Op cmpmap[Numops][3] = {
		[Oeq] = {Oeq, Oueq, Ofeq},
		[One] = {One, Oune, Ofne},
		[Ogt] = {Ogt, Ougt, Ofgt},
		[Oge] = {Oge, Ouge, Ofge},
		[Olt] = {Olt, Oult, Oflt},
		[Ole] = {Ole, Oule, Ofle}
	};
	Node *r;
	Type *ty;
	Op newop;

	/* void is always void */
	if (tybase(exprtype(n->expr.args[0]))->type == Tyvoid)
		return mkboollit(n->loc, 1);

	newop = Obad;
	ty = tybase(exprtype(n->expr.args[0]));
	if (istysigned(ty))
		newop = cmpmap[n->expr.op][0];
	else if (istyunsigned(ty))
		newop = cmpmap[n->expr.op][1];
	else if (istyunsigned(ty))
		newop = cmpmap[n->expr.op][1];
	else if (ty->type == Typtr)
		newop = cmpmap[n->expr.op][1];
	else if (istyfloat(ty))
		newop = cmpmap[n->expr.op][2];

	if (newop != Obad) {
		n->expr.op = newop;
		r = visit(s, n);
	} else if (fields) {
		r = comparecomplex(s, n, exprop(n));
	} else {
		fatal(n, "unsupported comparison on type %s", tystr(ty));
	}
	r->expr.type = mktype(n->loc, Tybool);
	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x4a0(%rbp), %rdi
leaq 0x1121c(%rip), %rsi     # 0x54a60
movl $0x480, %edx            # imm = 0x480
callq 0x6260
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
callq 0x30340
movq %rax, %rdi
callq 0x36a30
cmpl $0x1, (%rax)
jne 0x43885
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x30160
movq %rax, -0x8(%rbp)
jmp 0x43a7d
movl $0x0, -0x4b4(%rbp)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq (%rax), %rdi
callq 0x30340
movq %rax, %rdi
callq 0x36a30
movq %rax, -0x4b0(%rbp)
movq -0x4b0(%rbp), %rdi
callq 0x378a0
cmpl $0x0, %eax
je 0x438e3
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
leaq -0x4a0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x4b4(%rbp)
jmp 0x439b3
movq -0x4b0(%rbp), %rdi
callq 0x37850
cmpl $0x0, %eax
je 0x43919
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
leaq -0x4a0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x4b4(%rbp)
jmp 0x439b1
movq -0x4b0(%rbp), %rdi
callq 0x37850
cmpl $0x0, %eax
je 0x4394c
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
leaq -0x4a0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x4b4(%rbp)
jmp 0x439af
movq -0x4b0(%rbp), %rax
cmpl $0x12, (%rax)
jne 0x4397a
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
leaq -0x4a0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x4b4(%rbp)
jmp 0x439ad
movq -0x4b0(%rbp), %rdi
callq 0x37930
cmpl $0x0, %eax
je 0x439ab
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
leaq -0x4a0(%rbp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x4b4(%rbp)
jmp 0x439ad
jmp 0x439af
jmp 0x439b1
jmp 0x439b3
cmpl $0x0, -0x4b4(%rbp)
je 0x439df
movl -0x4b4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x43a90
movq %rax, -0x4a8(%rbp)
jmp 0x43a53
cmpl $0x0, -0x1c(%rbp)
je 0x43a22
movq -0x10(%rbp), %rax
movq %rax, -0x4c8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x4c0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2f210
movq -0x4c8(%rbp), %rdi
movq -0x4c0(%rbp), %rsi
movl %eax, %edx
callq 0x43d50
movq %rax, -0x4a8(%rbp)
jmp 0x43a51
movq -0x18(%rbp), %rax
movq %rax, -0x4d0(%rbp)
movq -0x4b0(%rbp), %rdi
callq 0x38a10
movq -0x4d0(%rbp), %rdi
movq %rax, %rdx
leaq 0x115d5(%rip), %rsi     # 0x5501f
movb $0x0, %al
callq 0x1dfe0
jmp 0x43a53
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl $0x2, %esi
callq 0x36c10
movq %rax, %rcx
movq -0x4a8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x4a8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
nopw (%rax,%rax)