// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
pushq $0x10
popq %rax
leaq (%rax,%rbp), %rcx
addq $-0x520, %rcx           # imm = 0xFAE0
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x210, %rax            # imm = 0x210
jne 0x4122
pushq $0x10
popq %rax
leaq (%rax,%rbp), %rcx
addq $-0x1520, %rcx          # imm = 0xEAE0
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x1010, %rax           # imm = 0x1010
jne 0x4148
leaq 0x1f4a(%rip), %rsi      # 0x60bc
leaq -0x318(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x2180
leaq -0x2a8(%rbp), %rdi
callq 0x2050
testb %al, %al
je 0x41dc
pushq $-0x1
popq %rbx
leaq -0x520(%rbp), %r15
xorl %r12d, %r12d
leaq -0x118(%rbp), %r13
cmpq 0x8(%r14), %r12
jae 0x41fc
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
pushq $0x7d
popq %rcx
callq 0x2160
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
addq $0x7d, %r12
incq %rbx
addq $0x20, %r15
jmp 0x41a5
movq 0x4ded(%rip), %rdi      # 0x8fd0
leaq 0x1ea5(%rip), %rsi      # 0x608f
callq 0x2150
movq %rax, %rdi
callq 0x20b0
jmp 0x43ba
leaq 0x1(%rbx), %rax
movq %rax, -0x38(%rbp)
leaq -0x520(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x1520(%rbp), %r15
xorl %r12d, %r12d
leaq -0x118(%rbp), %r13
cmpq %r12, -0x38(%rbp)
je 0x4393
leaq -0xf8(%rbp), %r14
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0x21c0
movq %r13, %rdi
movq %r14, %rsi
callq 0x44ca
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
cmpq %r12, %rbx
jne 0x428c
leaq -0xd8(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
pushq $0x1
popq %rcx
callq 0x4564
jmp 0x42ae
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r13, %rdi
movq %r14, %rsi
movl %r12d, %edx
xorl %ecx, %ecx
callq 0x4564
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
leaq -0x98(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r13, %rdi
movq %r14, %rsi
callq 0x4666
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
leaq -0x78(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r13, %rdi
movq %r14, %rsi
callq 0x47ee
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
leaq -0x58(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r13, %rdi
movq %r14, %rsi
callq 0x4884
movq %r15, %rdi
movq %r13, %rsi
callq 0x21a0
movq %r13, %rdi
callq 0x20a0
movq %r14, %rdi
callq 0x20a0
leaq -0x318(%rbp), %rdi
movq %r15, %rsi
callq 0x2130
movq %rax, %rdi
callq 0x20b0
incq %r12
addq $0x20, -0x30(%rbp)
addq $0x20, %r15
jmp 0x4220
movq 0x4c36(%rip), %rdi      # 0x8fd0
leaq 0x1da8(%rip), %rsi      # 0x6149
callq 0x2150
movq %rax, %rdi
callq 0x20b0
leaq -0x318(%rbp), %rdi
callq 0x21d0
leaq -0x318(%rbp), %rdi
callq 0x21e0
movl $0xfe0, %ebx            # imm = 0xFE0
leaq (%rbx,%rbp), %rdi
addq $-0x1520, %rdi          # imm = 0xEAE0
callq 0x20a0
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x43cb
movl $0x1e0, %ebx            # imm = 0x1E0
leaq (%rbx,%rbp), %rdi
addq $-0x520, %rdi           # imm = 0xFAE0
callq 0x20a0
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x43ea
addq $0x14f8, %rsp           # imm = 0x14F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4481
jmp 0x4472
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x4469
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
jmp 0x4469
jmp 0x4472
jmp 0x4472
jmp 0x4472
jmp 0x4472
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
jmp 0x4469
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
jmp 0x4469
jmp 0x4472
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
jmp 0x4469
jmp 0x4472
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x20a0
jmp 0x4475
jmp 0x4472
movq %rax, %rbx
leaq -0x318(%rbp), %rdi
callq 0x21e0
movl $0xfe0, %r14d           # imm = 0xFE0
leaq (%r14,%rbp), %rdi
addq $-0x1520, %rdi          # imm = 0xEAE0
callq 0x20a0
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x4487
movl $0x1e0, %r14d           # imm = 0x1E0
leaq (%r14,%rbp), %rdi
addq $-0x520, %rdi           # imm = 0xFAE0
callq 0x20a0
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x44a7
movq %rbx, %rdi
callq 0x2230
nop