// File: /workspace/github_cpp_makefile_star2_O3/SYZYGYfpga[P]brain-tools/src/smartvio-brain.cpp
// Function: printVIOStrings(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer>&, int)
int printVIOStrings (json &json_handler, int i2c_file)
{
	uint8_t temp_string[257];
	int i;
	int j = 0;

	for (i = 0; i < SVIO_NUM_PORTS; i++) {
		if (svio.ports[i].i2c_addr == 0x00) {
			// don't print anything for FPGA "ports"
			continue;
		}

		if (svio.ports[i].present == 0) {
			if (!json_handler.is_null()) {
				json_handler["port"][j] = nullptr;
			}

			// just increment the port counter for non-present ports
			j++;
			continue;
		}

		// retrieve manufacturer
		if (readMCU(i2c_file, svio.ports[i].i2c_addr,
		        0x8000 + svio.ports[i].mfr_offset, temp_string,
		        svio.ports[i].mfr_length) != 0) {
			return -1;
		}

		temp_string[svio.ports[i].mfr_length] = '\0';

		if (!json_handler.is_null()) {
			json_handler["port"][j]["manufacturer"] = std::string((char*) temp_string);
		} else {
			printf("Port 0x%X Manufacturer: %s\n", svio.ports[i].i2c_addr, temp_string);
		}

		// retrieve product name
		if (readMCU(i2c_file, svio.ports[i].i2c_addr,
		        0x8000 + svio.ports[i].product_name_offset, temp_string,
		        svio.ports[i].product_name_length) != 0) {
			return -1;
		}

		temp_string[svio.ports[i].product_name_length] = '\0';

		if (!json_handler.is_null()) {
			json_handler["port"][j]["product_name"] = std::string((char*) temp_string);
		} else {
			printf("Product Name: %s\n", temp_string);
		}

		// retrieve product model
		if (readMCU(i2c_file, svio.ports[i].i2c_addr,
		        0x8000 + svio.ports[i].product_model_offset, temp_string,
		        svio.ports[i].product_model_length) != 0) {
			return -1;
		}

		temp_string[svio.ports[i].product_model_length] = '\0';

		if (!json_handler.is_null()) {
			json_handler["port"][j]["product_model"] = std::string((char*) temp_string);
		} else {
			printf("Product Model: %s\n", temp_string);
		}

		// retrieve product version
		if (readMCU(i2c_file, svio.ports[i].i2c_addr,
		        0x8000 + svio.ports[i].product_version_offset, temp_string,
		        svio.ports[i].product_version_length) != 0) {
			return -1;
		}

		temp_string[svio.ports[i].product_version_length] = '\0';

		if (!json_handler.is_null()) {
			json_handler["port"][j]["product_version"] = std::string((char*) temp_string);
		} else {
			printf("Version: %s\n", temp_string);
		}

		// retrieve serial
		if (readMCU(i2c_file, svio.ports[i].i2c_addr,
		        0x8000 + svio.ports[i].serial_number_offset, temp_string,
		        svio.ports[i].serial_number_length) != 0) {
			return -1;
		}

		temp_string[svio.ports[i].serial_number_length] = '\0';

		if (!json_handler.is_null()) {
			json_handler["port"][j]["serial_number"] = std::string((char*) temp_string);
		} else {
			printf("Serial: %s\n", temp_string);
		}
		j++;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %esi, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0x28(%rsp), %r13
leaq 0xa708(%rip), %r12      # 0xe208
leaq 0xa0(%rsp), %rbp
xorl %ebx, %ebx
xorl %r15d, %r15d
movl 0x18(%rbx,%r12), %eax
testl %eax, %eax
je 0x417e
cmpl $0x0, 0x1c(%rbx,%r12)
je 0x3c4c
movl 0x5c(%rbx,%r12), %edx
movl $0x8000, %ecx           # imm = 0x8000
addl %ecx, %edx
movl 0x60(%rbx,%r12), %r8d
movzwl %ax, %esi
movl 0x10(%rsp), %edi
movq %rbp, %rcx
callq 0x3712
testl %eax, %eax
jne 0x4199
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
movl 0x60(%rbx,%r12), %eax
movb $0x0, 0xa0(%rsp,%rax)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
movl %r15d, 0x3c(%rsp)
movslq %r15d, %r15
je 0x3cfb
movq %r13, 0x18(%rsp)
movq %rbp, %rdi
callq 0x3110
leaq (%rsp,%rax), %rdx
addq $0xa0, %rdx
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x500e
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x4e28
movq 0x8(%rsp), %rdi
leaq 0x550d(%rip), %rsi      # 0x90ca
callq 0x4a8a
movq %rax, %rdi
movq %r15, %rsi
callq 0x4c16
movq %rax, %rdi
leaq 0x54f8(%rip), %rsi      # 0x90cf
callq 0x4a8a
movq %rax, %rbp
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x6f20
movb (%rbp), %al
movb 0x90(%rsp), %cl
movb %cl, (%rbp)
movb %al, 0x90(%rsp)
movq 0x8(%rbp), %rax
movq 0x98(%rsp), %rcx
movq %rcx, 0x8(%rbp)
movq %rax, 0x98(%rsp)
movq %rbp, %rdi
callq 0x6f20
movq %r13, %rdi
callq 0x4e06
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %r13
cmpq %r13, %rdi
je 0x3c3f
callq 0x3200
leaq 0xa0(%rsp), %rbp
jmp 0x3d11
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x417b
movq 0x8(%rsp), %r13
movl %r15d, %r14d
movb $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x6f20
movq %r15, %rdi
callq 0x6f20
movq %r13, %rdi
leaq 0x543b(%rip), %rsi      # 0x90ca
callq 0x4a8a
movslq %r14d, %rsi
movq %rax, %rdi
callq 0x4c16
movq %rax, %r15
leaq 0x40(%rsp), %r13
movq %r13, %rdi
callq 0x6f20
movb (%r15), %al
movb 0x40(%rsp), %cl
movb %cl, (%r15)
movb %al, 0x40(%rsp)
movq 0x8(%r15), %rax
movq 0x48(%rsp), %rcx
movq %rcx, 0x8(%r15)
movq %rax, 0x48(%rsp)
movq %r15, %rdi
callq 0x6f20
movq %r13, %rdi
callq 0x4e06
leaq 0xa522(%rip), %r12      # 0xe208
leaq 0xa0(%rsp), %rbp
movl %r14d, %r15d
leaq 0x28(%rsp), %r13
jmp 0x417b
movl 0x18(%rbx,%r12), %esi
leaq 0x53d5(%rip), %rdi      # 0x90dc
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3040
movzwl 0x18(%rbx,%r12), %esi
movl 0x64(%rbx,%r12), %edx
movl $0x8000, %eax           # imm = 0x8000
addl %eax, %edx
movl 0x68(%rbx,%r12), %r8d
movl 0x10(%rsp), %edi
movq %rbp, %rcx
callq 0x3712
testl %eax, %eax
jne 0x41a1
movl 0x68(%rbx,%r12), %eax
movb $0x0, 0xa0(%rsp,%rax)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x3e27
movq %r13, 0x18(%rsp)
movq %rbp, %rdi
callq 0x3110
leaq (%rsp,%rax), %rdx
addq $0xa0, %rdx
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x500e
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x4e28
movq 0x8(%rsp), %rdi
leaq 0x532f(%rip), %rsi      # 0x90ca
callq 0x4a8a
movq %rax, %rdi
movq %r15, %rsi
callq 0x4c16
movq %rax, %rdi
leaq 0x5343(%rip), %rsi      # 0x90f8
callq 0x4a8a
movq %rax, %rbp
leaq 0x80(%rsp), %r13
movq %r13, %rdi
callq 0x6f20
movb (%rbp), %al
movb 0x80(%rsp), %cl
movb %cl, (%rbp)
movb %al, 0x80(%rsp)
movq 0x8(%rbp), %rax
movq 0x88(%rsp), %rcx
movq %rcx, 0x8(%rbp)
movq %rax, 0x88(%rsp)
movq %rbp, %rdi
callq 0x6f20
movq %r13, %rdi
callq 0x4e06
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %r13
cmpq %r13, %rdi
je 0x3e1d
callq 0x3200
leaq 0xa0(%rsp), %rbp
jmp 0x3e38
leaq 0x52d7(%rip), %rdi      # 0x9105
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3040
movzwl 0x18(%rbx,%r12), %esi
movl 0x6c(%rbx,%r12), %edx
movl $0x8000, %eax           # imm = 0x8000
addl %eax, %edx
movl 0x70(%rbx,%r12), %r8d
movl 0x10(%rsp), %edi
movq %rbp, %rcx
callq 0x3712
testl %eax, %eax
jne 0x41a1
movl 0x70(%rbx,%r12), %eax
movb $0x0, 0xa0(%rsp,%rax)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x3f3c
movq %r13, 0x18(%rsp)
movq %rbp, %rdi
callq 0x3110
leaq (%rsp,%rax), %rdx
addq $0xa0, %rdx
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x500e
leaq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x4e28
movq 0x8(%rsp), %rdi
leaq 0x520b(%rip), %rsi      # 0x90ca
callq 0x4a8a
movq %rax, %rdi
movq %r15, %rsi
callq 0x4c16
movq %rax, %rdi
leaq 0x523e(%rip), %rsi      # 0x9117
callq 0x4a8a
movq %rax, %rbp
leaq 0x70(%rsp), %r13
movq %r13, %rdi
callq 0x6f20
movb (%rbp), %al
movb 0x70(%rsp), %cl
movb %cl, (%rbp)
movb %al, 0x70(%rsp)
movq 0x8(%rbp), %rax
movq 0x78(%rsp), %rcx
movq %rcx, 0x8(%rbp)
movq %rax, 0x78(%rsp)
movq %rbp, %rdi
callq 0x6f20
movq %r13, %rdi
callq 0x4e06
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %r13
cmpq %r13, %rdi
je 0x3f32
callq 0x3200
leaq 0xa0(%rsp), %rbp
jmp 0x3f4d
leaq 0x51e2(%rip), %rdi      # 0x9125
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3040
movzwl 0x18(%rbx,%r12), %esi
movl 0x74(%rbx,%r12), %edx
movl $0x8000, %eax           # imm = 0x8000
addl %eax, %edx
movl 0x78(%rbx,%r12), %r8d
movl 0x10(%rsp), %edi
movq %rbp, %rcx
callq 0x3712
testl %eax, %eax
jne 0x41a1
movl 0x78(%rbx,%r12), %eax
movb $0x0, 0xa0(%rsp,%rax)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x4051
movq %r13, 0x18(%rsp)
movq %rbp, %rdi
callq 0x3110
leaq (%rsp,%rax), %rdx
addq $0xa0, %rdx
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x500e
leaq 0x60(%rsp), %rdi
movq %r13, %rsi
callq 0x4e28
movq 0x8(%rsp), %rdi
leaq 0x50f6(%rip), %rsi      # 0x90ca
callq 0x4a8a
movq %rax, %rdi
movq %r15, %rsi
callq 0x4c16
movq %rax, %rdi
leaq 0x514a(%rip), %rsi      # 0x9138
callq 0x4a8a
movq %rax, %rbp
leaq 0x60(%rsp), %r13
movq %r13, %rdi
callq 0x6f20
movb (%rbp), %al
movb 0x60(%rsp), %cl
movb %cl, (%rbp)
movb %al, 0x60(%rsp)
movq 0x8(%rbp), %rax
movq 0x68(%rsp), %rcx
movq %rcx, 0x8(%rbp)
movq %rax, 0x68(%rsp)
movq %rbp, %rdi
callq 0x6f20
movq %r13, %rdi
callq 0x4e06
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %r13
cmpq %r13, %rdi
je 0x4047
callq 0x3200
leaq 0xa0(%rsp), %rbp
jmp 0x4062
leaq 0x50f0(%rip), %rdi      # 0x9148
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3040
movzwl 0x18(%rbx,%r12), %esi
movl 0x7c(%rbx,%r12), %edx
movl $0x8000, %eax           # imm = 0x8000
addl %eax, %edx
movl 0x80(%rbx,%r12), %r8d
movl 0x10(%rsp), %edi
movq %rbp, %rcx
callq 0x3712
testl %eax, %eax
jne 0x41a1
movl 0x80(%rbx,%r12), %eax
movb $0x0, 0xa0(%rsp,%rax)
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x4165
movq %r13, %r14
movq %r13, 0x18(%rsp)
movq %rbp, %rdi
callq 0x3110
leaq (%rsp,%rax), %rdx
addq $0xa0, %rdx
leaq 0x18(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x500e
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x4e28
movq 0x8(%rsp), %rdi
leaq 0x4fd8(%rip), %rsi      # 0x90ca
callq 0x4a8a
movq %rax, %rdi
movq %r15, %rsi
callq 0x4c16
movq %rax, %rdi
leaq 0x5049(%rip), %rsi      # 0x9155
callq 0x4a8a
movq %rax, %r15
leaq 0x50(%rsp), %r13
movq %r13, %rdi
callq 0x6f20
movb (%r15), %al
movb 0x50(%rsp), %cl
movb %cl, (%r15)
movb %al, 0x50(%rsp)
movq 0x8(%r15), %rax
movq 0x58(%rsp), %rcx
movq %rcx, 0x8(%r15)
movq %rax, 0x58(%rsp)
movq %r15, %rdi
callq 0x6f20
movq %r13, %rdi
callq 0x4e06
movq 0x18(%rsp), %rdi
movq %r14, %r13
cmpq %r14, %rdi
je 0x4176
callq 0x3200
jmp 0x4176
leaq 0x4ff7(%rip), %rdi      # 0x9163
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3040
movl 0x3c(%rsp), %r15d
incl %r15d
addq $0x6c, %rbx
cmpq $0x288, %rbx            # imm = 0x288
jne 0x3b0d
movl $0x0, 0x14(%rsp)
jmp 0x41a1
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
movl 0x14(%rsp), %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x41c7
jmp 0x41cc
jmp 0x41c7
jmp 0x41cc
jmp 0x41c7
jmp 0x41cc
jmp 0x41c7
jmp 0x41cc
movq %rax, %rbx
jmp 0x421b
movq %rax, %rbx
jmp 0x422f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x4e06
jmp 0x422f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x4216
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x4216
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x4216
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x4216
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4e06
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x422f
callq 0x3200
movq %rbx, %rdi
callq 0x3390