// File: /workspace/github_cpp_makefile_star2_O1/andresziemecki[P]MQTT/mqtt.cpp
// Function: SimPublisher::runSim()
void SimPublisher::runSim(){
    // Registrar el cliente
    brops = broker.registerClient(this);
    // Esperar un rato a que empiecen las conecciones
    std::this_thread::sleep_for (std::chrono::seconds(rand() % 3));
    
    // Mandar el connect
    brops->sendMsg(ConnectMsg(usuario_pass.username, usuario_pass.password));
    // esperar por CONNACK sin errores
    std::unique_lock<std::mutex> lock(mmutex);
    while(!connack_value){ 
        if(cond_var.wait_for(lock, std::chrono::seconds(5), [&](){return ready;})){
            break;
        }
        else{
            cout << "Loggin Error, no response of the broker" << endl;
            break;
        }
    }

    if (connack_value)
        ;
    else{
        mutex_cout.lock();
        cout << "Connack not recive -> Error" << endl; // DISCONNECT
        mutex_cout.unlock();
        return;
    }
    // Si el cliente es subscriptor que se subscriba a algo, sino que publique
    if(!Par_del_client.subscriptor)
        Publish();
    else
        Subscribirse(Par_del_client.topic_name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq %rbx, %rsi
callq 0x5aa2
movq %rax, 0xf8(%rbx)
callq 0x3070
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
testl %eax, %eax
jle 0x5dda
movl %eax, %eax
leaq -0xd8(%rbp), %r14
movq %rax, (%r14)
movq $0x0, 0x8(%r14)
movq %r14, %rdi
movq %r14, %rsi
callq 0x30b0
cmpl $-0x1, %eax
jne 0x5dda
callq 0x3040
cmpl $0x4, (%rax)
je 0x5dc0
movq 0xf8(%rbx), %r14
leaq -0x70(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x74c0
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x74c0
leaq -0xd8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x6cde
movq (%r14), %rax
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq *0x10(%rax)
leaq -0xd8(%rbp), %rdi
callq 0x6d5e
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x5e58
callq 0x31c0
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x5e66
callq 0x31c0
leaq 0x98(%rbx), %rax
leaq -0xd8(%rbp), %r14
movq %rax, (%r14)
movb $0x0, 0x8(%r14)
movq %r14, %rdi
callq 0x8c72
movb $0x1, 0x8(%r14)
cmpb $0x0, 0x90(%rbx)
je 0x5ee8
cmpb $0x0, 0x90(%rbx)
je 0x5f8a
cmpb $0x0, 0x78(%rbx)
je 0x5fee
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rdx
addq %rsi, %rdx
leaq -0x40(%rbp), %rdi
callq 0x74c0
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x62aa
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x5ff6
callq 0x31c0
jmp 0x5ff6
leaq 0xc0(%rbx), %r14
callq 0x3240
movabsq $0x12a05f200, %rcx      # imm = 0x12A05F200
addq %rax, %rcx
leaq -0x88(%rbp), %r15
movq %rcx, (%r15)
leaq -0xd8(%rbp), %r12
cmpb $0x0, 0xf0(%rbx)
jne 0x5e92
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x8cb8
cmpl $0x1, %eax
jne 0x5f12
cmpb $0x0, 0xf0(%rbx)
jne 0x5e92
movq 0x7092(%rip), %r14      # 0xcfd8
leaq 0x3250(%rip), %rsi      # 0x919d
movl $0x27, %edx
movq %r14, %rdi
callq 0x3200
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq 0x7060(%rip), %rdi      # 0xcfd8
callq 0x3030
movq %rax, %rdi
callq 0x3150
jmp 0x5e92
leaq 0x721f(%rip), %rdi      # 0xd1b0
callq 0x3270
testl %eax, %eax
jne 0x6012
movq 0x7037(%rip), %rbx      # 0xcfd8
leaq 0x321d(%rip), %rsi      # 0x91c5
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31d0
movsbl %al, %esi
movq 0x7005(%rip), %rdi      # 0xcfd8
callq 0x3030
movq %rax, %rdi
callq 0x3150
leaq 0x71c9(%rip), %rdi      # 0xd1b0
callq 0x3170
jmp 0x5ff6
movq %rbx, %rdi
callq 0x607c
leaq -0xd8(%rbp), %rdi
callq 0x6d9e
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x3140
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x6068
callq 0x31c0
jmp 0x6068
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x6d5e
jmp 0x6040
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x6053
callq 0x31c0
jmp 0x6053
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x6074
callq 0x31c0
jmp 0x6074
jmp 0x6065
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x6d9e
movq %rbx, %rdi
callq 0x32e0