// File: /workspace/github_c_makefile_star2_O0/back1127[P]linkedge-thing-access-websocket_client_sdk/sdk/leda.c
// Function: wsa_get_reply_result
int wsa_get_reply_result(int msg_id, int timeout_ms, int *code, char **payload)
{
    int time_count = 0, s;
    wsa_reply_t *reply;
    struct timespec ts = {0};

    reply = _wsa_get_reply_by_msg_id(msg_id);
    if (NULL == reply) {
        log_d(LOG_TAG, "get reply err:%d\r\n", msg_id);
        return LE_ERROR_INVAILD_PARAM;
    }
    if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
        wsa_remove_reply(msg_id);
        return LE_ERROR_UNKNOWN;
    }
    ts.tv_nsec = ts.tv_nsec + (timeout_ms % 1000) * 1000000000;
    ts.tv_sec = ts.tv_sec + timeout_ms / 1000;
    while ((s = sem_timedwait(&reply->sem, &ts)) == -1 && errno == EINTR) {
        continue;
    }

    if (-1 == s) {
        wsa_remove_reply(msg_id);
        log_e(LOG_TAG, "get reply time_out:%s", strerror(errno));
        return LE_ERROR_TIMEOUT;
    }
    
    if (code) {
        *code = reply->code;
    }
    if (payload) {
        *payload = strdup(reply->payload);
    }
    wsa_remove_reply(msg_id);

    return LE_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x4300
movl -0x8(%rbp), %edi
callq 0x52e0
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpq -0x30(%rbp), %rax
jne 0x54ba
movl -0x8(%rbp), %eax
xorl %edi, %edi
leaq 0x8cd3(%rip), %rsi      # 0xe150
leaq 0x8c12(%rip), %rdx      # 0xe096
leaq 0x8c10(%rip), %rcx      # 0xe09b
leaq 0x8cc4(%rip), %r8       # 0xe156
movl $0x159, %r9d            # imm = 0x159
leaq 0x8ccc(%rip), %r10      # 0xe16b
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x42b0
movl $0x186a1, -0x4(%rbp)    # imm = 0x186A1
jmp 0x560d
xorl %edi, %edi
leaq -0x40(%rbp), %rsi
callq 0x4180
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x54e4
movl -0x8(%rbp), %edi
callq 0x43e0
movl $0x186a0, -0x4(%rbp)    # imm = 0x186A0
jmp 0x560d
movq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0xc(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
movq -0x50(%rbp), %rax
imull $0x3b9aca00, %edx, %ecx # imm = 0x3B9ACA00
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0xc(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
leaq -0x40(%rbp), %rsi
callq 0x4210
movl %eax, %ecx
movl %ecx, -0x28(%rbp)
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x51(%rbp)
jne 0x555c
callq 0x4080
cmpl $0x4, (%rax)
sete %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x5565
jmp 0x5567
jmp 0x552e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl -0x28(%rbp), %eax
jne 0x55cc
movl -0x8(%rbp), %edi
callq 0x43e0
callq 0x4080
movl (%rax), %edi
callq 0x4710
movl $0x3, %edi
leaq 0x8aff(%rip), %rsi      # 0xe090
leaq 0x8afe(%rip), %rdx      # 0xe096
leaq 0x8afc(%rip), %rcx      # 0xe09b
leaq 0x8bb0(%rip), %r8       # 0xe156
movl $0x168, %r9d            # imm = 0x168
leaq 0x8bcb(%rip), %r10      # 0xe17e
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x42b0
movl $0x186a6, -0x4(%rbp)    # imm = 0x186A6
jmp 0x560d
cmpq $0x0, -0x18(%rbp)
je 0x55e0
movq -0x30(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x55fe
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x4700
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x8(%rbp), %edi
callq 0x43e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)