// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %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
movb $0x1, %bpl
leaq 0x252e(%rip), %r12      # 0xc590
leaq 0x10(%rsp), %r14
leaq 0x26b0(%rip), %r15      # 0xc71e
xorl %r13d, %r13d
leaq (,%r13,4), %rax
addq %r13, %rax
leaq (%rax,%rax,4), %rsi
addq %r12, %rsi
movq %r14, %rdi
callq 0x3280
movl 0x20(%rbx), %eax
cmpq %rax, %r13
jne 0xa0a2
movq (%rbx), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x3180
movq (%rbx), %rdi
leal 0x1(%r13), %esi
movl $0x1, %edx
movq %r15, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x30b0
movl 0x20(%rbx), %eax
cmpq %rax, %r13
jne 0xa0d2
movq (%rbx), %rdi
movl $0x400, %esi            # imm = 0x400
xorl %edx, %edx
callq 0x33b0
movl $0x1, %r13d
testb $0x1, %bpl
movl $0x0, %ebp
jne 0xa071
movq (%rbx), %rdi
movq 0x18(%rbx), %r8
addq $0x78, %r8
leaq 0x2622(%rip), %rcx      # 0xc717
movl $0x1, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq 0x18(%rbx), %rax
cmpb $0x0, 0x8c(%rax)
je 0xa185
movq (%rbx), %rdi
movl 0x90(%rax), %r8d
leaq 0x25fd(%rip), %rcx      # 0xc721
movl $0x2, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
movq 0x18(%rbx), %rax
movl 0x94(%rax), %r8d
leaq 0x25e8(%rip), %rcx      # 0xc732
movl $0x3, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
movq 0x18(%rbx), %rax
movl 0x98(%rax), %r8d
leaq 0x25d4(%rip), %rcx      # 0xc744
movl $0x4, %esi
movl $0x19, %edx
xorl %eax, %eax
callq 0x30b0
movq 0x18(%rbx), %rax
movb $0x0, 0xe(%rsp)
movw $0x42, 0xc(%rsp)
movl 0x9c(%rax), %r8d
cmpl $0x3e9, %r8d            # imm = 0x3E9
jl 0xa202
movl %r8d, %ecx
movb $0x0, 0xe(%rsp)
movw $0x424b, 0xc(%rsp)      # imm = 0x424B
cmpl $0xf4628, %r8d          # imm = 0xF4628
jb 0xa1f2
imulq $0x431bde83, %rcx, %rcx # imm = 0x431BDE83
shrq $0x32, %rcx
movb $0x0, 0xe(%rsp)
movw $0x424d, 0xc(%rsp)      # imm = 0x424D
cmpl $0x3baa0c40, %r8d       # imm = 0x3BAA0C40
jb 0xa1ff
imull $0x20c5, %ecx, %r8d     # imm = 0x20C5
shrl $0x17, %r8d
movb $0x0, 0xe(%rsp)
movw $0x4247, 0xc(%rsp)      # imm = 0x4247
jmp 0xa202
imulq $0x10624dd3, %rcx, %r8  # imm = 0x10624DD3
shrq $0x26, %r8
jmp 0xa202
movl %ecx, %r8d
movb $0x0, 0xa(%rsp)
movw $0x42, 0x8(%rsp)
movl 0xa0(%rax), %r14d
cmpl $0x3e9, %r14d           # imm = 0x3E9
jl 0xa27f
movl %r14d, %eax
movb $0x0, 0xa(%rsp)
movw $0x424b, 0x8(%rsp)      # imm = 0x424B
cmpl $0xf4628, %r14d         # imm = 0xF4628
jb 0xa26f
imulq $0x431bde83, %rax, %rax # imm = 0x431BDE83
shrq $0x32, %rax
movb $0x0, 0xa(%rsp)
movw $0x424d, 0x8(%rsp)      # imm = 0x424D
cmpl $0x3baa0c40, %r14d      # imm = 0x3BAA0C40
jb 0xa27c
imull $0x20c5, %eax, %r14d    # imm = 0x20C5
shrl $0x17, %r14d
movb $0x0, 0xa(%rsp)
movw $0x4247, 0x8(%rsp)      # imm = 0x4247
jmp 0xa27f
imulq $0x10624dd3, %rax, %r14 # imm = 0x10624DD3
shrq $0x26, %r14
jmp 0xa27f
movl %eax, %r14d
movq (%rbx), %rdi
leaq 0x24cd(%rip), %rcx      # 0xc756
leaq 0xc(%rsp), %r9
movl $0x1, %esi
movl $0x32, %edx
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
leaq 0x24bb(%rip), %rcx      # 0xc764
leaq 0x8(%rsp), %r9
movl $0x2, %esi
movl $0x32, %edx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x30b0
movq (%rbx), %rdi
callq 0x3310
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop