// File: /workspace/github_cpp_makefile_star2_O1/Stygain[P]bandwidth-monitor/src/interface.cpp
// Function: InterfaceDetailWindow::Update()
void InterfaceDetailWindow::Update()
{
	werase(this->win);
	wborder(this->win, 0, 0, 0, 0, 0, 0, 0, 0);

	char interfaceDetailOptionString[interfaceDetailOptionStringSize];
	for (int i = 0; i < IDO_END; ++i)
	{
		getInterfaceDetailOptionString((InterfaceDetailOption)i, interfaceDetailOptionString);
		if (i == this->activeItem)
		{
			wattron(this->win, COLOR_PAIR(HEADER_ACTIVE_COLOR));
		}
		mvwprintw(this->win, i + 1, 1, "%s", interfaceDetailOptionString);
		if (i == this->activeItem)
		{
			wattroff(this->win, COLOR_PAIR(HEADER_ACTIVE_COLOR));
		}
	}
	// TODO get max width of IDO strings
	mvwprintw(this->win, 1, 25, "State: %s", this->interface->operstate);

	if (this->interface->wireless)
	{
		mvwprintw(this->win, 2, 25, "Link Quality: %d", this->interface->linkQual);
		mvwprintw(this->win, 3, 25, "Level Quality: %d", this->interface->levelQual);
		mvwprintw(this->win, 4, 25, "Noise Quality: %d", this->interface->noiseQual);
	}

	char r_bpsUnit[3] = "B";
	int r_bps = this->interface->r_bps;
	if (r_bps > 1000)
	{
		r_bps = (int)(r_bps / 1000);
		strcpy(r_bpsUnit, "KB");
	}
	if (r_bps > 1000)
	{
		r_bps = (int)(r_bps / 1000);
		strcpy(r_bpsUnit, "MB");
	}
	if (r_bps > 1000)
	{
		r_bps = (int)(r_bps / 1000);
		strcpy(r_bpsUnit, "GB");
	}

	char t_bpsUnit[3] = "B";
	int t_bps = this->interface->t_bps;
	if (t_bps > 1000)
	{
		t_bps = (int)(t_bps / 1000);
		strcpy(t_bpsUnit, "KB");
	}
	if (t_bps > 1000)
	{
		t_bps = (int)(t_bps / 1000);
		strcpy(t_bpsUnit, "MB");
	}
	if (t_bps > 1000)
	{
		t_bps = (int)(t_bps / 1000);
		strcpy(t_bpsUnit, "GB");
	}
	mvwprintw(this->win, 1, 50, "Recv: %d %sps", r_bps, r_bpsUnit);
	mvwprintw(this->win, 2, 50, "Send: %d %sps", t_bps, t_bpsUnit);

	wrefresh(this->win);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3050
movq (%rbx), %rdi
subq $0x8, %rsp
xorl %eax, %eax
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %rax
pushq %rax
callq 0x31c0
addq $0x20, %rsp
leaq 0x24b8(%rip), %r14      # 0xc580
leaq 0x10(%rsp), %r15
leaq 0x263a(%rip), %r12      # 0xc70e
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
callq 0x3280
movl 0x20(%rbx), %eax
cmpq %rax, %r13
jne 0xa0f9
movq (%rbx), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x3180
movq (%rbx), %rdi
leal 0x1(%r13), %esi
movl $0x1, %edx
movq %r12, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x30b0
movl 0x20(%rbx), %eax
cmpq %rax, %r13
jne 0xa129
movq (%rbx), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x33b0
addq $0x19, %r14
leaq 0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
je 0xa0d7
movq (%rbx), %rdi
movq 0x18(%rbx), %r8
addq $0x78, %r8
leaq 0x25bc(%rip), %rcx      # 0xc707
movl $0x1, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq 0x18(%rbx), %rax
cmpb $0x0, 0x8c(%rax)
je 0xa1d7
movq (%rbx), %rdi
movl 0x90(%rax), %r8d
leaq 0x2597(%rip), %rcx      # 0xc711
movl $0x2, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
movq 0x18(%rbx), %rax
movl 0x94(%rax), %r8d
leaq 0x2582(%rip), %rcx      # 0xc722
movl $0x3, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
movq 0x18(%rbx), %rax
movl 0x98(%rax), %r8d
leaq 0x256e(%rip), %rcx      # 0xc734
movl $0x4, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movb $0x0, 0xe(%rsp)
movw $0x42, 0xc(%rsp)
movq 0x18(%rbx), %rax
movl 0x9c(%rax), %r8d
cmpl $0x3e9, %r8d            # imm = 0x3E9
jl 0xa211
movl %r8d, %ecx
imulq $0x10624dd3, %rcx, %r8  # imm = 0x10624DD3
shrq $0x26, %r8
movb $0x0, 0xe(%rsp)
movw $0x424b, 0xc(%rsp)      # imm = 0x424B
cmpl $0x3e9, %r8d            # imm = 0x3E9
jl 0xa234
movl %r8d, %ecx
imulq $0x10624dd3, %rcx, %r8  # imm = 0x10624DD3
shrq $0x26, %r8
movb $0x0, 0xe(%rsp)
movw $0x424d, 0xc(%rsp)      # imm = 0x424D
cmpl $0x3e9, %r8d            # imm = 0x3E9
jl 0xa257
movl %r8d, %ecx
imulq $0x10624dd3, %rcx, %r8  # imm = 0x10624DD3
shrq $0x26, %r8
movb $0x0, 0xe(%rsp)
movw $0x4247, 0xc(%rsp)      # imm = 0x4247
movb $0x0, 0xa(%rsp)
movw $0x42, 0x8(%rsp)
movl 0xa0(%rax), %r14d
cmpl $0x3e9, %r14d           # imm = 0x3E9
jl 0xa28d
movl %r14d, %eax
imulq $0x10624dd3, %rax, %r14 # imm = 0x10624DD3
shrq $0x26, %r14
movb $0x0, 0xa(%rsp)
movw $0x424b, 0x8(%rsp)      # imm = 0x424B
cmpl $0x3e9, %r14d           # imm = 0x3E9
jl 0xa2b0
movl %r14d, %eax
imulq $0x10624dd3, %rax, %r14 # imm = 0x10624DD3
shrq $0x26, %r14
movb $0x0, 0xa(%rsp)
movw $0x424d, 0x8(%rsp)      # imm = 0x424D
cmpl $0x3e9, %r14d           # imm = 0x3E9
jl 0xa2d3
movl %r14d, %eax
imulq $0x10624dd3, %rax, %r14 # imm = 0x10624DD3
shrq $0x26, %r14
movb $0x0, 0xa(%rsp)
movw $0x4247, 0x8(%rsp)      # imm = 0x4247
movq (%rbx), %rdi
leaq 0x2469(%rip), %rcx      # 0xc746
leaq 0xc(%rsp), %r9
movl $0x1, %esi
movl $0x32, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
leaq 0x2457(%rip), %rcx      # 0xc754
leaq 0x8(%rsp), %r9
movl $0x2, %esi
movl $0x32, %edx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
callq 0x3310
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq