#include "GetAttribute.h"
#include "XML.h"
#include "CFTTVector32x4.h"
#include "CRSplineF.h"
int GetFlag(CFTTXmlReaderNode a1, char const *a2, bool a3)
{
    LOGE("%x%x%x%x", a1.prapidxml_xml_node_0, a2, a3, rand());
    return rand();
}


double stod_19249A(char *a1)
{
    return strtod(a1, 0);
}

int StrToEaser(char const *a1)
{
    return atoi(a1) + rand();
}
// 00191FB8  ^_-
//单元测试等级: 目测游戏表现
//单元测试内容: 1-10
//单元测试结果: 正常
//已测试分支 1 2 3  4 5 6 7 8 9 10 11 12
CAdAttribute<TPointF, TAdPointInterpolator> *GetPointAttribute(CFTTXmlReaderNode r0_node)
{
    LOGE("GetPointAttribute11");
    // sp4c=r0_node
    CFTTXmlReaderNode node_sp70 = r0_node.GetFirstChild("Value");
     LOGE("GetPointAttribute node");
    if (node_sp70.IsValid())
    { // 00191FE6
        LOGE("分支1");
        TPointF pointf_sp0;
        pointf_sp0.fx_0 = 0;
        pointf_sp0.fy_4 = 0;
        TPointF pointf_sp44 = XMLGetPosF(r0_node, "Value", NULL, pointf_sp0);
        int r5_icount = r0_node.CountElement("Easer");
        r5_icount += r0_node.CountElement("SEaser");
        r5_icount += r0_node.CountElement("Spline");
        CAdAttribute<TPointF, TAdPointInterpolator> *pattr_sp24 = new CAdAttribute<TPointF, TAdPointInterpolator>(pointf_sp44, (uchar)r5_icount);
        CFTTXmlReaderNode node_sp40 = r0_node.GetFirstChild("Value");
        node_sp40 = node_sp40.GetNextSibling(NULL);
        float s16_f = 1.0f;
        // loc_1923EE
        while (node_sp40.IsValid())
        {

            // loc_19207A
            char *r5_pname = node_sp40.GetName();
            if (strcmp(r5_pname, "Easer"))
            {
                if (strcmp(r5_pname, "SEaser"))
                {
                    // 0019209A
                    if (strcmp(r5_pname, "Spline") == 0)
                    { // 001920AA
                        bool flag_sp28 = GetFlag(node_sp40, "Loop", false);
                        float s18_f = s16_f;
                        if (flag_sp28)
                        { // 001920C0
                             LOGE("分支2");
                            s18_f = XMLGetFloat(node_sp40, "Loop", NULL, 0);
                        }
                        // loc_1920D2
                        int r8_i = 0;
                        int itime_sp14 = XMLGetInt(node_sp40, "Time", NULL, 0);
                        float falpha_sp10 = XMLGetFloat(node_sp40, "Alpha", NULL, 0);
                        int r9_i = node_sp40.CountElement("Value");
                        CFTTVector32x4 *r5_pvector32x4 = new CFTTVector32x4[r9_i];
                        CFTTVector32x4 *r4_pvector32x4 = r5_pvector32x4;
                        CFTTXmlReaderNode node_sp50 = node_sp40.GetFirstChild("Value");
                        // loc_192162
                        while (node_sp50.IsValid())
                        {
                            // loc_192134
                            LOGE("分支3");
                            TPointF pointf_sp70 = StrToPosF(node_sp50.GetText(NULL));
                            r4_pvector32x4->my[0] = pointf_sp70.fx_0;
                            r4_pvector32x4->my[1] = pointf_sp70.fy_4;
                            r4_pvector32x4->my[2] = 0;
                            r4_pvector32x4->my[3] = 0;
                            node_sp50 = node_sp50.GetNextSibling("Value");
                            r4_pvector32x4++;
                            r8_i++;
                        }
                        // 0019216C
                        float s20_f;
                        float s22_f;
                        if (flag_sp28)
                        { // 00192174
                        LOGE("分支4");
                            s20_f = r5_pvector32x4[1].my[1];
                            s22_f = r5_pvector32x4[1].my[0];
                        }
                        else
                        {    LOGE("分支5");                                 // loc_1922AC
                            s20_f = r4_pvector32x4[-3].my[2]; // check 偏移
                            s22_f = r4_pvector32x4[-3].my[1];
                        }
                        // loc_1922B4
                        node_sp50 = node_sp40.GetFirstChild("SegLength");
                        float *r9_pf;
                        CRSplineF *r7_prsplinef;
                        if (node_sp50.IsValid())
                        {
                            // 001922DC
                            r9_pf = new float[r9_i];
                            float *r4_pf = r9_pf;

                            // loc_192320
                            while (node_sp50.IsValid())
                            {
                                LOGE("分支6");
                                // loc_1922FE
                                *r4_pf = stod_19249A(node_sp50.GetText(NULL));
                                node_sp50 = node_sp50.GetNextSibling("Value");
                                r4_pf++;
                            }
                            // 0019232A
                            // check CRSplineF大小
                            r7_prsplinef = new CRSplineF(r5_pvector32x4, r8_i, falpha_sp10, r9_pf, flag_sp28);
                            delete r9_pf;
                        }
                        else
                        { // loc_19237C
                        LOGE("分支7");
                            r7_prsplinef = new CRSplineF(r5_pvector32x4, r8_i, falpha_sp10, NULL, flag_sp28);
                        }
                        // loc_19239C
                        LOGE("分支8");
                        TAdPointSpline *r0_padpoint_spline = new TAdPointSpline;
                        r0_padpoint_spline->field_c = itime_sp14;
                        r0_padpoint_spline->prsplinef_10 = r7_prsplinef;
                        r0_padpoint_spline->f_14 = s18_f;
                        r0_padpoint_spline->pointf_04.fx_0 = s22_f;
                        r0_padpoint_spline->pointf_04.fy_4 = s20_f;
                        pattr_sp24->pBuf_10[pattr_sp24->c_14++] = r0_padpoint_spline; // check
                        delete[] r5_pvector32x4;
                    }
                    // loc_1923E6
                    node_sp40 = node_sp40.GetNextSibling(NULL);
                }
                else
                {
                    // loc_1921E4
                    char pc_sp70[0x20];
                    char pc_sp50[0x20];
                    int i = 0;
                    char *r0_pc = node_sp40.GetText(NULL);
                    ////loc_1921FC
                    while (*r0_pc)
                    {
                        LOGE("分支9");
                        char r2_c = *r0_pc;
                        if (r2_c == ' ')
                        { // loc_1921F2
                            r2_c = *(++r0_pc);
                        }
                        // loc_1921F6
                        pc_sp70[i++] = r2_c;
                        r0_pc++;
                    }
                    // 00192206
                    LOGE("分支10");
                    pc_sp70[i] = 0;
                    char *r4_pc1 = strchr(pc_sp70, 0x2c);
                    char *r5_pc2 = strchr(r4_pc1 + 1, 0x2c);
                    int r4_i = r4_pc1 - pc_sp70;
                    int r8_i = strlen(pc_sp70);
                    memcpy(pc_sp50, pc_sp70, r4_i);
                    int r6_i = r5_pc2 - pc_sp70;
                    pc_sp50[r4_i] = 0;
                    r4_i = r6_i - r4_i - 1;
                    int r9_i = atoi(pc_sp50);
                    memcpy(pc_sp50, r4_pc1 + 1, r4_i);
                    pc_sp50[r4_i] = 0;
                    r4_i = StrToEaser(pc_sp50);
                    int r5_i = r8_i - r6_i - 1;
                    memcpy(pc_sp50, r5_pc2 + 1, r5_i);
                    pc_sp50[r5_i] = 0;
                    TPointF pointf_sp38 = StrToPosF(pc_sp50);
                    TAdPointEaser *r0_adpointeaser = new TAdPointEaser;
                    r0_adpointeaser->field_c = r9_i;
                   
                    r0_adpointeaser->pointf_04 = pointf_sp38;
                    r0_adpointeaser->i_10 = r4_i;
                    pattr_sp24->pBuf_10[pattr_sp24->c_14++] = r0_adpointeaser;
                    // loc_1923E6
                    node_sp40 = node_sp40.GetNextSibling(NULL);
                }
            }
            else
            { // loc_19217E
            LOGE("分支11");
                int r8_i = XMLGetInt(node_sp40, "Time", NULL, 0);
                TPointF pointf_sp0;
                pointf_sp0.fx_0 = 0;
                pointf_sp0.fy_4 = 0;
                TPointF pointf_sp70 = XMLGetPosF(node_sp40, "Value", 0, pointf_sp0);
                char *r5_pc = XMLGetString(node_sp40, "Type", NULL, NULL);

                TAdPointEaser *r4_padpointeaser = new TAdPointEaser;

                int r0_i = StrToEaser(r5_pc);
                r4_padpointeaser->field_c = r8_i;
                r4_padpointeaser->pointf_04 = pointf_sp70;
                r4_padpointeaser->i_10 = r0_i;
                pattr_sp24->pBuf_10[pattr_sp24->c_14++] = 
                r4_padpointeaser;
                // loc_1923E6
                node_sp40 = node_sp40.GetNextSibling(NULL);
            }
        }
        LOGE("end ");
        // loc_192430
        return pattr_sp24;
    }
    else
    { // loc_192400
    LOGE("分支12");
        TPointF pointf_sp70 = StrToPosF(r0_node.GetText(NULL));
        CAdAttribute<TPointF, TAdPointInterpolator> *r9_pattr = new CAdAttribute<TPointF, TAdPointInterpolator>();

        r9_pattr->mem_00 = pointf_sp70;
        r9_pattr->mem_08 = pointf_sp70;
        r9_pattr->pBuf_10 = 0;
        r9_pattr->c_14 = 0;
        r9_pattr->cLen_15 = 0;
        return r9_pattr;
    }
}