// File: /workspace/github_c_makefile_star2_O2/aap[P]pdp11/xgp11.c
// Function: main
int
main(int argc, char *argv[])
{
	uint32 sleep;

	memset(&cpu, 0, sizeof(cpu));
	memset(&bus, 0, sizeof(Bus));
	cpu.bus = &bus;
	busadddev(&bus, &membusdev);
#ifndef KD11Bp
	busadddev(&bus, &kwbusdev);
	busadddev(&bus, &klbusdev);
#endif
	busadddev(&bus, &kebusdev);
	busadddev(&bus, &xgpbusdev);
	busadddev(&bus, &ten11busdev);

	port = 1110;
	sleep = 0;
	debug = quiet;
	ARGBEGIN{
	case 'p':
		port = atoi(EARGF(usage()));
		break;
	case 's':
		sleep = atoi(EARGF(usage()));
		break;
	case 'd':
		logfile = stderr;
		debug = log;
		break;
	}ARGEND;

	if(argc < 1)
		usage();

	host = argv[0];
	ten11.cycle = 0;
	ten11.fd = -1;
	loadmem("mem.txt");

//	if(loadpt("maindec/MAINDEC-11-D0NA-PB.ptap"))
//	if(loadpt("maindec/MAINDEC-11-D2AA-PB.ptap"))
//		return 0;

//	cpu.r[7] = 0200;
//	cpu.sw = 0104000;

	//void eaetest(KE11 *ke);
	//eaetest(&ke11);

	initxgp(&xgp);

	reset(&cpu);

	ttyopen(&TTYDEV.tty);

	/* wait until we get some data from the 10 */
	cpu.r[7] = 0;
	cpu.throttle = sleep;
	memory[0] = 0777;
	run(&cpu);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %r15d
leaq 0x28881(%rip), %rdi     # 0x2b450
xorl %ebx, %ebx
movl $0x90, %edx
xorl %esi, %esi
callq 0x20f0
andq $0x0, 0x2890b(%rip)     # 0x2b4f0
xorps %xmm0, %xmm0
movups %xmm0, 0x288f1(%rip)    # 0x2b4e0
leaq 0x288ea(%rip), %r12     # 0x2b4e0
movq %r12, 0x2887b(%rip)     # 0x2b478
leaq 0x1a5bc(%rip), %rsi     # 0x1d1c0
movq %r12, %rdi
callq 0x242c
leaq 0x1a66d(%rip), %rsi     # 0x1d280
movq %r12, %rdi
callq 0x242c
leaq 0x1a61e(%rip), %rsi     # 0x1d240
movq %r12, %rdi
callq 0x242c
leaq 0x1a5cf(%rip), %rsi     # 0x1d200
movq %r12, %rdi
callq 0x242c
leaq 0x1a680(%rip), %rsi     # 0x1d2c0
movq %r12, %rdi
callq 0x242c
leaq 0x1a6b1(%rip), %rsi     # 0x1d300
movq %r12, %rdi
callq 0x242c
movl $0x456, 0x1a70f(%rip)   # imm = 0x456
leaq -0x781(%rip), %rax      # 0x24e7
movq %rax, 0x1a709(%rip)     # 0x1d378
cmpq $0x0, 0x287d1(%rip)     # 0x2b448
jne 0x2c83
movq (%r14), %rax
movq %rax, 0x287c5(%rip)     # 0x2b448
movq 0x1a36e(%rip), %rax     # 0x1cff8
movq (%rax), %r12
leaq -0x7ac(%rip), %r13      # 0x24e8
leaq 0x1037f(%rip), %rbp     # 0x1301a
leaq 0x8(%r14), %rax
leal -0x1(%r15), %edx
movq 0x8(%r14), %rsi
testq %rsi, %rsi
je 0x2d5f
cmpb $0x2d, (%rsi)
jne 0x2d5f
leaq 0x1(%rsi), %rdi
movzbl 0x1(%rsi), %ecx
cmpl $0x2d, %ecx
je 0x2ccf
testl %ecx, %ecx
jne 0x2cd5
jmp 0x2d5f
cmpb $0x0, 0x2(%rsi)
je 0x2d51
movl %edx, %r15d
movq %rax, %r14
testb %cl, %cl
je 0x2c9b
incq %rdi
cmpb $0x64, %cl
je 0x2d3f
movzbl %cl, %eax
cmpl $0x73, %eax
je 0x2d1a
cmpl $0x70, %eax
jne 0x2d4d
cmpb $0x0, (%rdi)
jne 0x2d0d
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x2de1
addq $0x8, %r14
decl %r15d
callq 0x2290
movl %eax, 0x1a658(%rip)     # 0x1d370
jmp 0x2d3a
cmpb $0x0, (%rdi)
jne 0x2d33
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x2de1
addq $0x8, %r14
decl %r15d
callq 0x2290
movl %eax, %ebx
movq %rbp, %rdi
jmp 0x2d4d
movq %r12, 0x1a61a(%rip)     # 0x1d360
movq %r13, 0x1a62b(%rip)     # 0x1d378
movb (%rdi), %cl
jmp 0x2cdb
addl $-0x2, %r15d
addq $0x10, %r14
movl %r15d, %edx
movq %r14, %rax
testl %edx, %edx
jle 0x2de1
movq (%rax), %rax
movq %rax, 0x1a5fb(%rip)     # 0x1d368
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x286c2(%rip)     # 0x2b440
leaq 0x103df(%rip), %rdi     # 0x13164
callq 0x27ec
leaq 0x2865f(%rip), %rdi     # 0x2b3f0
callq 0x3193
leaq 0x286b3(%rip), %r14     # 0x2b450
movq %r14, %rdi
callq 0x357b
leaq 0x28608(%rip), %rdi     # 0x2b3b4
callq 0x6079
andw $0x0, 0x286a5(%rip)     # 0x2b45e
movl %ebx, 0x286d1(%rip)     # 0x2b490
movw $0x1ff, 0x1a5b8(%rip)   # imm = 0x1FF
movq %r14, %rdi
callq 0x5509
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2b36
nop