// File: Stygain[P]bandwidth-monitor/src/main.cpp
// Function: assessGraphUISize()
GraphMode assessGraphUISize()
{
	int numWide = 0;
	int numTall = 0;
	if (COLS > (GRAPH_MIN_WIDTH * 4))
	{
		// Or if the screen is wide enough add the other graphs
		logger->Log("Wide enough for four\n");
		numWide = 4;
	}
	else if (COLS > (GRAPH_MIN_WIDTH * 2))
	{
		// Or if the screen is wide enough add the other graphs
		logger->Log("Wide enough for two ");
		logger->Log(std::to_string(COLS));
		logger->Log(":");
		logger->Log(std::to_string(GRAPH_MIN_WIDTH*2));
		logger->Log("\n");
		numWide = 2;
	}
	else
	{
		logger->Log("Wide enough for one ");
		logger->Log(std::to_string(COLS));
		logger->Log(":");
		logger->Log(std::to_string(GRAPH_MIN_WIDTH*2));
		logger->Log("\n");
		numWide = 1;
	}

	logger->Log("Available vertical space: ");
	logger->Log(std::to_string((LINES - ((interfaceRows.size() * 3) + 1) - 2)));
	logger->Log(":");
	logger->Log(std::to_string(GRAPH_MIN_HEIGHT));
	logger->Log("\n");
	// If the screen is tall enough, add in the other graphs
	if ((LINES - ((interfaceRows.size() * 3) + 1) - 2) > (GRAPH_MIN_HEIGHT * 4))
	{
		logger->Log("Tall enough for four\n");
		numTall = 32;
	}
	else if ((LINES - ((interfaceRows.size() * 3) + 1) - 2) > (GRAPH_MIN_HEIGHT * 2))
	{
		logger->Log("Tall enough for two\n");
		numTall = 16;
	}
	else
	{
		logger->Log("Tall enough for one\n");
		numTall = 8;
	}

	logger->Log("Values: ");
	logger->Log(std::to_string(numWide));
	logger->Log("x");
	logger->Log(std::to_string(numTall));
	logger->Log(" | ");
	logger->Log(std::to_string(numWide | numTall));
	logger->Log("\n");

	// Translate numWide and numTall to GM types
	switch (numWide | numTall)
	{
		case 4 | 8:
		case 4 | 16:
		case 4 | 32:
		{
			logger->Log("Returning 4 wide\n");
			return GM_FOUR_WIDE;
		}
		case 2 | 8:
		{
			logger->Log("Returning 2 wide\n");
			return GM_TWO_WIDE;
		}
		case 2 | 16:
		case 2 | 32:
		{
			logger->Log("Returning 2 wide 2 tall\n");
			return GM_TWO_WIDE_TWO_TALL;
		}
		case 1 | 32:
		{
			logger->Log("Returning 4 tall\n");
			return GM_FOUR_TALL;
		}
		case 1 | 16:
		{
			logger->Log("Returning 2 tall\n");
			return GM_TWO_TALL;
		}
		case 1 | 8:
		{
			logger->Log("Returning 1\n");
			return GM_ONE;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movl $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq 0x194e0(%rip), %rax     # 0x1dfc0
cmpl $0xb4, (%rax)
jle 0x4b0a
leaq 0x198d9(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11652(%rip), %rsi     # 0x1614b
callq 0x13910
movl $0x4, -0x8(%rbp)
jmp 0x4d5a
movq 0x194af(%rip), %rax     # 0x1dfc0
cmpl $0x5a, (%rax)
jle 0x4c36
leaq 0x198a7(%rip), %rax     # 0x1e3c8
movq %rax, -0x158(%rbp)
movq (%rax), %rdi
leaq 0x1162f(%rip), %rsi     # 0x16161
callq 0x13910
movq -0x158(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x150(%rbp)
movq 0x19471(%rip), %rax     # 0x1dfc0
movl (%rax), %esi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x9d40
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
callq 0x13940
jmp 0x4b76
leaq -0x30(%rbp), %rdi
callq 0x3250
leaq 0x19842(%rip), %rax     # 0x1e3c8
movq %rax, -0x170(%rbp)
movq (%rax), %rdi
leaq 0x115df(%rip), %rsi     # 0x16176
callq 0x13910
movq -0x170(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x168(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x160(%rbp)
movl $0x5a, %esi
callq 0x9d40
movq -0x168(%rbp), %rdi
movq -0x160(%rbp), %rsi
callq 0x13940
jmp 0x4bd7
leaq -0x60(%rbp), %rdi
callq 0x3250
leaq 0x197e1(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11672(%rip), %rsi     # 0x16263
callq 0x13910
movl $0x2, -0x8(%rbp)
jmp 0x4d58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3250
jmp 0x521b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3250
jmp 0x521b
leaq 0x1978b(%rip), %rax     # 0x1e3c8
movq %rax, -0x188(%rbp)
movq (%rax), %rdi
leaq 0x1152a(%rip), %rsi     # 0x16178
callq 0x13910
movq -0x188(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x180(%rbp)
movq 0x19355(%rip), %rax     # 0x1dfc0
movl (%rax), %esi
leaq -0x80(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x9d40
movq -0x180(%rbp), %rdi
movq -0x178(%rbp), %rsi
callq 0x13940
jmp 0x4c92
leaq -0x80(%rbp), %rdi
callq 0x3250
leaq 0x19726(%rip), %rax     # 0x1e3c8
movq %rax, -0x1a0(%rbp)
movq (%rax), %rdi
leaq 0x114c3(%rip), %rsi     # 0x16176
callq 0x13910
movq -0x1a0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x198(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x190(%rbp)
movl $0x5a, %esi
callq 0x9d40
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rsi
callq 0x13940
jmp 0x4cf6
leaq -0xa0(%rbp), %rdi
callq 0x3250
leaq 0x196bf(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11550(%rip), %rsi     # 0x16263
callq 0x13910
movl $0x1, -0x8(%rbp)
jmp 0x4d58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3250
jmp 0x521b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3250
jmp 0x521b
jmp 0x4d5a
leaq 0x19667(%rip), %rax     # 0x1e3c8
movq %rax, -0x1c0(%rbp)
movq (%rax), %rdi
leaq 0x1141b(%rip), %rsi     # 0x1618d
callq 0x13910
movq -0x1c0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1b0(%rbp)
movq 0x19221(%rip), %rax     # 0x1dfb0
movslq (%rax), %rax
movq %rax, -0x1b8(%rbp)
leaq 0x195b8(%rip), %rdi     # 0x1e358
callq 0x9f40
movq -0x1b8(%rbp), %rcx
leaq (%rax,%rax,2), %rax
notq %rax
leaq -0x2(%rax,%rcx), %rsi
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x9e60
movq -0x1b0(%rbp), %rdi
movq -0x1a8(%rbp), %rsi
callq 0x13940
jmp 0x4de0
leaq -0xc0(%rbp), %rdi
callq 0x3250
leaq 0x195d5(%rip), %rax     # 0x1e3c8
movq %rax, -0x1d8(%rbp)
movq (%rax), %rdi
leaq 0x11372(%rip), %rsi     # 0x16176
callq 0x13910
movq -0x1d8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
movl $0x14, %esi
callq 0x9d40
movq -0x1d0(%rbp), %rdi
movq -0x1c8(%rbp), %rsi
callq 0x13940
jmp 0x4e47
leaq -0xe0(%rbp), %rdi
callq 0x3250
leaq 0x1956e(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x113ff(%rip), %rsi     # 0x16263
callq 0x13910
movq 0x19140(%rip), %rax     # 0x1dfb0
movslq (%rax), %rax
movq %rax, -0x1e0(%rbp)
leaq 0x194d7(%rip), %rdi     # 0x1e358
callq 0x9f40
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
imulq $0x3, %rcx, %rcx
addq $0x1, %rcx
subq %rcx, %rax
subq $0x2, %rax
cmpq $0x50, %rax
jbe 0x4f01
leaq 0x1951c(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x112f2(%rip), %rsi     # 0x161a8
callq 0x13910
movl $0x20, -0xc(%rbp)
jmp 0x4f7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3250
jmp 0x521b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3250
jmp 0x521b
movq 0x190a8(%rip), %rax     # 0x1dfb0
movslq (%rax), %rax
movq %rax, -0x1e8(%rbp)
leaq 0x1943f(%rip), %rdi     # 0x1e358
callq 0x9f40
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
imulq $0x3, %rcx, %rcx
addq $0x1, %rcx
subq %rcx, %rax
subq $0x2, %rax
cmpq $0x28, %rax
jbe 0x4f5c
leaq 0x19484(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11270(%rip), %rsi     # 0x161be
callq 0x13910
movl $0x10, -0xc(%rbp)
jmp 0x4f79
leaq 0x19465(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11266(%rip), %rsi     # 0x161d3
callq 0x13910
movl $0x8, -0xc(%rbp)
jmp 0x4f7b
leaq 0x19446(%rip), %rax     # 0x1e3c8
movq %rax, -0x200(%rbp)
movq (%rax), %rdi
leaq 0x11255(%rip), %rsi     # 0x161e8
callq 0x13910
movq -0x200(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x1f8(%rbp)
movl -0x8(%rbp), %esi
leaq -0x100(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x9d40
movq -0x1f8(%rbp), %rdi
movq -0x1f0(%rbp), %rsi
callq 0x13940
jmp 0x4fd4
leaq -0x100(%rbp), %rdi
callq 0x3250
leaq 0x193e1(%rip), %rax     # 0x1e3c8
movq %rax, -0x218(%rbp)
movq (%rax), %rdi
leaq 0x111f9(%rip), %rsi     # 0x161f1
callq 0x13910
movq -0x218(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x210(%rbp)
movl -0xc(%rbp), %esi
leaq -0x120(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x9d40
movq -0x210(%rbp), %rdi
movq -0x208(%rbp), %rsi
callq 0x13940
jmp 0x5039
leaq -0x120(%rbp), %rdi
callq 0x3250
leaq 0x1937c(%rip), %rax     # 0x1e3c8
movq %rax, -0x230(%rbp)
movq (%rax), %rdi
leaq 0x11196(%rip), %rsi     # 0x161f3
callq 0x13910
movq -0x230(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x228(%rbp)
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %eax
orl %eax, %esi
leaq -0x140(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x9d40
movq -0x228(%rbp), %rdi
movq -0x220(%rbp), %rsi
callq 0x13940
jmp 0x50a3
leaq -0x140(%rbp), %rdi
callq 0x3250
leaq 0x19312(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x111a3(%rip), %rsi     # 0x16263
callq 0x13910
movl -0x8(%rbp), %eax
movl -0xc(%rbp), %ecx
orl %ecx, %eax
addl $-0x9, %eax
movl %eax, %ecx
movq %rcx, -0x238(%rbp)
subl $0x1b, %eax
ja 0x520d
movq -0x238(%rbp), %rax
leaq 0x10f14(%rip), %rcx     # 0x16004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x3250
jmp 0x521b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x3250
jmp 0x521b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x3250
jmp 0x521b
leaq 0x19271(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11096(%rip), %rsi     # 0x161f7
callq 0x13910
movl $0x3, -0x4(%rbp)
jmp 0x520f
leaq 0x1924f(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11086(%rip), %rsi     # 0x16209
callq 0x13910
movl $0x1, -0x4(%rbp)
jmp 0x520f
leaq 0x19230(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11079(%rip), %rsi     # 0x1621b
callq 0x13910
movl $0x5, -0x4(%rbp)
jmp 0x520f
leaq 0x19211(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11073(%rip), %rsi     # 0x16234
callq 0x13910
movl $0x4, -0x4(%rbp)
jmp 0x520f
leaq 0x191f2(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11066(%rip), %rsi     # 0x16246
callq 0x13910
movl $0x2, -0x4(%rbp)
jmp 0x520f
leaq 0x191d3(%rip), %rax     # 0x1e3c8
movq (%rax), %rdi
leaq 0x11059(%rip), %rsi     # 0x16258
callq 0x13910
movl $0x0, -0x4(%rbp)
jmp 0x520f
ud2
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x35c0
nopw %cs:(%rax,%rax)