// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movl 0x8(%rsi), %eax
cmpl $0x1, %eax
je 0x5d6d
cmpl $0x27, %eax
je 0x5da9
cmpl $0x3, %eax
jne 0x5dc9
movq 0x10(%rbx), %rax
cmpl $0x3, 0x4(%rax)
jne 0x5da9
movq 0x18(%rbx), %rax
cmpl $0x4, 0x4(%rax)
jne 0x5da9
cmpl $0x0, 0x18(%rax)
je 0x5da9
movl $0x1, 0x8(%rbx)
movl 0x18(%rax), %edi
movl $0x3, %esi
callq 0xac01
movq %rax, 0x18(%rbx)
jmp 0x5da9
movq 0x10(%rbx), %rax
movl 0x4(%rax), %edi
callq 0xa8d7
testl %eax, %eax
jne 0x5eaf
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0xb555
testl %eax, %eax
je 0x5da9
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
movl 0x18(%rax), %edi
movl 0x4(%rcx), %esi
callq 0xac01
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0xb5af
testl %eax, %eax
je 0x5dc9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rbx), %eax
leaq 0x29545(%rip), %rcx     # 0x2f318
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
movl $0x59089, %r14d         # imm = 0x59089
movq %rax, 0x8(%rsp)
movzbl (%rax), %ecx
cmpl $0x25, %ecx
je 0x5e07
testl %ecx, %ecx
je 0x5dba
movsbl %cl, %edi
movq 0x10(%rsp), %rsi
callq 0x41f0
jmp 0x5e70
incq %rax
movq %rax, 0x8(%rsp)
movl %ebp, %eax
movq 0x8(%rsp), %r13
movzbl (%r13), %ecx
movsbq %cl, %r12
leal -0x66(%rcx), %edx
cmpl $0x12, %edx
ja 0x5e32
btl %edx, %r14d
jb 0x5e5a
cmpl $0xe, %edx
je 0x5e7d
testl %ecx, %ecx
je 0x5dba
callq 0x4390
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r12,2)
je 0x5e9e
movq %r13, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x4260
decl %eax
jmp 0x5e11
cltq
movq 0x10(%rbx,%rax,8), %rsi
movq 0x10(%rsp), %rdi
movl %r12d, %edx
callq 0x5a97
incl %ebp
movq 0x8(%rsp), %rax
incq %rax
jmp 0x5de7
cltq
movq 0x10(%rbx,%rax,8), %rax
movl 0x4(%rax), %eax
leaq 0x3d732(%rip), %rcx     # 0x435c0
movq (%rcx,%rax,8), %rdi
movq 0x10(%rsp), %rsi
callq 0x4190
jmp 0x5e70
leaq 0x29792(%rip), %rdi     # 0x2f637
movl %r12d, %esi
xorl %eax, %eax
callq 0x13a00
leaq 0x29739(%rip), %rdi     # 0x2f5ef
leaq 0x29754(%rip), %rsi     # 0x2f611
leaq 0x29756(%rip), %rcx     # 0x2f61a
movl $0x89, %edx
callq 0x4180