// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/6/gengas.c
// Function: iprintf
void
iprintf(FILE *fd, Insn *insn)
{
	char *p;
	int i;
	int idx;

	/* x64 has a quirk; it has no movzlq because mov zero extends. Thi
	 * means that we need to do a movl when we really want a movzlq. Since
	 * we don't know the name of the reg to use, we need to sub it in when
	 * writing... */
	switch (insn->op) {
	case Imovzx:
		if (insn->args[0]->mode == ModeL && insn->args[1]->mode == ModeQ) {
			if (insn->args[1]->reg.colour) {
				insn->op = Imov;
				insn->args[1] = coreg(insn->args[1]->reg.colour, ModeL);
			}
		}
		if(dumbmov(insn->args[0], insn->args[1]))
			return;
		break;
	case Imovs:
		if(dumbmov(insn->args[0], insn->args[1]))
			return;
		break;
	case Imov:
		assert(!isfloatmode(insn->args[0]->mode));
		/* 
		 * if one reg is a subreg of another, we can just use the right
		 * mode to move between them, without any cost.
		 */
		if (issubreg(insn->args[0], insn->args[1]))
			insn->args[0] = coreg(insn->args[0]->reg.colour, insn->args[1]->mode);
		if(dumbmov(insn->args[0], insn->args[1]))
			return;
		break;
	default:
		break;
	}
	p = insnfmt[insn->op];
	i = 0;
	for (; *p; p++) {
		if (*p !=  '%') {
			fputc(*p, fd);
			continue;
		}

		/* %-formating */
		p++;
		idx = i;
again:
		switch (*p) {
		case '\0':
			goto done; /* skip the final p++ */
		case 'r': /* int register */
		case 'f': /* float register */
		case 'm': /* memory */
		case 'i': /* imm */
		case 'v': /* reg/mem */
		case 'u': /* reg/imm */
		case 'x': /* reg/mem/imm */
			locprint(fd, insn->args[idx], *p);
			i++;
			break;
		case 't':
			fputs(modenames[insn->args[idx]->mode], fd);
			break;
		default:
			/* the  asm description uses 1-based indexing, so that 0
			 * can be used as a sentinel. */
			if (!isdigit(*p))
				die("Invalid %%-specifier '%c'", *p);
			idx = strtol(p, &p, 10) - 1;
			goto again;
			break;
		}
	}
done
:
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
movl 0x8(%rsi), %eax
cmpl $0x1, %eax
movq %rsi, (%rsp)
je 0x55f8
cmpl $0x27, %eax
je 0x55f2
cmpl $0x3, %eax
jne 0x5653
movq (%rsp), %rbx
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
cmpl $0x3, 0x4(%rdi)
jne 0x563b
cmpl $0x4, 0x4(%rsi)
jne 0x563b
cmpl $0x0, 0x18(%rsi)
je 0x563b
movl $0x1, 0x8(%rbx)
movl 0x18(%rsi), %edi
pushq $0x3
popq %rsi
callq 0x9f13
movq %rax, %rsi
movq %rax, 0x18(%rbx)
movq 0x10(%rbx), %rdi
jmp 0x563b
movq 0x10(%rbx), %rdi
jmp 0x5637
movq 0x10(%rbx), %rax
movl 0x4(%rax), %edi
callq 0x9cab
testl %eax, %eax
jne 0x5745
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0xa84d
movq 0x10(%rbx), %rdi
testl %eax, %eax
je 0x5637
movl 0x18(%rdi), %edi
movq 0x18(%rbx), %rax
movl 0x4(%rax), %esi
callq 0x9f13
movq %rax, %rdi
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rsi
callq 0xa8a3
testl %eax, %eax
je 0x5653
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rax
movl 0x8(%rax), %eax
leaq 0x25cb7(%rip), %rcx     # 0x2b318
movslq (%rcx,%rax,4), %r12
addq %rcx, %r12
xorl %r14d, %r14d
leaq 0x10(%rsp), %r15
pushq $0xa
popq %rbp
movl $0x59089, %ebx          # imm = 0x59089
movq %r12, 0x10(%rsp)
movzbl (%r12), %eax
cmpl $0x25, %eax
je 0x569a
testl %eax, %eax
je 0x5644
movsbl %al, %edi
movq 0x8(%rsp), %rsi
callq 0x41f0
jmp 0x5709
incq %r12
movq %r12, 0x10(%rsp)
movl %r14d, %eax
movzbl (%r12), %ecx
movsbq %cl, %r13
leal -0x66(%rcx), %edx
cmpl $0x12, %edx
ja 0x56c2
btl %edx, %ebx
cltq
jb 0x56f0
cmpl $0xe, %edx
je 0x5711
testl %ecx, %ecx
je 0x5644
callq 0x4390
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r13,2)
je 0x5734
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x4260
decl %eax
movq 0x10(%rsp), %r12
jmp 0x56a5
movq (%rsp), %rcx
movq 0x10(%rcx,%rax,8), %rsi
movq 0x8(%rsp), %rdi
movl %r13d, %edx
callq 0x5355
incl %r14d
incq %r12
jmp 0x5678
movq (%rsp), %rcx
movq 0x10(%rcx,%rax,8), %rax
movl 0x4(%rax), %eax
leaq 0x3ae9c(%rip), %rcx     # 0x405c0
movq (%rcx,%rax,8), %rdi
movq 0x8(%rsp), %rsi
callq 0x4190
jmp 0x5709
leaq 0x25efc(%rip), %rdi     # 0x2b637
movl %r13d, %esi
xorl %eax, %eax
callq 0x1205c
leaq 0x25ea3(%rip), %rdi     # 0x2b5ef
leaq 0x25ebe(%rip), %rsi     # 0x2b611
leaq 0x25ec0(%rip), %rcx     # 0x2b61a
movl $0x89, %edx
callq 0x4180