// File: /workspace/github_c_makefile_star2_O1/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 0x2df1(%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 0xde5(%rip), %rsi       # 0x2004
movq %rax, %rdi
callq 0x1030
testl %eax, %eax
je 0x1233
movl %eax, %r14d
jmp 0x138f
leaq -0x1f8(%rbp), %r12
xorl %r14d, %r14d
movl $0x90, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x1080
movq 0x2d8d(%rip), %r15      # 0x3fe0
leaq 0xa78(%r15), %rsi
movl $0x1, %edi
callq 0x1040
movq %rax, 0x88(%r12)
movq $0x1, 0x80(%r12)
movw $0x0, (%rax)
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 0x10a0
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 0x10d0
cmpl $0x0, 0xc(%r12)
jne 0x1352
cmpq $0x0, -0xe0(%rbp)
je 0x1352
movq -0xd8(%rbp), %rax
testb $0x1, (%rax)
je 0x1352
cmpq $0x0, 0x18(%rax)
jne 0x1352
cmpq $0x2, 0x20(%rax)
jb 0x1352
movl $0x1e0, %ecx            # imm = 0x1E0
addq 0x2cd2(%rip), %rcx      # 0x3fe0
cmpq %rcx, 0x8(%rax)
jne 0x1352
movq 0x20(%rax), %rax
movq (%rax), %r12
leaq 0xcfc(%rip), %rdi       # 0x201e
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
movq %r12, %rdi
callq 0x10c0
movq %rax, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
leaq 0xce7(%rip), %rdi       # 0x2030
movl %eax, %esi
xorl %eax, %eax
callq 0x1070
leaq -0x1f8(%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 0x1090
movq %rbx, %rdi
callq 0x10b0
movl %r14d, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq