// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x50(%rsi), %rax
movq (%rax), %rdi
callq 0x1bf90
movq %rax, %rdi
callq 0x1fcd8
cmpl $0x1, (%rax)
jne 0x270a0
movq (%rbx), %rdi
pushq $0x1
popq %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1beb1
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1bf90
movq %rax, %rdi
callq 0x1fcd8
movq %rax, %r15
movq %rax, %rdi
callq 0x20489
testl %eax, %eax
je 0x270d6
movl 0x18(%rbx), %eax
imulq $0xc, %rax, %rcx
leaq 0xd48f(%rip), %rax      # 0x34560
addq %rcx, %rax
jmp 0x27109
movq %r15, %rdi
callq 0x20469
testl %eax, %eax
jne 0x270f4
movq %r15, %rdi
callq 0x20469
testl %eax, %eax
jne 0x270f4
cmpl $0x12, (%r15)
jne 0x27125
movl 0x18(%rbx), %eax
imulq $0xc, %rax, %rax
leaq 0xd45e(%rip), %rcx      # 0x34560
addq %rcx, %rax
addq $0x4, %rax
movl (%rax), %eax
testl %eax, %eax
je 0x27148
movl %eax, 0x18(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2729d
movq %rax, %r14
jmp 0x27230
movq %r15, %rdi
callq 0x204b9
testl %eax, %eax
je 0x27148
movl 0x18(%rbx), %eax
imulq $0xc, %rax, %rax
leaq 0xd421(%rip), %rcx      # 0x34560
addq %rcx, %rax
addq $0x8, %rax
jmp 0x27109
testl %ebp, %ebp
je 0x27268
movq %rbx, %rdi
callq 0x1b5e6
movl %eax, %ebp
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1bf90
movq %rax, %rdi
callq 0x1fcd8
cmpl $0x18, (%rax)
jne 0x2724b
movq %rax, %rdi
callq 0x1fd13
testl %eax, %eax
je 0x2724b
movq 0x50(%rbx), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x261a7
movq (%rbx), %rdi
pushq $0x43
popq %r12
movl %r12d, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1b718
movq %rax, %r15
movq 0x50(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x261a7
movq (%rbx), %rdi
movl %r12d, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1b718
movq %rax, %r14
movq (%rbx), %rdi
pushq $0xd
popq %r12
movl %r12d, %esi
callq 0x1fdc2
movq %rax, 0x20(%r15)
movq (%rbx), %rdi
movl %r12d, %esi
callq 0x1fdc2
movq %rax, 0x20(%r14)
cmpl $0x17, %ebp
je 0x27208
cmpl $0x18, %ebp
jne 0x27284
pushq $0x5b
jmp 0x2720a
pushq $0x5a
popq %rsi
movq (%rbx), %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1b718
movq %rax, %r14
movq (%rbx), %rdi
pushq $0x2
popq %rsi
callq 0x1fdc2
movq %rax, 0x20(%r14)
movq (%rbx), %rdi
pushq $0x2
popq %rsi
callq 0x1fdc2
movq %rax, 0x20(%r14)
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1bf90
movq %rax, %rdi
callq 0x21009
leaq 0xd902(%rip), %rsi      # 0x34b68
jmp 0x27277
movq %r15, %rdi
callq 0x21009
leaq 0xd8a8(%rip), %rsi      # 0x34b1f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x120fd
movl %ebp, %eax
leaq 0x36113(%rip), %rcx     # 0x5d3a0
movq (%rcx,%rax,8), %rdx
leaq 0xd8a9(%rip), %rsi      # 0x34b41
movq %rbx, %rdi
jmp 0x2727d