// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x14f8, %rsp           # imm = 0x14F8
movq %rdi, %rbx
movl $0x10, %eax
leaq (%rax,%rbp), %rcx
addq $-0x520, %rcx           # imm = 0xFAE0
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x210, %rax            # imm = 0x210
jne 0x52e4
movl $0x10, %eax
leaq (%rax,%rbp), %rcx
addq $-0x1520, %rcx          # imm = 0xEAE0
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x1010, %rax           # imm = 0x1010
jne 0x530f
leaq 0x2d80(%rip), %rsi      # 0x80bc
leaq -0x320(%rbp), %rdi
movl $0x10, %edx
callq 0x2180
leaq -0x2b0(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x53c3
cmpq $0x0, 0x8(%rbx)
je 0x540e
leaq -0x520(%rbp), %r14
xorl %r13d, %r13d
leaq -0x50(%rbp), %r15
xorl %r12d, %r12d
movl $0x7d, %ecx
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2170
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x53b0
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
addq $0x7d, %r12
incq %r13
addq $0x20, %r14
cmpq 0x8(%rbx), %r12
jb 0x5379
jmp 0x5411
movq 0x5c06(%rip), %rbx      # 0xafd0
leaq 0x2cbe(%rip), %rsi      # 0x808f
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x5bd4(%rip), %rdi      # 0xafd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
jmp 0x57c8
xorl %r13d, %r13d
movq %r13, -0x58(%rbp)
testq %r13, %r13
je 0x5776
leaq -0x40(%rbp), %r13
movq -0x58(%rbp), %rax
decq %rax
movq %rax, -0x120(%rbp)
leaq -0x1520(%rbp), %rbx
leaq -0x518(%rbp), %r12
movq $0x0, -0x30(%rbp)
leaq -0x108(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x8(%r12), %rsi
movq (%r12), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %r15
movq %r15, %rdi
callq 0x30c0
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x59c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x549e
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x54c0
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x30(%rbp), %rax
cmpq %rax, -0x120(%rbp)
jne 0x554c
leaq -0xe8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %r14
movq %r14, %rdi
callq 0x30c0
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
movl $0x1, %ecx
callq 0x5aa0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x552c
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0xf8(%rbp), %rdi
leaq -0xe8(%rbp), %rax
cmpq %rax, %rdi
je 0x55ca
movq -0xe8(%rbp), %rsi
jmp 0x55c2
leaq -0xc8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %r14
movq %r14, %rdi
callq 0x30c0
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x5aa0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x55a8
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x55ca
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
callq 0x30c0
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x5d2e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x5620
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x5642
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x30c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x5f5e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x5694
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x56b6
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2160
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r15
movq %r15, %rdi
callq 0x30c0
movq %r14, %rdi
movq %r15, %rsi
callq 0x6012
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0x56ff
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2160
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x5718
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2160
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq -0x320(%rbp), %rdi
callq 0x21a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq -0x30(%rbp), %rcx
incq %rcx
addq $0x20, %rbx
addq $0x20, %r12
movq %rcx, -0x30(%rbp)
cmpq %rcx, -0x58(%rbp)
leaq -0x40(%rbp), %r13
jne 0x5446
movq 0x5853(%rip), %rbx      # 0xafd0
leaq 0x29c5(%rip), %rsi      # 0x8149
movl $0x10, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x5821(%rip), %rdi      # 0xafd0
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq -0x320(%rbp), %rdi
callq 0x21d0
movq 0x57f9(%rip), %rax      # 0xafc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x318(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x320(%rbp,%rcx)
callq 0x2110
leaq -0x228(%rbp), %rdi
callq 0x20a0
movq $-0x1000, %rbx          # imm = 0xF000
leaq -0x530(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x5820
movq (%r14), %rsi
incq %rsi
callq 0x2160
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x580c
movq $-0x200, %rbx           # imm = 0xFE00
leaq -0x330(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x584c
movq (%r14), %rsi
incq %rsi
callq 0x2160
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x5838
addq $0x14f8, %rsp           # imm = 0x14F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x595f
jmp 0x5950
jmp 0x5950
jmp 0x5950
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x5953
movq -0xc8(%rbp), %rsi
jmp 0x5944
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
leaq -0xe8(%rbp), %rax
cmpq %rax, %rdi
je 0x5953
movq -0xe8(%rbp), %rsi
jmp 0x5944
jmp 0x5950
movq %rax, %rbx
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x5953
movq -0x108(%rbp), %rsi
jmp 0x5944
jmp 0x5950
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x5953
movq -0xa8(%rbp), %rsi
jmp 0x5944
jmp 0x5950
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x5953
movq -0x88(%rbp), %rsi
jmp 0x5944
jmp 0x5950
movq %rax, %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x5953
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2160
jmp 0x5953
jmp 0x5950
movq %rax, %rbx
leaq -0x320(%rbp), %rdi
callq 0x21e0
movq $-0x1000, %r14          # imm = 0xF000
leaq -0x530(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x5981
movq (%r15), %rsi
incq %rsi
callq 0x2160
addq $-0x20, %r15
addq $0x20, %r14
jne 0x596d
movq $-0x200, %r14           # imm = 0xFE00
leaq -0x330(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x59ad
movq (%r15), %rsi
incq %rsi
callq 0x2160
addq $-0x20, %r15
addq $0x20, %r14
jne 0x5999
movq %rbx, %rdi
callq 0x2240
nop