// File: /workspace/github_c_makefile_star2_O3/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
je 0x5ca0
cmpl $0x27, %eax
je 0x5c9a
cmpl $0x3, %eax
jne 0x5cfb
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
cmpl $0x3, 0x4(%rdi)
jne 0x5ce3
cmpl $0x4, 0x4(%rsi)
jne 0x5ce3
cmpl $0x0, 0x18(%rsi)
je 0x5ce3
movl $0x1, 0x8(%rbx)
movl 0x18(%rsi), %edi
movl $0x3, %esi
callq 0xaacd
movq %rax, %rsi
movq %rax, 0x18(%rbx)
movq 0x10(%rbx), %rdi
jmp 0x5ce3
movq 0x10(%rbx), %rdi
jmp 0x5cdf
movq 0x10(%rbx), %rax
movl 0x4(%rax), %edi
callq 0xa7a3
testl %eax, %eax
jne 0x5dde
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0xb411
movq 0x10(%rbx), %rdi
testl %eax, %eax
je 0x5cdf
movl 0x18(%rdi), %edi
movq 0x18(%rbx), %rax
movl 0x4(%rax), %esi
callq 0xaacd
movq %rax, %rdi
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rsi
callq 0xb46b
testl %eax, %eax
je 0x5cfb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rbx), %eax
leaq 0x29613(%rip), %rcx     # 0x2f318
movslq (%rcx,%rax,4), %r12
addq %rcx, %r12
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
movl $0x59089, %r14d         # imm = 0x59089
movq %r12, 0x10(%rsp)
movzbl (%r12), %eax
cmpl $0x25, %eax
je 0x5d3b
testl %eax, %eax
je 0x5cec
movsbl %al, %edi
movq 0x8(%rsp), %rsi
callq 0x41f0
jmp 0x5da4
incq %r12
movq %r12, 0x10(%rsp)
movl %ebp, %eax
movzbl (%r12), %ecx
movsbq %cl, %r13
leal -0x66(%rcx), %edx
cmpl $0x12, %edx
ja 0x5d61
btl %edx, %r14d
jb 0x5d8e
cmpl $0xe, %edx
je 0x5dac
testl %ecx, %ecx
je 0x5cec
callq 0x4390
movq (%rax), %rax
testb $0x8, 0x1(%rax,%r13,2)
je 0x5dcd
movq %r12, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x4260
decl %eax
movq 0x10(%rsp), %r12
jmp 0x5d45
cltq
movq 0x10(%rbx,%rax,8), %rsi
movq 0x8(%rsp), %rdi
movl %r13d, %edx
callq 0x59df
incl %ebp
incq %r12
jmp 0x5d19
cltq
movq 0x10(%rbx,%rax,8), %rax
movl 0x4(%rax), %eax
leaq 0x3d803(%rip), %rcx     # 0x435c0
movq (%rcx,%rax,8), %rdi
movq 0x8(%rsp), %rsi
callq 0x4190
jmp 0x5da4
leaq 0x29863(%rip), %rdi     # 0x2f637
movl %r13d, %esi
xorl %eax, %eax
callq 0x13844
leaq 0x2980a(%rip), %rdi     # 0x2f5ef
leaq 0x29825(%rip), %rsi     # 0x2f611
leaq 0x29827(%rip), %rcx     # 0x2f61a
movl $0x89, %edx
callq 0x4180