// File: /workspace/github_c_makefile_star2_O0/mrdotx[P]st/boxdraw.c
// Function: drawboxlines
void
drawboxlines(int x, int y, int w, int h, XftColor *fg, ushort bd)
{
	/* s: stem thickness. width/8 roughly matches underscore thickness. */
	/* We draw bold as 1.5 * normal-stem and at least 1px thicker.      */
	/* doubles draw at least 3px, even when w or h < 3. bold needs 6px. */
	int mwh = MIN(w, h);
	int base_s = MAX(1, DIV(mwh, 8));
	int bold = (bd & BDB) && mwh >= 6;  /* possibly ignore boldness */
	int s = bold ? MAX(base_s + 1, DIV(3 * base_s, 2)) : base_s;
	int w2 = DIV(w - s, 2), h2 = DIV(h - s, 2);
	/* the s-by-s square (x + w2, y + h2, s, s) is the center texel.    */
	/* The base length (per direction till edge) includes this square.  */

	int light = bd & (LL | LU | LR | LD);
	int double_ = bd & (DL | DU | DR | DD);

	if (light) {
		/* d: additional (negative) length to not-draw the center   */
		/* texel - at arcs and avoid drawing inside (some) doubles  */
		int arc = bd & BDA;
		int multi_light = light & (light - 1);
		int multi_double = double_ & (double_ - 1);
		/* light crosses double only at DH+LV, DV+LH (ref. shapes)  */
		int d = arc || (multi_double && !multi_light) ? -s : 0;

		if (bd & LL)
			XftDrawRect(xd, fg, x, y + h2, w2 + s + d, s);
		if (bd & LU)
			XftDrawRect(xd, fg, x + w2, y, s, h2 + s + d);
		if (bd & LR)
			XftDrawRect(xd, fg, x + w2 - d, y + h2, w - w2 + d, s);
		if (bd & LD)
			XftDrawRect(xd, fg, x + w2, y + h2 - d, s, h - h2 + d);
	}

	/* double lines - also align with light to form heavy when combined */
	if (double_) {
		/*
		* going clockwise, for each double-ray: p is additional length
		* to the single-ray nearer to the previous direction, and n to
		* the next. p and n adjust from the base length to lengths
		* which consider other doubles - shorter to avoid intersections
		* (p, n), or longer to draw the far-corner texel (n).
		*/
		int dl = bd & DL, du = bd & DU, dr = bd & DR, dd = bd & DD;
		if (dl) {
			int p = dd ? -s : 0, n = du ? -s : dd ? s : 0;
			XftDrawRect(xd, fg, x, y + h2 + s, w2 + s + p, s);
			XftDrawRect(xd, fg, x, y + h2 - s, w2 + s + n, s);
		}
		if (du) {
			int p = dl ? -s : 0, n = dr ? -s : dl ? s : 0;
			XftDrawRect(xd, fg, x + w2 - s, y, s, h2 + s + p);
			XftDrawRect(xd, fg, x + w2 + s, y, s, h2 + s + n);
		}
		if (dr) {
			int p = du ? -s : 0, n = dd ? -s : du ? s : 0;
			XftDrawRect(xd, fg, x + w2 - p, y + h2 - s, w - w2 + p, s);
			XftDrawRect(xd, fg, x + w2 - n, y + h2 + s, w - w2 + n, s);
		}
		if (dd) {
			int p = dr ? -s : 0, n = dl ? -s : dr ? s : 0;
			XftDrawRect(xd, fg, x + w2 + s, y + h2 - p, s, h - h2 + p);
			XftDrawRect(xd, fg, x + w2 - s, y + h2 - n, s, h - h2 + n);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movw %r9w, %ax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x15523
movl -0xc(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0x15529
movl -0x10(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $0x4, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jge 0x1555e
movl -0x20(%rbp), %eax
addl $0x4, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x84(%rbp)
jmp 0x1556b
movl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x1556b
movl -0x84(%rbp), %eax
movl %eax, -0x24(%rbp)
movzwl -0x1a(%rbp), %ecx
andl $0x8000, %ecx           # imm = 0x8000
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x85(%rbp)
je 0x15598
cmpl $0x6, -0x20(%rbp)
setge %al
movb %al, -0x85(%rbp)
movb -0x85(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x15604
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
imull $0x3, -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jge 0x155ea
imull $0x3, -0x24(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x90(%rbp)
jmp 0x155f6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x94(%rbp)
jmp 0x1560d
movl -0x24(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0xc(%rbp), %eax
subl -0x2c(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x30(%rbp)
movl -0x10(%rbp), %eax
subl -0x2c(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x34(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x38(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0xf0, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x1579a
movzwl -0x1a(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
movl %eax, -0x40(%rbp)
movl -0x38(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x15698
cmpl $0x0, -0x48(%rbp)
je 0x156a5
cmpl $0x0, -0x44(%rbp)
jne 0x156a5
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x98(%rbp)
jmp 0x156af
xorl %eax, %eax
movl %eax, -0x98(%rbp)
jmp 0x156af
movl -0x98(%rbp), %eax
movl %eax, -0x4c(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x156ed
movq 0xc3ed(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
movl -0x30(%rbp), %r8d
addl -0x2c(%rbp), %r8d
addl -0x4c(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x63f0
movzwl -0x1a(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x15722
movq 0xc3b8(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
movl -0x8(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r9d
addl -0x2c(%rbp), %r9d
addl -0x4c(%rbp), %r9d
callq 0x63f0
movzwl -0x1a(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1575d
movq 0xc383(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
subl -0x4c(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
movl -0xc(%rbp), %r8d
subl -0x30(%rbp), %r8d
addl -0x4c(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x63f0
movzwl -0x1a(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x15798
movq 0xc348(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x4c(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x10(%rbp), %r9d
subl -0x34(%rbp), %r9d
addl -0x4c(%rbp), %r9d
callq 0x63f0
jmp 0x1579a
cmpl $0x0, -0x3c(%rbp)
je 0x15b14
movzwl -0x1a(%rbp), %eax
andl $0x10, %eax
movl %eax, -0x50(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0x20, %eax
movl %eax, -0x54(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0x40, %eax
movl %eax, -0x58(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0x80, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x15899
cmpl $0x0, -0x5c(%rbp)
je 0x157eb
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0x157f5
xorl %eax, %eax
movl %eax, -0x9c(%rbp)
jmp 0x157f5
movl -0x9c(%rbp), %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x15811
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xa0(%rbp)
jmp 0x15838
cmpl $0x0, -0x5c(%rbp)
je 0x15822
movl -0x2c(%rbp), %eax
movl %eax, -0xa4(%rbp)
jmp 0x1582c
xorl %eax, %eax
movl %eax, -0xa4(%rbp)
jmp 0x1582c
movl -0xa4(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0x64(%rbp)
movq 0xc270(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
addl -0x2c(%rbp), %r8d
addl -0x60(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x63f0
movq 0xc244(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
addl -0x2c(%rbp), %r8d
addl -0x64(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x63f0
cmpl $0x0, -0x54(%rbp)
je 0x15964
cmpl $0x0, -0x50(%rbp)
je 0x158b6
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xa8(%rbp)
jmp 0x158c0
xorl %eax, %eax
movl %eax, -0xa8(%rbp)
jmp 0x158c0
movl -0xa8(%rbp), %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x158dc
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0x15903
cmpl $0x0, -0x50(%rbp)
je 0x158ed
movl -0x2c(%rbp), %eax
movl %eax, -0xb0(%rbp)
jmp 0x158f7
xorl %eax, %eax
movl %eax, -0xb0(%rbp)
jmp 0x158f7
movl -0xb0(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq 0xc1a5(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
subl -0x2c(%rbp), %edx
movl -0x8(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r9d
addl -0x2c(%rbp), %r9d
addl -0x68(%rbp), %r9d
callq 0x63f0
movq 0xc179(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
addl -0x2c(%rbp), %edx
movl -0x8(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r9d
addl -0x2c(%rbp), %r9d
addl -0x6c(%rbp), %r9d
callq 0x63f0
cmpl $0x0, -0x58(%rbp)
je 0x15a3b
cmpl $0x0, -0x54(%rbp)
je 0x15981
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xb4(%rbp)
jmp 0x1598b
xorl %eax, %eax
movl %eax, -0xb4(%rbp)
jmp 0x1598b
movl -0xb4(%rbp), %eax
movl %eax, -0x70(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x159a7
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xb8(%rbp)
jmp 0x159ce
cmpl $0x0, -0x54(%rbp)
je 0x159b8
movl -0x2c(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0x159c2
xorl %eax, %eax
movl %eax, -0xbc(%rbp)
jmp 0x159c2
movl -0xbc(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0x74(%rbp)
movq 0xc0da(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
subl -0x70(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x2c(%rbp), %ecx
movl -0xc(%rbp), %r8d
subl -0x30(%rbp), %r8d
addl -0x70(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x63f0
movq 0xc0a8(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
subl -0x74(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movl -0xc(%rbp), %r8d
subl -0x30(%rbp), %r8d
addl -0x74(%rbp), %r8d
movl -0x2c(%rbp), %r9d
callq 0x63f0
cmpl $0x0, -0x5c(%rbp)
je 0x15b12
cmpl $0x0, -0x58(%rbp)
je 0x15a58
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xc0(%rbp)
jmp 0x15a62
xorl %eax, %eax
movl %eax, -0xc0(%rbp)
jmp 0x15a62
movl -0xc0(%rbp), %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x15a7e
xorl %eax, %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xc4(%rbp)
jmp 0x15aa5
cmpl $0x0, -0x58(%rbp)
je 0x15a8f
movl -0x2c(%rbp), %eax
movl %eax, -0xc8(%rbp)
jmp 0x15a99
xorl %eax, %eax
movl %eax, -0xc8(%rbp)
jmp 0x15a99
movl -0xc8(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq 0xc003(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
addl -0x2c(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x78(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x10(%rbp), %r9d
subl -0x34(%rbp), %r9d
addl -0x78(%rbp), %r9d
callq 0x63f0
movq 0xbfd1(%rip), %rdi      # 0x21ab8
movq -0x18(%rbp), %rsi
movl -0x4(%rbp), %edx
addl -0x30(%rbp), %edx
subl -0x2c(%rbp), %edx
movl -0x8(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl -0x7c(%rbp), %ecx
movl -0x2c(%rbp), %r8d
movl -0x10(%rbp), %r9d
subl -0x34(%rbp), %r9d
addl -0x7c(%rbp), %r9d
callq 0x63f0
jmp 0x15b14
addq $0xd0, %rsp
popq %rbp
retq