// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x3050
movq (%rbx), %rdi
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x31c0
pushq $0x2
popq %r15
leaq 0x20(%rsp), %r14
pushq $0x1
popq %rbp
xorl %r12d, %r12d
subl $0x1, %r15d
jb 0x93b1
movl %r12d, %edi
movq %r14, %rsi
callq 0x88e0
cmpl 0x20(%rbx), %r12d
jne 0x9376
movq (%rbx), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x3180
movq (%rbx), %rdi
leal 0x1(%r12), %r13d
movl %r13d, %esi
movl %ebp, %edx
leaq 0x2394(%rip), %rcx      # 0xb71e
movq %r14, %r8
xorl %eax, %eax
callq 0x30b0
cmpl 0x20(%rbx), %r12d
movl %r13d, %r12d
jne 0x9350
movq (%rbx), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x33a0
movl %r13d, %r12d
jmp 0x9350
movq (%rbx), %rdi
movq 0x18(%rbx), %r8
addq $0x78, %r8
leaq 0x2354(%rip), %rcx      # 0xb717
pushq $0x1
popq %rsi
pushq $0x19
popq %rdx
xorl %eax, %eax
callq 0x30b0
movq 0x18(%rbx), %rcx
cmpb $0x0, 0x8c(%rcx)
je 0x9443
movq (%rbx), %rdi
movl 0x90(%rcx), %r8d
leaq 0x2333(%rip), %rcx      # 0xb721
pushq $0x2
popq %rsi
pushq $0x19
popq %rbp
movl %ebp, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
movq 0x18(%rbx), %rax
movl 0x94(%rax), %r8d
leaq 0x2320(%rip), %rcx      # 0xb732
pushq $0x3
popq %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
movq 0x18(%rbx), %rax
movl 0x98(%rax), %r8d
leaq 0x2311(%rip), %rcx      # 0xb744
pushq $0x4
popq %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x30b0
movq 0x18(%rbx), %rcx
movb $0x0, 0x1e(%rsp)
movw $0x42, 0x1c(%rsp)
movl 0x9c(%rcx), %r8d
cmpl $0x3e9, %r8d            # imm = 0x3E9
jl 0x94bf
movl $0x3e8, %esi            # imm = 0x3E8
movl %r8d, %eax
xorl %edx, %edx
divl %esi
movb $0x0, 0x1e(%rsp)
movw $0x424b, 0x1c(%rsp)     # imm = 0x424B
cmpl $0xf4628, %r8d          # imm = 0xF4628
jb 0x94bc
movl $0xf4240, %esi          # imm = 0xF4240
movl %r8d, %eax
xorl %edx, %edx
divl %esi
movb $0x0, 0x1e(%rsp)
movw $0x424d, 0x1c(%rsp)     # imm = 0x424D
cmpl $0x3baa0c40, %r8d       # imm = 0x3BAA0C40
jb 0x94bc
movw $0x3e8, %si             # imm = 0x3E8
xorl %edx, %edx
divw %si
movzwl %ax, %r8d
movb $0x0, 0x1e(%rsp)
movw $0x4247, 0x1c(%rsp)     # imm = 0x4247
jmp 0x94bf
movl %eax, %r8d
movb $0x0, 0x1a(%rsp)
movw $0x42, 0x18(%rsp)
movl 0xa0(%rcx), %ebp
cmpl $0x3e9, %ebp            # imm = 0x3E9
jl 0x9533
movl $0x3e8, %ecx            # imm = 0x3E8
movl %ebp, %eax
xorl %edx, %edx
divl %ecx
movb $0x0, 0x1a(%rsp)
movw $0x424b, 0x18(%rsp)     # imm = 0x424B
cmpl $0xf4628, %ebp          # imm = 0xF4628
jb 0x9531
movl $0xf4240, %ecx          # imm = 0xF4240
movl %ebp, %eax
xorl %edx, %edx
divl %ecx
movb $0x0, 0x1a(%rsp)
movw $0x424d, 0x18(%rsp)     # imm = 0x424D
cmpl $0x3baa0c40, %ebp       # imm = 0x3BAA0C40
jb 0x9531
movw $0x3e8, %cx             # imm = 0x3E8
xorl %edx, %edx
divw %cx
movzwl %ax, %ebp
movb $0x0, 0x1a(%rsp)
movw $0x4247, 0x18(%rsp)     # imm = 0x4247
jmp 0x9533
movl %eax, %ebp
movq (%rbx), %rdi
leaq 0x2219(%rip), %rcx      # 0xb756
pushq $0x1
popq %rsi
pushq $0x32
popq %r14
leaq 0x1c(%rsp), %r9
movl %r14d, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
leaq 0x2207(%rip), %rcx      # 0xb764
pushq $0x2
popq %rsi
leaq 0x18(%rsp), %r9
movl %r14d, %edx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
callq 0x3310
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop