// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/xgp.c
// Function: xgp_sync
void
xgp_sync(XGP *xgp)
{
	int wstatus;
	if(waitpid(-1, &wstatus, WNOHANG) > 0) {
		if(WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != 0)
			fprintf(stderr, "Printing error\n");
	}

	if(xgp->xcr & FMOT)
		xgp->speed += (xgp->speed < SPEED_READY);
	else if (--xgp->stopping == 0) {
		xgp->stopping = 1;
		if(xgp->speed == SPEED_READY)
			fprintf(stderr, "XGP stopping\n");
		if(xgp->speed == 1)
			fprintf(stderr, "XGP stopped\n");
		xgp->speed -= (xgp->speed > 0);
	}

	if(xgp->speed >= SPEED_READY) {
		if((xgp->xsr & FRDY) == 0) {
			fprintf(stderr, "Paper up to speed\n");
			xgp->stopping = 3*MKTOCT;
		}
		print_line();
		xgp->xsr |= FRDY;
	} else
		xgp->xsr &= ~FRDY;

	if((xgp->xcr & FRDY) == 0)
		return;

	if(xgp->xcr & FGO)
		xgp->go = xgp_go;
	else
		xgp_done(xgp, FSYN);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq -0xc(%rbp), %rsi
movl $0x1, %edx
callq 0x2230
cmpl $0x0, %eax
jle 0x3da9
movl -0xc(%rbp), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
jne 0x3da7
movl -0xc(%rbp), %eax
andl $0xff00, %eax           # imm = 0xFF00
sarl $0x8, %eax
cmpl $0x0, %eax
je 0x3da7
movq 0x25262(%rip), %rax     # 0x28ff8
movq (%rax), %rdi
leaq 0x1c492(%rip), %rsi     # 0x20232
movb $0x0, %al
callq 0x2140
jmp 0x3da9
movq -0x8(%rbp), %rax
movzwl 0x28(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x3ddd
movq -0x8(%rbp), %rax
cmpl $0x12c, 0x44(%rax)      # imm = 0x12C
setl %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x8(%rbp), %rax
addl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
jmp 0x3e5f
movq -0x8(%rbp), %rcx
movl 0x4c(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x4c(%rcx)
cmpl $0x0, %eax
jne 0x3e5d
movq -0x8(%rbp), %rax
movl $0x1, 0x4c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x12c, 0x44(%rax)      # imm = 0x12C
jne 0x3e1f
movq 0x251ea(%rip), %rax     # 0x28ff8
movq (%rax), %rdi
leaq 0x1c435(%rip), %rsi     # 0x2024d
movb $0x0, %al
callq 0x2140
movq -0x8(%rbp), %rax
cmpl $0x1, 0x44(%rax)
jne 0x3e41
movq 0x251c8(%rip), %rax     # 0x28ff8
movq (%rax), %rdi
leaq 0x1c421(%rip), %rsi     # 0x2025b
movb $0x0, %al
callq 0x2140
movq -0x8(%rbp), %rax
cmpl $0x0, 0x44(%rax)
setg %al
andb $0x1, %al
movzbl %al, %edx
movq -0x8(%rbp), %rax
movl 0x44(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x44(%rax)
jmp 0x3e5f
movq -0x8(%rbp), %rax
cmpl $0x12c, 0x44(%rax)      # imm = 0x12C
jl 0x3eb5
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x3e9f
movq 0x25175(%rip), %rax     # 0x28ff8
movq (%rax), %rdi
leaq 0x1c3db(%rip), %rsi     # 0x20268
movb $0x0, %al
callq 0x2140
movq -0x8(%rbp), %rax
movl $0x1830, 0x4c(%rax)     # imm = 0x1830
callq 0x94a0
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
orl $0x40, %ecx
movw %cx, 0x2c(%rax)
jmp 0x3ec4
movq -0x8(%rbp), %rax
movzwl 0x2c(%rax), %ecx
andl $-0x41, %ecx
movw %cx, 0x2c(%rax)
movq -0x8(%rbp), %rax
movzwl 0x28(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x3ed6
jmp 0x3f05
movq -0x8(%rbp), %rax
movzwl 0x28(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3ef7
movq -0x8(%rbp), %rax
leaq -0x1d1(%rip), %rcx      # 0x3d20
movq %rcx, 0x30(%rax)
jmp 0x3f05
movq -0x8(%rbp), %rdi
movl $0x4000, %esi           # imm = 0x4000
callq 0x38d0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)