// File: /workspace/github_c_makefile_star2_O0/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
subq $0x230, %rsp            # imm = 0x230
movl $0x0, -0x4(%rbp)
movq 0x2dff(%rip), %rax      # 0x3fe8
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x1050
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xdee(%rip), %rsi       # 0x2004
callq 0x1030
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x1238
movq -0x10(%rbp), %rdi
callq 0x10a0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13f5
movq $0x0, -0x20(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x1410
movl $0x1, %edi
movq 0x2d88(%rip), %rsi      # 0x3fe0
addq $0xa78, %rsi            # imm = 0xA78
callq 0x1040
movq %rax, -0x38(%rbp)
movq $0x1, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0xd8(%rbp), %rdi
xorl %esi, %esi
movl $0x8d2, %edx            # imm = 0x8D2
callq 0x1440
movq -0x1a0(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xc8(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movl $0xd, 0x18(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x198(%rbp)
movq %rsp, %rdi
movl $0x12, %ecx
leaq -0xc0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x198(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x1470
cmpl $0x0, -0x174(%rbp)
jne 0x13bb
cmpq $0x0, -0xf8(%rbp)
jbe 0x13bb
movq -0xf0(%rbp), %rax
movb (%rax), %al
andb $0x1, %al
testb $0x1, %al
je 0x13bb
movq -0xf0(%rbp), %rdi
addq $0x8, %rdi
callq 0x14c0
testb $0x1, %al
jne 0x1337
jmp 0x13bb
movq -0xf0(%rbp), %rax
movq 0x2c9b(%rip), %rcx      # 0x3fe0
addq $0x1e0, %rcx            # imm = 0x1E0
cmpq %rcx, 0x8(%rax)
jne 0x13bb
movq -0xf0(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0xcaf(%rip), %rdi       # 0x201e
movb $0x0, %al
callq 0x1070
movq -0x20(%rbp), %rdi
callq 0x10b0
movq %rax, -0x190(%rbp)
movq %rdx, -0x188(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movl %eax, %esi
movq -0x28(%rbp), %rdx
leaq 0xc7c(%rip), %rdi       # 0x2030
movb $0x0, %al
callq 0x1070
leaq -0xc0(%rbp), %rdi
callq 0x1500
leaq -0x180(%rbp), %rdi
callq 0x1530
leaq -0x30(%rbp), %rdi
callq 0x1560
movq -0x10(%rbp), %rdi
callq 0x1090
movq -0x10(%rbp), %rdi
callq 0x10a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw %cs:(%rax,%rax)