// File: /workspace/github_c_makefile_star2_O0/soso7885[P]OPCUA_example/server.c
// Function: main
int main(void)
{
	UA_ServerNetworkLayer nl;	//Server interface
	UA_Server *svr;		//server
	UA_ServerConfig conf;	//Server config
	UA_Int32 val;	//the var value
	UA_VariableAttributes attr;	//the var attribues
	UA_NodeId selfNodeId, parentNodeId, parRefNodeId, varType;//the node-ID
	UA_QualifiedName bName;	//browse-name

	signal(SIGINT, stopHandler);
	signal(SIGTERM, stopHandler);

	/*
	 * Step 1.
	 *	init the server
	*/	
	//fill in the `UA_ServerNetworkLayer` structure member
	nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
	//the server config setting
	conf = UA_ServerConfig_standard;
	conf.logger = Logger_Stdout;
	conf.networkLayers = &nl;
	conf.networkLayersSize = 1;
	svr = UA_Server_new(conf);
	/*
	 * Step 2.
	 *  Set the variable and variable attribute
	*/
	val = 5566;
	UA_String str = UA_STRING_ALLOC("Hello, world");
	UA_VariableAttributes_init(&attr);	
//	UA_Variant_setScalar(&attr.value, &val, &UA_TYPES[UA_TYPES_INT32]);	
	UA_Variant_setScalarCopy(&attr.value, &str, &UA_TYPES[UA_TYPES_STRING]);
	attr.displayName = UA_LOCALIZEDTEXT("TW", "the fucker");
	/*
	 * Step 3.
	 *  Define the variable shall be add with which `browsname`
	*/
	selfNodeId = UA_NODEID_STRING(1, "the.fucker");
	parentNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER);
	parRefNodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES);
	varType = UA_NODEID_NULL; //no variable type defined
	bName = UA_QUALIFIEDNAME(1, "the fucker");
	/*
	 * Step 4.
	 * Add the node
	*/
	UA_Server_addVariableNode(svr, selfNodeId, parentNodeId, parRefNodeId,
							bName, varType, attr, NULL, NULL);
	/*
	 * Step 5.
	 * Run server
	*/
	isRunning = true;	// the switch
	UA_Server_run(svr, &isRunning);
	UA_Server_delete(svr);
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x540, %rsp            # imm = 0x540
movl $0x0, -0x4(%rbp)
movl $0x2, %edi
leaq 0x382(%rip), %rsi       # 0x1590
callq 0x10a0
movl $0xf, %edi
leaq 0x371(%rip), %rsi       # 0x1590
callq 0x10a0
movq 0x2dc5(%rip), %rax      # 0x3ff0
movq (%rax), %rcx
movq %rcx, -0x340(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x338(%rbp)
movl 0x10(%rax), %eax
movl %eax, -0x330(%rbp)
leaq -0x328(%rbp), %rdi
leaq -0x340(%rbp), %rax
movl $0x4118, %esi           # imm = 0x4118
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl 0x10(%rax), %eax
movl %eax, 0x10(%rsp)
callq 0x1040
leaq -0x40(%rbp), %rdi
leaq -0x328(%rbp), %rsi
movl $0x38, %edx
callq 0x1090
leaq -0x1a8(%rbp), %rdi
movq 0x2d3d(%rip), %rsi      # 0x3fd8
movl $0x160, %edx            # imm = 0x160
callq 0x1090
movq 0x2d34(%rip), %rax      # 0x3fe0
movq %rax, -0x1a0(%rbp)
leaq -0x40(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq $0x1, -0xb8(%rbp)
movq %rsp, %rdi
movl $0x2c, %ecx
leaq -0x1a8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x1030
movq %rax, -0x48(%rbp)
movl $0x15be, -0x1ac(%rbp)   # imm = 0x15BE
leaq 0xd0f(%rip), %rdi       # 0x2004
callq 0x10d0
movq %rax, -0x350(%rbp)
movq %rdx, -0x348(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x15c0
leaq -0x278(%rbp), %rdi
addq $0x50, %rdi
leaq -0x350(%rbp), %rsi
movq 0x2ca3(%rip), %rdx      # 0x3fd0
addq $0x1b8, %rdx            # imm = 0x1B8
callq 0x1080
leaq -0x370(%rbp), %rdi
leaq 0xcca(%rip), %rsi       # 0x2011
leaq 0xcc6(%rip), %rdx       # 0x2014
callq 0x15f0
movq -0x370(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x360(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0x358(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0x388(%rbp), %rdi
movl $0x1, %esi
leaq 0xc81(%rip), %rdx       # 0x201f
callq 0x1660
movq -0x388(%rbp), %rax
movq %rax, -0x290(%rbp)
movq -0x380(%rbp), %rax
movq %rax, -0x288(%rbp)
movq -0x378(%rbp), %rax
movq %rax, -0x280(%rbp)
leaq -0x3a0(%rbp), %rdi
xorl %esi, %esi
movl $0x55, %edx
callq 0x16c0
movq -0x3a0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x398(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x390(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x3b8(%rbp), %rdi
xorl %esi, %esi
movl $0x23, %edx
callq 0x16c0
movq -0x3b8(%rbp), %rax
movq %rax, -0x2c0(%rbp)
movq -0x3b0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x3a8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq 0x2b72(%rip), %rax      # 0x3fc0
movq (%rax), %rcx
movq %rcx, -0x2d8(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x2d0(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x2c8(%rbp)
leaq -0x3d0(%rbp), %rdi
movl $0x1, %esi
leaq 0xb93(%rip), %rdx       # 0x2014
callq 0x16f0
movq -0x3d0(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x3c8(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq -0x3c0(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x3d8(%rbp)
xorl %eax, %eax
movq %rsp, %rax
movq %rax, %rdi
addq $0x78, %rdi
movl $0x19, %ecx
leaq -0x278(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x3d8(%rbp), %rdi
movq -0x2c8(%rbp), %rcx
movq %rcx, 0x70(%rax)
movups -0x2d8(%rbp), %xmm0
movups %xmm0, 0x60(%rax)
movq -0x2e0(%rbp), %rcx
movq %rcx, 0x58(%rax)
movups -0x2f0(%rbp), %xmm0
movups %xmm0, 0x48(%rax)
movq -0x2b0(%rbp), %rcx
movq %rcx, 0x40(%rax)
movups -0x2c0(%rbp), %xmm0
movups %xmm0, 0x30(%rax)
movq -0x298(%rbp), %rcx
movq %rcx, 0x28(%rax)
movups -0x2a8(%rbp), %xmm0
movups %xmm0, 0x18(%rax)
movq -0x280(%rbp), %rcx
movq %rcx, 0x10(%rax)
movups -0x290(%rbp), %xmm0
movups %xmm0, (%rax)
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1750
movb $0x1, 0x2b2c(%rip)      # 0x4089
movq -0x48(%rbp), %rdi
leaq 0x2b21(%rip), %rsi      # 0x4089
callq 0x10b0
movq -0x48(%rbp), %rdi
callq 0x10e0
xorl %eax, %eax
addq $0x540, %rsp            # imm = 0x540
popq %rbp
retq
nopw %cs:(%rax,%rax)