// File: carellano8[P]Proyecto-Redes-I-2017/hamming.cpp
// Function: hamming::enviar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void hamming::enviar(string msj){
    size_t i,n;
    string bufferMsj[MAXMSJ/MAXT];
    binario bufferB[MAXMSJ/MAXT*8];
    i=0;n=0;
	ofstream archivo("canalh.txt");

    if(archivo.is_open()){
	    while(i<msj.size()){
	        bufferMsj[n]=msj.substr(i,MAXT);
	        i+=MAXT;n++;
	    }

	    for (i = 0; i < n; ++i){
	        bufferB[i]=msjTobin(bufferMsj[i]);

	        if(i==n-1){
	            bufferB[i]=insertarCabecera(bufferB[i],i,1);// Inserta el bit de fin de trasmision demensaje
	        }else{
	            bufferB[i]=insertarCabecera(bufferB[i],i,0);
	        }

	        bufferB[i]=codificadorHamming(bufferB[i]);
	        bufferB[i]=relleno_Bit(bufferB[i]);
	        bufferB[i]=insercion_banderas(bufferB[i]);
	        archivo/*<<"Trama Hamming: "*/<<bufferB[i]<<endl;
	    }

        cout<<"tramas Enviadas "<<endl;
        archivo.close();
    }else{
    	cout<<"Se ha detectado algun un error"<<endl;
    }
 }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x16b0, %rsp           # imm = 0x16B0
movq %rdi, -0x15e8(%rbp)
movq %rdi, -0x8(%rbp)
leaq -0x220(%rbp), %rax
movq %rax, %rcx
addq $0x200, %rcx            # imm = 0x200
movq %rcx, -0x15e0(%rbp)
movq %rax, -0x15d8(%rbp)
movq -0x15d8(%rbp), %rdi
movq %rdi, -0x15f0(%rbp)
callq 0x32d0
movq -0x15f0(%rbp), %rax
movq -0x15e0(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x15d8(%rbp)
jne 0x70a5
leaq -0x1220(%rbp), %rax
movq %rax, %rcx
addq $0x1000, %rcx           # imm = 0x1000
movq %rcx, -0x1600(%rbp)
movq %rax, -0x15f8(%rbp)
movq -0x15f8(%rbp), %rdi
movq %rdi, -0x1608(%rbp)
callq 0x32d0
movq -0x1608(%rbp), %rax
movq -0x1600(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x15f8(%rbp)
jne 0x70f5
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
leaq 0x2f7f(%rip), %rsi      # 0xa0bc
leaq -0x1420(%rbp), %rdi
movl $0x10, %edx
callq 0x3250
jmp 0x7150
leaq -0x1420(%rbp), %rdi
callq 0x3190
movb %al, -0x1609(%rbp)
jmp 0x7164
movb -0x1609(%rbp), %al
testb $0x1, %al
jne 0x7173
jmp 0x7656
jmp 0x7175
movq -0x15e8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x1618(%rbp)
callq 0x3170
movq %rax, %rcx
movq -0x1618(%rbp), %rax
cmpq %rcx, %rax
jae 0x7232
movq -0x15e8(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x1450(%rbp), %rdi
movl $0x7d, %ecx
callq 0x3200
jmp 0x71bd
movq -0x18(%rbp), %rax
leaq -0x220(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x1450(%rbp), %rsi
callq 0x3290
leaq -0x1450(%rbp), %rdi
callq 0x3140
movq -0x10(%rbp), %rax
addq $0x7d, %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x7175
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
jmp 0x7742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
jmp 0x7736
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x7615
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x220(%rbp,%rax), %rsi
leaq -0x1490(%rbp), %rdi
callq 0x30e0
jmp 0x7266
leaq -0x1470(%rbp), %rdi
leaq -0x1490(%rbp), %rsi
callq 0x77f0
jmp 0x727b
movq -0x10(%rbp), %rax
leaq -0x1220(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x1470(%rbp), %rsi
callq 0x3290
leaq -0x1470(%rbp), %rdi
callq 0x3140
leaq -0x1490(%rbp), %rdi
callq 0x3140
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x7382
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rsi
leaq -0x14d0(%rbp), %rdi
callq 0x30e0
jmp 0x72e4
movl -0x10(%rbp), %edx
leaq -0x14b0(%rbp), %rdi
leaq -0x14d0(%rbp), %rsi
movl $0x1, %ecx
callq 0x7950
jmp 0x7301
movq -0x10(%rbp), %rax
leaq -0x1220(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x14b0(%rbp), %rsi
callq 0x3290
leaq -0x14b0(%rbp), %rdi
callq 0x3140
leaq -0x14d0(%rbp), %rdi
callq 0x3140
jmp 0x7415
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
leaq -0x1490(%rbp), %rdi
callq 0x3140
jmp 0x7736
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
leaq -0x14d0(%rbp), %rdi
callq 0x3140
jmp 0x7736
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rsi
leaq -0x1510(%rbp), %rdi
callq 0x30e0
jmp 0x73a0
movl -0x10(%rbp), %edx
leaq -0x14f0(%rbp), %rdi
leaq -0x1510(%rbp), %rsi
xorl %ecx, %ecx
callq 0x7950
jmp 0x73ba
movq -0x10(%rbp), %rax
leaq -0x1220(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x14f0(%rbp), %rsi
callq 0x3290
leaq -0x14f0(%rbp), %rdi
callq 0x3140
leaq -0x1510(%rbp), %rdi
callq 0x3140
jmp 0x7415
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
leaq -0x1510(%rbp), %rdi
callq 0x3140
jmp 0x7736
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rsi
leaq -0x1550(%rbp), %rdi
callq 0x30e0
jmp 0x7433
leaq -0x1530(%rbp), %rdi
leaq -0x1550(%rbp), %rsi
callq 0x7ae0
jmp 0x7448
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rdi
leaq -0x1530(%rbp), %rsi
movq %rsi, -0x1620(%rbp)
callq 0x3290
movq -0x1620(%rbp), %rdi
callq 0x3140
leaq -0x1550(%rbp), %rdi
callq 0x3140
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rsi
leaq -0x1590(%rbp), %rdi
callq 0x30e0
jmp 0x74a1
leaq -0x1570(%rbp), %rdi
leaq -0x1590(%rbp), %rsi
callq 0x7e90
jmp 0x74b6
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rdi
leaq -0x1570(%rbp), %rsi
movq %rsi, -0x1628(%rbp)
callq 0x3290
movq -0x1628(%rbp), %rdi
callq 0x3140
leaq -0x1590(%rbp), %rdi
callq 0x3140
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rsi
leaq -0x15d0(%rbp), %rdi
callq 0x30e0
jmp 0x750f
leaq -0x15b0(%rbp), %rdi
leaq -0x15d0(%rbp), %rsi
callq 0x7ff0
jmp 0x7524
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rdi
leaq -0x15b0(%rbp), %rsi
movq %rsi, -0x1638(%rbp)
callq 0x3290
movq -0x1638(%rbp), %rdi
callq 0x3140
leaq -0x15d0(%rbp), %rdi
callq 0x3140
movq -0x10(%rbp), %rax
shlq $0x5, %rax
leaq -0x1220(%rbp,%rax), %rsi
leaq -0x1420(%rbp), %rdi
callq 0x31d0
movq %rax, -0x1630(%rbp)
jmp 0x7584
movq -0x1630(%rbp), %rdi
movq 0x5a2e(%rip), %rsi      # 0xcfc0
callq 0x3210
jmp 0x7599
jmp 0x759b
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x723a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
leaq -0x1550(%rbp), %rdi
callq 0x3140
jmp 0x7736
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
leaq -0x1590(%rbp), %rdi
callq 0x3140
jmp 0x7736
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1428(%rbp)
movl %eax, -0x142c(%rbp)
leaq -0x15d0(%rbp), %rdi
callq 0x3140
jmp 0x7736
movq 0x59b4(%rip), %rdi      # 0xcfd0
leaq 0x2b26(%rip), %rsi      # 0xa149
callq 0x31f0
movq %rax, -0x1640(%rbp)
jmp 0x7631
movq -0x1640(%rbp), %rdi
movq 0x5981(%rip), %rsi      # 0xcfc0
callq 0x3210
jmp 0x7646
leaq -0x1420(%rbp), %rdi
callq 0x32e0
jmp 0x7654
jmp 0x7689
movq 0x5973(%rip), %rdi      # 0xcfd0
leaq 0x2a2b(%rip), %rsi      # 0xa08f
callq 0x31f0
movq %rax, -0x1648(%rbp)
jmp 0x7672
movq -0x1648(%rbp), %rdi
movq 0x5940(%rip), %rsi      # 0xcfc0
callq 0x3210
jmp 0x7687
jmp 0x7689
leaq -0x1420(%rbp), %rdi
callq 0x3300
leaq -0x1220(%rbp), %rax
movq %rax, -0x1658(%rbp)
addq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x1650(%rbp)
movq -0x1650(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x1660(%rbp)
callq 0x3140
movq -0x1658(%rbp), %rcx
movq -0x1660(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1650(%rbp)
jne 0x76b0
leaq -0x220(%rbp), %rax
movq %rax, -0x1670(%rbp)
addq $0x200, %rax            # imm = 0x200
movq %rax, -0x1668(%rbp)
movq -0x1668(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x1678(%rbp)
callq 0x3140
movq -0x1670(%rbp), %rcx
movq -0x1678(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1668(%rbp)
jne 0x76fc
addq $0x16b0, %rsp           # imm = 0x16B0
popq %rbp
retq
leaq -0x1420(%rbp), %rdi
callq 0x3300
leaq -0x1220(%rbp), %rax
movq %rax, -0x1688(%rbp)
addq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x1680(%rbp)
movq -0x1680(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x1690(%rbp)
callq 0x3140
movq -0x1688(%rbp), %rcx
movq -0x1690(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1680(%rbp)
jne 0x775d
leaq -0x220(%rbp), %rax
movq %rax, -0x16a0(%rbp)
addq $0x200, %rax            # imm = 0x200
movq %rax, -0x1698(%rbp)
movq -0x1698(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x16a8(%rbp)
callq 0x3140
movq -0x16a0(%rbp), %rcx
movq -0x16a8(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1698(%rbp)
jne 0x77a9
jmp 0x77dc
movq -0x1428(%rbp), %rdi
callq 0x3390
nopl (%rax,%rax)