// File: /workspace/github_c_makefile_star2_O0/kaiserschmarrn0[P]mywm/rounded.c
// Function: rounded_corners
void rounded_corners(window *win) {
	int w = win->geom[GEOM_W];
	int h = win->geom[GEOM_H];

	xcb_rectangle_t win_rects[2 * RAD + 1];

	int half_rect_count = rect_count / 2;

	int i = 0;
	for (; i < half_rect_count; i++) {
		win_rects[i].x = rect_mask[i].x;
		win_rects[i].y = rect_mask[i].y;
		win_rects[i].width = w - 2 * rect_mask[i].x;
		win_rects[i].height = rect_mask[i].height;
	}

	win_rects[i].x = 0;
	win_rects[i].y = corner_height;
	win_rects[i].width = w;
	win_rects[i].height = h - 2 * corner_height;
	
	i++;

	for (; i < rect_count; i++) {
		win_rects[i].x = rect_mask[i].x;
		win_rects[i].y = h - corner_height + rect_mask[i].y;
		win_rects[i].width = w - 2 * rect_mask[i].x;
		win_rects[i].height = rect_mask[i].height;
	}

	xcb_shape_rectangles(conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
			XCB_CLIP_ORDERING_Y_SORTED, win->windows[WIN_PARENT], 0, 0, rect_count,
			win_rects);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x110(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x114(%rax), %eax
movl %eax, -0x10(%rbp)
movl 0xab44(%rip), %eax      # 0x10350
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x589d
movslq -0x48(%rbp), %rcx
leaq 0xb09f(%rip), %rax      # 0x108d0
movw (%rax,%rcx,8), %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x40(%rbp,%rax,8)
movslq -0x48(%rbp), %rcx
leaq 0xb087(%rip), %rax      # 0x108d0
movw 0x2(%rax,%rcx,8), %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3e(%rbp,%rax,8)
movl -0xc(%rbp), %eax
movslq -0x48(%rbp), %rdx
leaq 0xb06b(%rip), %rcx      # 0x108d0
movswl (%rcx,%rdx,8), %ecx
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3c(%rbp,%rax,8)
movslq -0x48(%rbp), %rcx
leaq 0xb04c(%rip), %rax      # 0x108d0
movw 0x6(%rax,%rcx,8), %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3a(%rbp,%rax,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x581e
movslq -0x48(%rbp), %rax
movw $0x0, -0x40(%rbp,%rax,8)
movl 0xb042(%rip), %eax      # 0x108f0
movw %ax, %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3e(%rbp,%rax,8)
movl -0xc(%rbp), %eax
movw %ax, %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3c(%rbp,%rax,8)
movl -0x10(%rbp), %eax
movl 0xb01e(%rip), %ecx      # 0x108f0
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3a(%rbp,%rax,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl 0xaa5c(%rip), %eax      # 0x10350
jge 0x5982
movslq -0x48(%rbp), %rcx
leaq 0xafcb(%rip), %rax      # 0x108d0
movw (%rax,%rcx,8), %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x40(%rbp,%rax,8)
movl -0x10(%rbp), %eax
subl 0xafd5(%rip), %eax      # 0x108f0
movslq -0x48(%rbp), %rdx
leaq 0xafaa(%rip), %rcx      # 0x108d0
movswl 0x2(%rcx,%rdx,8), %ecx
addl %ecx, %eax
movw %ax, %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3e(%rbp,%rax,8)
movl -0xc(%rbp), %eax
movslq -0x48(%rbp), %rdx
leaq 0xaf89(%rip), %rcx      # 0x108d0
movswl (%rcx,%rdx,8), %ecx
shll %ecx
subl %ecx, %eax
movw %ax, %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3c(%rbp,%rax,8)
movslq -0x48(%rbp), %rcx
leaq 0xaf6a(%rip), %rax      # 0x108d0
movw 0x6(%rax,%rcx,8), %cx
movslq -0x48(%rbp), %rax
movw %cx, -0x3a(%rbp,%rax,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x58eb
leaq 0xaabf(%rip), %rax      # 0x10448
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl 0xd0(%rax), %r8d
movl 0xa9b2(%rip), %r10d     # 0x10350
leaq -0x40(%rbp), %rax
xorl %r9d, %r9d
movl $0x1, %ecx
movl %r9d, %esi
movl %r9d, %edx
movl $0x0, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x3250
movl %eax, -0x4c(%rbp)
addq $0x70, %rsp
popq %rbp
retq
nop