// File: /workspace/github_c_makefile_star2_O3/baines[P]MiniGBS/ui.c
// Function: ui_refresh
void ui_refresh(void){
	struct point {
		int16_t x, y;
	} points[OSC_W];

	for(size_t i = 0; i < OSC_W; ++i){
		points[i].x = i;
	}

	const int off_start = OSC_W / 2;
	const int off_end   = OSC_SAMPLES - off_start;
	const int height    = 120;

	x11_draw_begin();

	for(size_t i = 0; i < 4; ++i){
		struct osc_chan* c = osc_chans + i;

		const float y_mid = height / 2 + height * i;
		const ssize_t off = i == 3 ? OSC_SAMPLES - OSC_W : osc_find_transition(c->samples + off_start, c->samples + off_end);

		if(off != -1){
			for(size_t j = 0; j < OSC_W; ++j){
				points[j].y = y_mid + c->samples[j+off] * height;
			}
			x11_draw_lines((int16_t*)&points, OSC_W*2);
		}
	}

	x11_draw_end();
	if(cfg.hide_ui) return;

	ui_msg_draw();
	refresh();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xda8, %rsp            # imm = 0xDA8
movdqa 0x2925(%rip), %xmm0     # 0xd4d0
movdqa 0x292d(%rip), %xmm1     # 0xd4e0
movdqa 0x2935(%rip), %xmm2     # 0xd4f0
movdqa 0x293d(%rip), %xmm3     # 0xd500
xorl %eax, %eax
movdqa 0x2943(%rip), %xmm6     # 0xd510
pshufd $0xa0, %xmm6, %xmm4     # xmm4 = xmm6[0,0,2,2]
movdqa 0x2946(%rip), %xmm5     # 0xd520
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
movdqa 0x2949(%rip), %xmm7     # 0xd530
movdqa %xmm3, %xmm8
pxor %xmm5, %xmm8
pshufd $0xa0, %xmm8, %xmm9     # xmm9 = xmm8[0,0,2,2]
movdqa %xmm4, %xmm10
pcmpgtd %xmm9, %xmm10
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pcmpeqd %xmm6, %xmm8
pand %xmm10, %xmm8
pshuflw $0xe8, %xmm8, %xmm9     # xmm9 = xmm8[0,2,2,3,4,5,6,7]
packssdw %xmm9, %xmm9
movd %xmm9, %ecx
testb $0x1, %cl
je 0xac2b
movw %ax, 0x50(%rsp,%rax,4)
packssdw %xmm8, %xmm8
packssdw %xmm8, %xmm8
movd %xmm8, %ecx
shrl $0x10, %ecx
testb $0x1, %cl
je 0xac4a
leal 0x1(%rax), %ecx
movw %cx, 0x54(%rsp,%rax,4)
movdqa %xmm2, %xmm8
pxor %xmm5, %xmm8
pshufd $0xa0, %xmm8, %xmm9     # xmm9 = xmm8[0,0,2,2]
movdqa %xmm4, %xmm10
pcmpgtd %xmm9, %xmm10
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pcmpeqd %xmm6, %xmm8
pand %xmm10, %xmm8
packssdw %xmm8, %xmm9
packssdw %xmm9, %xmm9
pextrw $0x2, %xmm9, %ecx
testb $0x1, %cl
je 0xac91
leal 0x2(%rax), %ecx
movw %cx, 0x58(%rsp,%rax,4)
pshufhw $0x84, %xmm8, %xmm8     # xmm8 = xmm8[0,1,2,3,4,5,4,6]
packssdw %xmm8, %xmm8
pextrw $0x3, %xmm8, %ecx
testb $0x1, %cl
je 0xacaf
leal 0x3(%rax), %ecx
movw %cx, 0x5c(%rsp,%rax,4)
movdqa %xmm1, %xmm8
pxor %xmm5, %xmm8
pshufd $0xa0, %xmm8, %xmm9     # xmm9 = xmm8[0,0,2,2]
movdqa %xmm4, %xmm10
pcmpgtd %xmm9, %xmm10
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pcmpeqd %xmm6, %xmm8
pand %xmm10, %xmm8
pshuflw $0xe8, %xmm8, %xmm9     # xmm9 = xmm8[0,2,2,3,4,5,6,7]
packssdw %xmm9, %xmm9
pextrw $0x4, %xmm9, %ecx
testb $0x1, %cl
je 0xacf7
leal 0x4(%rax), %ecx
movw %cx, 0x60(%rsp,%rax,4)
packssdw %xmm8, %xmm8
packssdw %xmm8, %xmm8
pextrw $0x5, %xmm8, %ecx
testb $0x1, %cl
je 0xad14
leal 0x5(%rax), %ecx
movw %cx, 0x64(%rsp,%rax,4)
movdqa %xmm0, %xmm8
pxor %xmm5, %xmm8
pshufd $0xa0, %xmm8, %xmm9     # xmm9 = xmm8[0,0,2,2]
movdqa %xmm4, %xmm10
pcmpgtd %xmm9, %xmm10
pshufd $0xf5, %xmm8, %xmm8     # xmm8 = xmm8[1,1,3,3]
pcmpeqd %xmm6, %xmm8
pand %xmm10, %xmm8
packssdw %xmm8, %xmm9
packssdw %xmm9, %xmm9
pextrw $0x6, %xmm9, %ecx
testb $0x1, %cl
je 0xad5b
leal 0x6(%rax), %ecx
movw %cx, 0x68(%rsp,%rax,4)
pshufhw $0x84, %xmm8, %xmm8     # xmm8 = xmm8[0,1,2,3,4,5,4,6]
packssdw %xmm8, %xmm8
pextrw $0x7, %xmm8, %ecx
testb $0x1, %cl
je 0xad79
leal 0x7(%rax), %ecx
movw %cx, 0x6c(%rsp,%rax,4)
addq $0x8, %rax
paddq %xmm7, %xmm3
paddq %xmm7, %xmm2
paddq %xmm7, %xmm1
paddq %xmm7, %xmm0
cmpq $0x358, %rax            # imm = 0x358
jne 0xabe7
callq 0xb819
leaq 0x798b(%rip), %rbp      # 0x12730
xorl %r15d, %r15d
movss 0x270c(%rip), %xmm2     # 0xd4bc
movl $0x1900, %r12d          # imm = 0x1900
leaq 0x10(%rsp), %r13
movss 0x26ed(%rip), %xmm3     # 0xd4b0
movss 0x26e9(%rip), %xmm4     # 0xd4b4
movq %r13, %rax
negq %rax
movq %rax, 0x8(%rsp)
movq %rbp, %r14
xorl %ebx, %ebx
movl $0x2ea, %edx            # imm = 0x2EA
cmpq $0x3, %rbx
je 0xaea7
imulq $0x1900, %rbx, %rax     # imm = 0x1900
addq %rbp, %rax
addq $0x6ac, %rax            # imm = 0x6AC
movl $0x6b0, %esi            # imm = 0x6B0
movq %r13, %rdx
leaq (%r15,%rsi), %rcx
movss (%rbp,%rcx), %xmm0
ucomiss %xmm3, %xmm0
ja 0xae23
leaq 0x4(%rsi), %rcx
cmpq $0x124c, %rsi           # imm = 0x124C
movq %rcx, %rsi
jl 0xae02
jmp 0xae5e
ucomiss (%r14,%rsi), %xmm4
ja 0xae3c
leaq 0x4(%rsi), %rcx
cmpq $0x124c, %rsi           # imm = 0x124C
movq %rcx, %rsi
jl 0xae23
jmp 0xae5e
leaq (%r14,%rsi), %rdi
leaq 0x8(%rdx), %rcx
movq %rdi, (%rdx)
movq 0x8(%rsp), %rdi
addq %rdx, %rdi
addq $0x8, %rdi
movq %rcx, %rdx
cmpq $0x40, %rdi
jb 0xae02
jmp 0xae61
movq %rdx, %rcx
cmpq %rcx, %r13
jae 0xaf06
movq $-0x1, %rdx
movq %r13, %rsi
movss 0x263c(%rip), %xmm0     # 0xd4b8
movq (%rsi), %rdi
movss (%rdi), %xmm1
subq %rax, %rdi
sarq $0x2, %rdi
ucomiss %xmm1, %xmm0
cmovaq %rdi, %rdx
minss %xmm0, %xmm1
addq $0x8, %rsi
movaps %xmm1, %xmm0
cmpq %rcx, %rsi
jb 0xae7c
cmpq $-0x1, %rdx
je 0xaf06
imulq $0x78, %rbx, %rax
addq $0x3c, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
leaq (%r14,%rdx,4), %rax
xorl %ecx, %ecx
movss (%rax,%rcx,4), %xmm1
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %edx
movw %dx, 0x52(%rsp,%rcx,4)
incq %rcx
cmpq $0x356, %rcx            # imm = 0x356
jne 0xaebd
movl $0x6ac, %esi            # imm = 0x6AC
leaq 0x50(%rsp), %rdi
callq 0xb85c
movss 0x25c6(%rip), %xmm2     # 0xd4bc
movss 0x25b2(%rip), %xmm3     # 0xd4b0
movss 0x25ae(%rip), %xmm4     # 0xd4b4
incq %rbx
addq %r12, %r15
addq %r12, %r14
cmpq $0x4, %rbx
jne 0xaddb
callq 0xb89a
leaq 0x6523(%rip), %rax      # 0x11448
cmpb $0x0, 0x5(%rax)
jne 0xb00b
cmpl $0x0, 0x772a(%rip)      # 0x12660
jle 0xaf98
movq 0x6091(%rip), %rbx      # 0x10fd0
movq (%rbx), %rdi
movl 0x2c(%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x5210
movl 0x770c(%rip), %eax      # 0x12660
movl %eax, %ecx
decl %ecx
movl %ecx, 0x7702(%rip)      # 0x12660
je 0xaff4
cmpl $0x11, %eax
jl 0xaf78
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52b0
leaq 0x14e8(%rip), %rdi      # 0xc467
leaq 0x765a(%rip), %rsi      # 0x125e0
xorl %eax, %eax
callq 0x54d0
cmpl $0x10, 0x76cc(%rip)     # 0x12660
jge 0xafe3
jmp 0xaffc
cmpb $0x1, 0xdb91(%rip)      # 0x18b30
jne 0xaffc
movq 0x6028(%rip), %rbx      # 0x10fd0
movq (%rbx), %rdi
movl 0x2c(%rax), %esi
decl %esi
xorl %edx, %edx
callq 0x5210
movq (%rbx), %rdi
callq 0x5220
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52b0
leaq 0x27f6(%rip), %rdi      # 0xd7cb
leaq 0xdb64(%rip), %rsi      # 0x18b40
xorl %eax, %eax
callq 0x54d0
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5590
jmp 0xaffc
movq (%rbx), %rdi
callq 0x5220
movq 0x5fcd(%rip), %rax      # 0x10fd0
movq (%rax), %rdi
callq 0x52c0
addq $0xda8, %rsp            # imm = 0xDA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq