// File: mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: GenerateSIROutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string GenerateSIROutput (string line)
{
		istringstream iss(line);
		string sub, str;
		int n, k;

		// Scarta nome comando
		iss >> sub;
		// Memorizza dimensione dati, utilizzabile per verifica
		iss >> n;
		// Scarta parametro
		iss >> sub;
		// Prende dati in esadecimale tra parentesi
		iss >> sub;

		// Preleva parte tra parentesi
		string hexval = sub.substr(1,2);
		// Converte stringa esadecimale in stringa binaria
		string binval = hexstrToBinstr(hexval);

		// Inserisce parte iniziale comune per tutte le SIR
		str += "!!**";
		
		// Sostituisce '.' e ',' a 0 e 1
		for (k=binval.length()-1; k>binval.length()-n; k--)
		{
			if (binval[k]=='0') 
				str += '.';
			else if(binval[k]=='1') 
				str += ',';
		}

		// Sostituisce l'ultimo bit con ':' o con ';'
		if (binval[k]=='0') 
			str += ':';
        else if (binval[k]=='1') 
			str += ';';

		// Inserisce parte finale comune per tutte le SIR
		str += "!*";
		
		return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x248(%rbp)
movq %rdi, %rax
movq %rax, -0x250(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x240(%rbp)
movl $0x8, %edx
callq 0x3460
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x33a0
movq -0x248(%rbp), %rdi
movb $0x0, -0x1b1(%rbp)
callq 0x33a0
movq -0x240(%rbp), %rdi
movq -0x238(%rbp), %rsi
callq 0x3370
jmp 0x8257
leaq -0x190(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x3180
jmp 0x826c
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3370
jmp 0x8281
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3370
jmp 0x8296
leaq -0x1f0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
movl $0x1, %edx
movl $0x2, %ecx
callq 0x32b0
jmp 0x82b5
leaq -0x230(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x30e0
jmp 0x82ca
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x8e90
jmp 0x82df
leaq -0x230(%rbp), %rdi
callq 0x3190
movq -0x248(%rbp), %rdi
leaq 0x248f(%rip), %rsi      # 0xa788
callq 0x3270
jmp 0x8300
leaq -0x210(%rbp), %rdi
callq 0x3410
subq $0x1, %rax
movl %eax, -0x1bc(%rbp)
movslq -0x1bc(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3410
movq %rax, %rcx
movq -0x258(%rbp), %rax
movslq -0x1b8(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jbe 0x8460
movslq -0x1bc(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x3540
movq %rax, -0x260(%rbp)
jmp 0x8369
movq -0x260(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x8408
movq -0x248(%rbp), %rdi
movl $0x2e, %esi
callq 0x31a0
jmp 0x838f
jmp 0x844a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x8563
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
jmp 0x8521
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3190
jmp 0x8521
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3190
jmp 0x8521
movslq -0x1bc(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x3540
movq %rax, -0x268(%rbp)
jmp 0x8424
movq -0x268(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x8448
movq -0x248(%rbp), %rdi
movl $0x2c, %esi
callq 0x31a0
jmp 0x8446
jmp 0x8448
jmp 0x844a
jmp 0x844c
movl -0x1bc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x8316
movslq -0x1bc(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x3540
movq %rax, -0x270(%rbp)
jmp 0x847c
movq -0x270(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x84a0
movq -0x248(%rbp), %rdi
movl $0x3a, %esi
callq 0x31a0
jmp 0x849e
jmp 0x84e2
movslq -0x1bc(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x3540
movq %rax, -0x278(%rbp)
jmp 0x84bc
movq -0x278(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x84e0
movq -0x248(%rbp), %rdi
movl $0x3b, %esi
callq 0x31a0
jmp 0x84de
jmp 0x84e0
jmp 0x84e2
movq -0x248(%rbp), %rdi
leaq 0x22a8(%rip), %rsi      # 0xa798
callq 0x3270
jmp 0x84f7
movb $0x1, -0x1b1(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x3190
leaq -0x1f0(%rbp), %rdi
callq 0x3190
testb $0x1, -0x1b1(%rbp)
jne 0x853b
jmp 0x852f
leaq -0x1f0(%rbp), %rdi
callq 0x3190
jmp 0x8563
movq -0x248(%rbp), %rdi
callq 0x3190
leaq -0x1b0(%rbp), %rdi
callq 0x3190
leaq -0x190(%rbp), %rdi
callq 0x3100
movq -0x250(%rbp), %rax
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x248(%rbp), %rdi
callq 0x3190
leaq -0x1b0(%rbp), %rdi
callq 0x3190
leaq -0x190(%rbp), %rdi
callq 0x3100
movq -0x1c8(%rbp), %rdi
callq 0x34a0
nopw %cs:(%rax,%rax)