// File: /workspace/github_c_makefile_star2_O0/soso7885[P]OPCUA_example/demo_src/server_method.c
// Function: main
int main(int argc, char** argv) {
    signal(SIGINT, stopHandler); /* catches ctrl-c */

    /* initialize the server */
    UA_ServerConfig config = UA_ServerConfig_standard;
    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
    config.networkLayers = &nl;
    config.networkLayersSize = 1;
    UA_Server *server = UA_Server_new(config);

    //EXAMPLE 1
    /* add the method node with the callback */
    UA_Argument inputArguments;
    UA_Argument_init(&inputArguments);
    inputArguments.arrayDimensionsSize = 0;
    inputArguments.arrayDimensions = NULL;
    inputArguments.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
    inputArguments.description = UA_LOCALIZEDTEXT("en_US", "A String");
    inputArguments.name = UA_STRING("MyInput");
    inputArguments.valueRank = -1;

    UA_Argument outputArguments;
    UA_Argument_init(&outputArguments);
    outputArguments.arrayDimensionsSize = 0;
    outputArguments.arrayDimensions = NULL;
    outputArguments.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
    outputArguments.description = UA_LOCALIZEDTEXT("en_US", "A String");
    outputArguments.name = UA_STRING("MyOutput");
    outputArguments.valueRank = -1;
        
    UA_MethodAttributes helloAttr;
    UA_MethodAttributes_init(&helloAttr);
    helloAttr.description = UA_LOCALIZEDTEXT("en_US","Say `Hello World`");
    helloAttr.displayName = UA_LOCALIZEDTEXT("en_US","Hello World");
    helloAttr.executable = true;
    helloAttr.userExecutable = true;
    UA_Server_addMethodNode(server, UA_NODEID_NUMERIC(1,62541),
                            UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
                            UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
                            UA_QUALIFIEDNAME(1, "hello world"), 
                            helloAttr, &helloWorldMethod, NULL,
                            1, &inputArguments, 1, &outputArguments, NULL);

    //END OF EXAMPLE 1

    //EXAMPLE 2
    /* add another method node: output argument as 1d Int32 array*/
    // define input arguments
    UA_Argument_init(&inputArguments);
    inputArguments.arrayDimensionsSize = 1;
    UA_UInt32 * pInputDimensions = UA_UInt32_new();
    pInputDimensions[0] = 5;
    inputArguments.arrayDimensions = pInputDimensions;
    inputArguments.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
    inputArguments.description = UA_LOCALIZEDTEXT("en_US",
                    "input an array with 5 elements, type int32");
    inputArguments.name = UA_STRING("int32 value");
    inputArguments.valueRank = 1;

    // define output arguments
    UA_Argument_init(&outputArguments);
    outputArguments.arrayDimensionsSize = 1;
    UA_UInt32 * pOutputDimensions = UA_UInt32_new();
    pOutputDimensions[0] = 5;
    outputArguments.arrayDimensions = pOutputDimensions;
    outputArguments.dataType = UA_TYPES[UA_TYPES_INT32].typeId;
    outputArguments.description = UA_LOCALIZEDTEXT("en_US", "increment each array index");
    outputArguments.name = UA_STRING("output is the array, each index is incremented by one");
    outputArguments.valueRank = 1;

    
    UA_MethodAttributes incAttr;
    UA_MethodAttributes_init(&incAttr);
    incAttr.description = UA_LOCALIZEDTEXT("en_US","1dArrayExample");
    incAttr.displayName = UA_LOCALIZEDTEXT("en_US","1dArrayExample");
    incAttr.executable = true;
    incAttr.userExecutable = true;
    UA_Server_addMethodNode(server, UA_NODEID_STRING(1, "IncInt32ArrayValues"),
                            UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
                            UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT), 
                            UA_QUALIFIEDNAME(1, "IncInt32ArrayValues"),
                            incAttr, &IncInt32ArrayValuesMethod, NULL,
                            1, &inputArguments, 1, &outputArguments, NULL);
    //END OF EXAMPLE 2

    /* If out methodnode is part of an instantiated object, we never had
       the opportunity to define the callback... we could do that now
    */
    UA_Server_setMethodNode_callback(server, UA_NODEID_NUMERIC(1,62541), &fooBarMethod, NULL);
    
    //END OF EXAMPLE 3
    /* start server */
    UA_StatusCode retval = UA_Server_run(server, &running);

    /* ctrl-c received -> clean up */
    UA_UInt32_delete(pInputDimensions);
    UA_UInt32_delete(pOutputDimensions);
    UA_Server_delete(server);
    nl.deleteMembers(&nl);

    return (int)retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6e0, %rsp            # imm = 0x6E0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x2, %edi
leaq 0x93b(%rip), %rsi       # 0x1ba0
callq 0x10d0
leaq -0x170(%rbp), %rdi
movq 0x3d68(%rip), %rsi      # 0x4fe0
movl $0x160, %edx            # imm = 0x160
callq 0x10c0
movq 0x3d67(%rip), %rax      # 0x4ff0
movq (%rax), %rcx
movq %rcx, -0x1c0(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x1b8(%rbp)
movl 0x10(%rax), %eax
movl %eax, -0x1b0(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1c0(%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 0x1060
leaq -0x1a8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq $0x1, -0x80(%rbp)
movq %rsp, %rdi
movl $0x2c, %ecx
leaq -0x170(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x1030
movq %rax, -0x1c8(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x1be0
movq $0x0, -0x1f8(%rbp)
movq $0x0, -0x1f0(%rbp)
movq 0x3ca8(%rip), %rax      # 0x4fd8
movq 0x1b8(%rax), %rcx
movq %rcx, -0x218(%rbp)
movq 0x1c0(%rax), %rcx
movq %rcx, -0x210(%rbp)
movq 0x1c8(%rax), %rax
movq %rax, -0x208(%rbp)
leaq -0x248(%rbp), %rdi
leaq 0x1c9c(%rip), %rsi      # 0x3004
leaq 0x1c9b(%rip), %rdx      # 0x300a
callq 0x1c10
movq -0x248(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x238(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0x230(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq 0x1c60(%rip), %rdi      # 0x3013
callq 0x1c80
movq %rax, -0x258(%rbp)
movq %rdx, -0x250(%rbp)
movq -0x258(%rbp), %rax
movq %rax, -0x228(%rbp)
movq -0x250(%rbp), %rax
movq %rax, -0x220(%rbp)
movl $0xffffffff, -0x200(%rbp) # imm = 0xFFFFFFFF
leaq -0x2b8(%rbp), %rdi
callq 0x1be0
movq $0x0, -0x288(%rbp)
movq $0x0, -0x280(%rbp)
movq 0x3bc3(%rip), %rax      # 0x4fd8
movq 0x1b8(%rax), %rcx
movq %rcx, -0x2a8(%rbp)
movq 0x1c0(%rax), %rcx
movq %rcx, -0x2a0(%rbp)
movq 0x1c8(%rax), %rax
movq %rax, -0x298(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq 0x1bb7(%rip), %rsi      # 0x3004
leaq 0x1bb6(%rip), %rdx      # 0x300a
callq 0x1c10
movq -0x2d8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x2d0(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x2c8(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x2c0(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq 0x1b83(%rip), %rdi      # 0x301b
callq 0x1c80
movq %rax, -0x2e8(%rbp)
movq %rdx, -0x2e0(%rbp)
movq -0x2e8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x2e0(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl $0xffffffff, -0x290(%rbp) # imm = 0xFFFFFFFF
leaq -0x340(%rbp), %rdi
callq 0x1cb0
leaq -0x360(%rbp), %rdi
leaq 0x1b19(%rip), %rsi      # 0x3004
leaq 0x1b32(%rip), %rdx      # 0x3024
callq 0x1c10
movq -0x360(%rbp), %rax
movq %rax, -0x318(%rbp)
movq -0x358(%rbp), %rax
movq %rax, -0x310(%rbp)
movq -0x350(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x348(%rbp), %rax
movq %rax, -0x300(%rbp)
leaq -0x380(%rbp), %rdi
leaq 0x1ac7(%rip), %rsi      # 0x3004
leaq 0x1af2(%rip), %rdx      # 0x3036
callq 0x1c10
movq -0x380(%rbp), %rax
movq %rax, -0x338(%rbp)
movq -0x378(%rbp), %rax
movq %rax, -0x330(%rbp)
movq -0x370(%rbp), %rax
movq %rax, -0x328(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x320(%rbp)
movb $0x1, -0x2f0(%rbp)
movb $0x1, -0x2ef(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x580(%rbp)
leaq -0x398(%rbp), %rdi
movl $0x1, %esi
movl $0xf44d, %edx           # imm = 0xF44D
callq 0x1ce0
leaq -0x3b0(%rbp), %rdi
xorl %esi, %esi
movl $0x55, %edx
callq 0x1ce0
leaq -0x3c8(%rbp), %rdi
xorl %esi, %esi
movl $0x2f, %edx
callq 0x1ce0
leaq -0x3e0(%rbp), %rdi
movl $0x1, %esi
leaq 0x1a56(%rip), %rdx      # 0x3042
callq 0x1d10
movq -0x580(%rbp), %rdi
xorl %eax, %eax
movq -0x2f0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0xb0(%rax)
movups -0x300(%rbp), %xmm0
movups %xmm0, 0xa0(%rax)
movups -0x340(%rbp), %xmm0
movups -0x330(%rbp), %xmm1
movups -0x320(%rbp), %xmm2
movups -0x310(%rbp), %xmm3
movups %xmm3, 0x90(%rax)
movups %xmm2, 0x80(%rax)
movups %xmm1, 0x70(%rax)
movups %xmm0, 0x60(%rax)
movq -0x3d0(%rbp), %rcx
movq %rcx, 0x58(%rax)
movups -0x3e0(%rbp), %xmm0
movups %xmm0, 0x48(%rax)
movq -0x3b8(%rbp), %rcx
movq %rcx, 0x40(%rax)
movups -0x3c8(%rbp), %xmm0
movups %xmm0, 0x30(%rax)
movq -0x3a0(%rbp), %rcx
movq %rcx, 0x28(%rax)
movups -0x3b0(%rbp), %xmm0
movups %xmm0, 0x18(%rax)
movq -0x388(%rbp), %rcx
movq %rcx, 0x10(%rax)
movups -0x398(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x2b8(%rbp), %rcx
movq %rcx, 0xb8(%rax)
movq $0x0, 0xc0(%rax)
leaq 0x6ae(%rip), %rsi       # 0x1d70
xorl %eax, %eax
movl %eax, %edx
leaq -0x228(%rbp), %r8
movl $0x1, %r9d
movq %r9, %rcx
callq 0x1040
leaq -0x228(%rbp), %rdi
callq 0x1be0
movq $0x1, -0x1f8(%rbp)
callq 0x1e50
movq %rax, -0x3e8(%rbp)
movq -0x3e8(%rbp), %rax
movl $0x5, (%rax)
movq -0x3e8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq 0x38b8(%rip), %rax      # 0x4fd8
movq 0xc8(%rax), %rcx
movq %rcx, -0x218(%rbp)
movq 0xd0(%rax), %rcx
movq %rcx, -0x210(%rbp)
movq 0xd8(%rax), %rax
movq %rax, -0x208(%rbp)
leaq -0x408(%rbp), %rdi
leaq 0x18ac(%rip), %rsi      # 0x3004
leaq 0x18ef(%rip), %rdx      # 0x304e
callq 0x1c10
movq -0x408(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x400(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movq -0x3f8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
movq -0x3f0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq 0x18d6(%rip), %rdi      # 0x3079
callq 0x1c80
movq %rax, -0x418(%rbp)
movq %rdx, -0x410(%rbp)
movq -0x418(%rbp), %rax
movq %rax, -0x228(%rbp)
movq -0x410(%rbp), %rax
movq %rax, -0x220(%rbp)
movl $0x1, -0x200(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x1be0
movq $0x1, -0x288(%rbp)
callq 0x1e50
movq %rax, -0x420(%rbp)
movq -0x420(%rbp), %rax
movl $0x5, (%rax)
movq -0x420(%rbp), %rax
movq %rax, -0x280(%rbp)
movq 0x37b7(%rip), %rax      # 0x4fd8
movq 0xc8(%rax), %rcx
movq %rcx, -0x2a8(%rbp)
movq 0xd0(%rax), %rcx
movq %rcx, -0x2a0(%rbp)
movq 0xd8(%rax), %rax
movq %rax, -0x298(%rbp)
leaq -0x440(%rbp), %rdi
leaq 0x17ab(%rip), %rsi      # 0x3004
leaq 0x1825(%rip), %rdx      # 0x3085
callq 0x1c10
movq -0x440(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x438(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x430(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0x428(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq 0x17fc(%rip), %rdi      # 0x30a0
callq 0x1c80
movq %rax, -0x450(%rbp)
movq %rdx, -0x448(%rbp)
movq -0x450(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x448(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl $0x1, -0x290(%rbp)
leaq -0x4a8(%rbp), %rdi
callq 0x1cb0
leaq -0x4c8(%rbp), %rdi
leaq 0x170d(%rip), %rsi      # 0x3004
leaq 0x17d8(%rip), %rdx      # 0x30d6
callq 0x1c10
movq -0x4c8(%rbp), %rax
movq %rax, -0x480(%rbp)
movq -0x4c0(%rbp), %rax
movq %rax, -0x478(%rbp)
movq -0x4b8(%rbp), %rax
movq %rax, -0x470(%rbp)
movq -0x4b0(%rbp), %rax
movq %rax, -0x468(%rbp)
leaq -0x4e8(%rbp), %rdi
leaq 0x16bb(%rip), %rsi      # 0x3004
leaq 0x1786(%rip), %rdx      # 0x30d6
callq 0x1c10
movq -0x4e8(%rbp), %rax
movq %rax, -0x4a0(%rbp)
movq -0x4e0(%rbp), %rax
movq %rax, -0x498(%rbp)
movq -0x4d8(%rbp), %rax
movq %rax, -0x490(%rbp)
movq -0x4d0(%rbp), %rax
movq %rax, -0x488(%rbp)
movb $0x1, -0x458(%rbp)
movb $0x1, -0x457(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0x578(%rbp)
leaq -0x500(%rbp), %rdi
movl $0x1, %esi
leaq 0x1729(%rip), %rdx      # 0x30e5
callq 0x1e70
leaq -0x518(%rbp), %rdi
xorl %esi, %esi
movl $0x55, %edx
callq 0x1ce0
leaq -0x530(%rbp), %rdi
xorl %esi, %esi
movl $0x2f, %edx
callq 0x1ce0
leaq -0x548(%rbp), %rdi
movl $0x1, %esi
leaq 0x16eb(%rip), %rdx      # 0x30e5
callq 0x1d10
movq -0x578(%rbp), %rdi
xorl %eax, %eax
movq -0x458(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0xb0(%rax)
movups -0x468(%rbp), %xmm0
movups %xmm0, 0xa0(%rax)
movups -0x4a8(%rbp), %xmm0
movups -0x498(%rbp), %xmm1
movups -0x488(%rbp), %xmm2
movups -0x478(%rbp), %xmm3
movups %xmm3, 0x90(%rax)
movups %xmm2, 0x80(%rax)
movups %xmm1, 0x70(%rax)
movups %xmm0, 0x60(%rax)
movq -0x538(%rbp), %rcx
movq %rcx, 0x58(%rax)
movups -0x548(%rbp), %xmm0
movups %xmm0, 0x48(%rax)
movq -0x520(%rbp), %rcx
movq %rcx, 0x40(%rax)
movups -0x530(%rbp), %xmm0
movups %xmm0, 0x30(%rax)
movq -0x508(%rbp), %rcx
movq %rcx, 0x28(%rax)
movups -0x518(%rbp), %xmm0
movups %xmm0, 0x18(%rax)
movq -0x4f0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movups -0x500(%rbp), %xmm0
movups %xmm0, (%rax)
leaq -0x2b8(%rbp), %rcx
movq %rcx, 0xb8(%rax)
movq $0x0, 0xc0(%rax)
leaq 0x400(%rip), %rsi       # 0x1ed0
xorl %eax, %eax
movl %eax, %edx
leaq -0x228(%rbp), %r8
movl $0x1, %r9d
movq %r9, %rcx
callq 0x1040
movq -0x1c8(%rbp), %rax
movq %rax, -0x570(%rbp)
leaq -0x560(%rbp), %rdi
movl $0x1, %esi
movl $0xf44d, %edx           # imm = 0xF44D
callq 0x1ce0
movq -0x570(%rbp), %rdi
leaq -0x560(%rbp), %rax
leaq 0x43e(%rip), %rsi       # 0x1f60
xorl %ecx, %ecx
movl %ecx, %edx
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x1110
movq -0x1c8(%rbp), %rdi
leaq 0x355e(%rip), %rsi      # 0x50b0
callq 0x10e0
movl %eax, -0x564(%rbp)
movq -0x3e8(%rbp), %rdi
callq 0x2040
movq -0x420(%rbp), %rdi
callq 0x2040
movq -0x1c8(%rbp), %rdi
callq 0x1130
leaq -0x1a8(%rbp), %rdi
callq *-0x178(%rbp)
movl -0x564(%rbp), %eax
addq $0x6e0, %rsp            # imm = 0x6E0
popq %rbp
retq
nopl (%rax)