// File: /workspace/github_c_makefile_star2_O3/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 %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x50(%rsi), %rax
movq (%rax), %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x227ac
cmpl $0x1, (%rax)
jne 0x2a1bb
movq (%rbx), %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1e21e
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x227ac
movq %rax, %r15
movq %rax, %rdi
callq 0x22fb3
testl %eax, %eax
je 0x2a1f2
movl 0x18(%rbx), %eax
leaq (%rax,%rax,2), %rax
leaq 0xe354(%rip), %rcx      # 0x38540
leaq (%rcx,%rax,4), %rax
jmp 0x2a226
movq %r15, %rdi
callq 0x22f93
testl %eax, %eax
jne 0x2a210
movq %r15, %rdi
callq 0x22f93
testl %eax, %eax
jne 0x2a210
cmpl $0x12, (%r15)
jne 0x2a242
movl 0x18(%rbx), %eax
leaq (%rax,%rax,2), %rax
leaq 0xe322(%rip), %rcx      # 0x38540
leaq (%rcx,%rax,4), %rax
addq $0x4, %rax
movl (%rax), %eax
testl %eax, %eax
je 0x2a266
movl %eax, 0x18(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a3c4
movq %rax, %r14
jmp 0x2a353
movq %r15, %rdi
callq 0x23002
testl %eax, %eax
je 0x2a266
movl 0x18(%rbx), %eax
leaq (%rax,%rax,2), %rax
leaq 0xe2e4(%rip), %rcx      # 0x38540
leaq (%rcx,%rax,4), %rax
addq $0x8, %rax
jmp 0x2a226
testl %ebp, %ebp
je 0x2a38f
movq %rbx, %rdi
callq 0x1d422
movl %eax, %ebp
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x227ac
cmpl $0x18, (%rax)
jne 0x2a372
movq %rax, %rdi
callq 0x227e7
testl %eax, %eax
je 0x2a372
movq 0x50(%rbx), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x2925b
movq (%rbx), %rdi
movl $0x43, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r15
movq 0x50(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
callq 0x2925b
movq (%rbx), %rdi
movl $0x43, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r14
movq (%rbx), %rdi
movl $0xd, %esi
callq 0x2289d
movq %rax, 0x20(%r15)
movq (%rbx), %rdi
movl $0xd, %esi
callq 0x2289d
movq %rax, 0x20(%r14)
movl $0x5a, %esi
cmpl $0x17, %ebp
je 0x2a32c
cmpl $0x18, %ebp
jne 0x2a3ab
movl $0x5b, %esi
movq (%rbx), %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x1d5e2
movq %rax, %r14
movq (%rbx), %rdi
movl $0x2, %esi
callq 0x2289d
movq %rax, 0x20(%r14)
movq (%rbx), %rdi
movl $0x2, %esi
callq 0x2289d
movq %rax, 0x20(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x50(%rbx), %rax
movq (%rax), %rdi
callq 0x1e384
movq %rax, %rdi
callq 0x2398e
leaq 0xe7bb(%rip), %rsi      # 0x38b48
jmp 0x2a39e
movq %r15, %rdi
callq 0x2398e
leaq 0xe761(%rip), %rsi      # 0x38aff
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x138e7
movl %ebp, %eax
leaq 0x35fec(%rip), %rcx     # 0x603a0
movq (%rcx,%rax,8), %rdx
leaq 0xe762(%rip), %rsi      # 0x38b21
movq %rbx, %rdi
jmp 0x2a3a4