// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x343a3(%rip), %rdi     # 0x37470
xorl %esi, %esi
movl $0x90, %edx
callq 0x2100
leaq 0x34420(%rip), %rdi     # 0x37500
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
leaq 0x3440d(%rip), %rax     # 0x37500
movq %rax, 0x3439e(%rip)     # 0x37498
leaq 0x343ff(%rip), %rdi     # 0x37500
leaq 0x260c0(%rip), %rsi     # 0x291c8
callq 0x2430
leaq 0x343ec(%rip), %rdi     # 0x37500
leaq 0x2616d(%rip), %rsi     # 0x29288
callq 0x2430
leaq 0x343d9(%rip), %rdi     # 0x37500
leaq 0x2611a(%rip), %rsi     # 0x29248
callq 0x2430
leaq 0x343c6(%rip), %rdi     # 0x37500
leaq 0x260c7(%rip), %rsi     # 0x29208
callq 0x2430
leaq 0x343b3(%rip), %rdi     # 0x37500
leaq 0x26174(%rip), %rsi     # 0x292c8
callq 0x2430
leaq 0x343a0(%rip), %rdi     # 0x37500
leaq 0x261a1(%rip), %rsi     # 0x29308
callq 0x2430
movl $0x456, 0x2621a(%rip)   # imm = 0x456
movl $0x0, -0x14(%rbp)
leaq -0xb04(%rip), %rax      # 0x2680
movq %rax, 0x2620d(%rip)     # 0x29398
movb $0x1, %al
cmpq $0x0, 0x342d3(%rip)     # 0x37468
movb %al, -0x2a(%rbp)
jne 0x31b2
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, 0x342c0(%rip)     # 0x37468
cmpq $0x0, %rax
setne %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x2b(%rbp)
je 0x3201
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2d, %ecx
movb %al, -0x2b(%rbp)
jne 0x3201
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x2b(%rbp)
movb -0x2b(%rbp), %al
testb $0x1, %al
jne 0x320d
jmp 0x33f9
movq -0x10(%rbp), %rax
movq (%rax), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x324f
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x324f
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x33f9
movb $0x0, -0x29(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2c(%rbp)
je 0x3284
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb (%rax), %al
movb %al, -0x29(%rbp)
movsbl %al, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x2c(%rbp)
movb -0x2c(%rbp), %al
testb $0x1, %al
jne 0x3290
jmp 0x33d7
movsbl -0x29(%rbp), %eax
movl %eax, -0x30(%rbp)
subl $0x64, %eax
je 0x33b3
jmp 0x32a2
movl -0x30(%rbp), %eax
subl $0x70, %eax
je 0x32bd
jmp 0x32ac
movl -0x30(%rbp), %eax
subl $0x73, %eax
je 0x333b
jmp 0x33d2
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x1cd6d(%rip), %rax     # 0x20039
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x32e6
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x3327
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3313
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x331d
callq 0x3020
callq 0x2050
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x3327
movq -0x38(%rbp), %rdi
callq 0x2290
movl %eax, 0x2605a(%rip)     # 0x29390
jmp 0x33d2
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x1ccef(%rip), %rax     # 0x20039
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x3364
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x33a5
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x3391
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x339b
callq 0x3020
callq 0x2050
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x33a5
movq -0x48(%rbp), %rdi
callq 0x2290
movl %eax, -0x14(%rbp)
jmp 0x33d2
movq 0x25c3e(%rip), %rax     # 0x28ff8
movq (%rax), %rax
movq %rax, 0x25fbc(%rip)     # 0x29380
leaq -0xccb(%rip), %rax      # 0x2700
movq %rax, 0x25fc6(%rip)     # 0x29398
jmp 0x3253
movq $0x0, -0x28(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x31ca
cmpl $0x1, -0x8(%rbp)
jge 0x3404
callq 0x3020
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, 0x25f76(%rip)     # 0x29388
movl $0x0, 0x34044(%rip)     # 0x37460
movl $0xffffffff, 0x3403e(%rip) # imm = 0xFFFFFFFF
leaq 0x1cd65(%rip), %rdi     # 0x20192
callq 0x2b30
leaq 0x33fd7(%rip), %rdi     # 0x37410
callq 0x3c30
leaq 0x3402b(%rip), %rdi     # 0x37470
callq 0x4260
leaq 0x33f57(%rip), %rdi     # 0x373a8
addq $0x2c, %rdi
callq 0x8ec0
movw $0x0, 0x3401b(%rip)     # 0x3747e
movl -0x14(%rbp), %eax
movl %eax, 0x34044(%rip)     # 0x374b0
movw $0x1ff, 0x25f2b(%rip)   # imm = 0x1FF
leaq 0x33ff4(%rip), %rdi     # 0x37470
callq 0x7350
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)