// File: /workspace/github_cpp_makefile_star2_O3/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 0x5a98
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 0x5d74
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 0x5d74
callq 0x3040
cmpl $0x4, (%rax)
je 0x5d5a
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 0x742a
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x742a
leaq -0xd8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x6c48
movq (%r14), %rax
leaq -0xd8(%rbp), %rsi
movq %r14, %rdi
callq *0x10(%rax)
leaq -0xd8(%rbp), %rdi
callq 0x6cc8
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x5df2
callq 0x31c0
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x5e00
callq 0x31c0
leaq 0x98(%rbx), %rax
leaq -0xd8(%rbp), %r14
movq %rax, (%r14)
movb $0x0, 0x8(%r14)
movq %r14, %rdi
callq 0x8baa
movb $0x1, 0x8(%r14)
cmpb $0x0, 0x90(%rbx)
je 0x5e82
cmpb $0x0, 0x90(%rbx)
je 0x5f24
cmpb $0x0, 0x78(%rbx)
je 0x5f88
leaq -0x30(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rdx
addq %rsi, %rdx
leaq -0x40(%rbp), %rdi
callq 0x742a
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x6244
movq -0x40(%rbp), %rdi
cmpq %r14, %rdi
je 0x5f90
callq 0x31c0
jmp 0x5f90
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 $0x1, 0xf0(%rbx)
je 0x5e2c
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x8bf0
cmpl $0x1, %eax
jne 0x5eac
cmpb $0x0, 0xf0(%rbx)
jne 0x5e2c
movq 0x70f8(%rip), %r14      # 0xcfd8
leaq 0x32b6(%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 0x70c6(%rip), %rdi      # 0xcfd8
callq 0x3030
movq %rax, %rdi
callq 0x3150
jmp 0x5e2c
leaq 0x7285(%rip), %rdi      # 0xd1b0
callq 0x3270
testl %eax, %eax
jne 0x5fac
movq 0x709d(%rip), %rbx      # 0xcfd8
leaq 0x3283(%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 0x706b(%rip), %rdi      # 0xcfd8
callq 0x3030
movq %rax, %rdi
callq 0x3150
leaq 0x722f(%rip), %rdi      # 0xd1b0
callq 0x3170
jmp 0x5f90
movq %rbx, %rdi
callq 0x6016
leaq -0xd8(%rbp), %rdi
callq 0x6d08
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 0x6002
callq 0x31c0
jmp 0x6002
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x6cc8
jmp 0x5fda
movq %rax, %rbx
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x5fed
callq 0x31c0
jmp 0x5fed
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x600e
callq 0x31c0
jmp 0x600e
jmp 0x5fff
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x6d08
movq %rbx, %rdi
callq 0x32e0