// File: /workspace/github_c_makefile_star2_O0/soso7885[P]OPCUA_example/client.c
// Function: main
int main(void)
{
	UA_Client *clt;	//client
	UA_StatusCode retval;
	UA_ReadRequest req;	//read request
	UA_ReadResponse resp; //response
	/*
	 * Step 1.
	 *	create & init the client
	*/
	clt = UA_Client_new(UA_ClientConfig_standard);
	retval = UA_Client_connect(clt, URL);
	if(retval != UA_STATUSCODE_GOOD){
		UA_Client_delete(clt);
		return retval;
	}
	/*
	 * Step 2.
	 *	Create read request
	*/
	UA_ReadRequest_init(&req);	// memset 0 in req
	req.nodesToRead = UA_Array_new(1, &UA_TYPES[UA_TYPES_READVALUEID]);
	req.nodesToReadSize = 1;
	/*
	 * Step 3.
	 *	define which node and attribute to be read
	*/
	req.nodesToRead[0].nodeId = UA_NODEID_STRING_ALLOC(1, "the.fucker");
	req.nodesToRead[0].attributeId = UA_ATTRIBUTEID_VALUE;
	/*
	 * Step 4.
	 *	call the `UA_Client_Service_read` to read
	*/
	UA_ReadResponse_init(&resp);
	resp = UA_Client_Service_read(clt, req);
/*	if(resp.responseHeader.serviceResult == UA_STATUSCODE_GOOD &&
		resp.resultsSize > 0 &&
		resp.results[0].hasValue &&
		UA_Variant_isScalar(&resp.results[0].value) &&
		resp.results[0].value.type == &UA_TYPES[UA_TYPES_INT32])
	{*/
	if(resp.responseHeader.serviceResult == UA_STATUSCODE_GOOD &&
		resp.resultsSize > 0 &&
		resp.results[0].hasValue &&
		UA_Variant_isScalar(&resp.results[0].value) &&
		resp.results[0].value.type == &UA_TYPES[UA_TYPES_STRING])
	{
		UA_String *str = (UA_String *)resp.results[0].value.data;
		printf("The string : %s\n", str->data);
		/*
		UA_Int32 *val = (UA_Int32 *)resp.results[0].value.data;
		printf("The value is: %d\n", *val);*/
	}
	/*
	 * Step 5.
	 *	free resource
	*/
	UA_ReadRequest_deleteMembers(&req);
	UA_ReadResponse_deleteMembers(&resp);
	UA_Client_disconnect(clt);
	UA_Client_delete(clt);
	
	return UA_STATUSCODE_GOOD;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movl $0x0, -0x4(%rbp)
movq 0x2def(%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 0xdde(%rip), %rsi       # 0x2004
callq 0x1030
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x1248
movq -0x10(%rbp), %rdi
callq 0x10b0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13d0
leaq -0xa8(%rbp), %rdi
callq 0x13e0
movl $0x1, %edi
movq 0x2d80(%rip), %rsi      # 0x3fe0
addq $0xa78, %rsi            # imm = 0xA78
callq 0x1040
movq %rax, -0x20(%rbp)
movq $0x1, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x168(%rbp), %rdi
movl $0x1, %esi
leaq 0xd88(%rip), %rdx       # 0x201e
callq 0x1410
movq -0x228(%rbp), %rax
movq -0x168(%rbp), %rcx
movq %rcx, (%rax)
movq -0x160(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x158(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movl $0xd, 0x18(%rax)
leaq -0x150(%rbp), %rdi
callq 0x1470
movq -0x10(%rbp), %rax
movq %rax, -0x220(%rbp)
movq %rsp, %rdi
movl $0x12, %ecx
leaq -0xa8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x220(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x14a0
leaq -0x150(%rbp), %rdi
leaq -0x210(%rbp), %rsi
movl $0xa8, %edx
callq 0x10a0
cmpl $0x0, -0x144(%rbp)
jne 0x139f
cmpq $0x0, -0xc8(%rbp)
jbe 0x139f
movq -0xc0(%rbp), %rax
movb (%rax), %al
andb $0x1, %al
testb $0x1, %al
je 0x139f
movq -0xc0(%rbp), %rdi
addq $0x8, %rdi
callq 0x14f0
testb $0x1, %al
jne 0x1359
jmp 0x139f
movq -0xc0(%rbp), %rax
movq 0x2c79(%rip), %rcx      # 0x3fe0
addq $0x1b8, %rcx            # imm = 0x1B8
cmpq %rcx, 0x8(%rax)
jne 0x139f
movq -0xc0(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xc91(%rip), %rdi       # 0x2029
movb $0x0, %al
callq 0x1070
leaq -0xa8(%rbp), %rdi
callq 0x1530
leaq -0x150(%rbp), %rdi
callq 0x1560
movq -0x10(%rbp), %rdi
callq 0x1090
movq -0x10(%rbp), %rdi
callq 0x10b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
nopl (%rax)