// File: /workspace/github_c_makefile_star2_O2/soso7885[P]OPCUA_example/demo_src/client_firstSteps.c
// Function: main
int main(void) {
    UA_Client *client = UA_Client_new(UA_ClientConfig_standard);
    UA_StatusCode retval = UA_Client_connect(client, "opc.tcp://localhost:16664");
    if(retval != UA_STATUSCODE_GOOD) {
        UA_Client_delete(client);
        return (int)retval;
    }

    //variables to store data
    UA_DateTime raw_date = 0;
    UA_String string_date;

    UA_ReadRequest rReq;
    UA_ReadRequest_init(&rReq);
    rReq.nodesToRead = UA_Array_new(1, &UA_TYPES[UA_TYPES_READVALUEID]);
    rReq.nodesToReadSize = 1;
    rReq.nodesToRead[0].nodeId = UA_NODEID_NUMERIC(0, 2258);
    rReq.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;

    UA_ReadResponse rResp = UA_Client_Service_read(client, rReq);
    if(rResp.responseHeader.serviceResult == UA_STATUSCODE_GOOD && rResp.resultsSize > 0 &&
       rResp.results[0].hasValue && UA_Variant_isScalar(&rResp.results[0].value) &&
       rResp.results[0].value.type == &UA_TYPES[UA_TYPES_DATETIME]) {
        raw_date = *(UA_DateTime*)rResp.results[0].value.data;
        printf("raw date is: %" PRId64 "\n", raw_date);
        string_date = UA_DateTime_toString(raw_date);
        printf("string date is: %.*s\n", (int)string_date.length, string_date.data);
    }

    UA_ReadRequest_deleteMembers(&rReq);
    UA_ReadResponse_deleteMembers(&rResp);
    UA_String_deleteMembers(&string_date);

    UA_Client_disconnect(client);
    UA_Client_delete(client);
    return (int) UA_STATUSCODE_GOOD;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq 0x2e01(%rip), %rax      # 0x3fe8
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x1050
movq %rax, %rbx
leaq 0xdf5(%rip), %rsi       # 0x2004
movq %rax, %rdi
callq 0x1030
movl %eax, %r14d
testl %eax, %eax
jne 0x139a
xorps %xmm0, %xmm0
leaq -0x200(%rbp), %r12
movaps %xmm0, 0x70(%r12)
movaps %xmm0, 0x60(%r12)
movaps %xmm0, 0x50(%r12)
movaps %xmm0, 0x40(%r12)
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movq 0x2d7e(%rip), %r15      # 0x3fe0
leaq 0xa78(%r15), %rsi
pushq $0x1
popq %rdi
callq 0x1040
movq %rax, 0x88(%r12)
andw $0x0, (%rax)
movq $0x1, 0x80(%r12)
movabsq $0x8d200000000, %rcx    # imm = 0x8D200000000
movq %rcx, 0x4(%rax)
movl $0xd, 0x18(%rax)
leaq -0xc0(%rbp), %r13
movl $0x90, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x1090
leaq 0x1400(%r15), %rdx
leaq 0x13b0(%r15), %rax
leaq -0x168(%rbp), %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %r13
movq %rdx, -0x30(%rbp)
movq %r12, %rcx
movq %rax, %r8
callq 0x10c0
cmpl $0x0, 0xc(%r12)
jne 0x135d
cmpq $0x0, -0xe0(%rbp)
je 0x135d
movq -0xd8(%rbp), %rax
testb $0x1, (%rax)
je 0x135d
cmpq $0x0, 0x18(%rax)
jne 0x135d
movq 0x20(%rax), %rcx
cmpq $0x2, %rcx
jb 0x135d
movl $0x1e0, %edx            # imm = 0x1E0
addq 0x2cc3(%rip), %rdx      # 0x3fe0
cmpq %rdx, 0x8(%rax)
jne 0x135d
movq (%rcx), %r12
leaq 0xcf1(%rip), %rdi       # 0x201e
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
movq %r12, %rdi
callq 0x10b0
movq %rax, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
leaq 0xcdc(%rip), %rdi       # 0x2030
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq -0x200(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1060
leaq -0x168(%rbp), %rdi
movq %r13, %rsi
callq 0x1060
addq $0x1b8, %r15            # imm = 0x1B8
leaq -0xc0(%rbp), %rdi
movq %r15, %rsi
callq 0x1060
movq %rbx, %rdi
callq 0x1080
movq %rbx, %rdi
callq 0x10a0
movl %r14d, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq