// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//

using System;
using System.Collections;
using System.Runtime.InteropServices;
using Xunit;

public enum TestEnum
{
    red = 1,
    green = 2,
    blue = 4,
}

public class AA
{
    public bool[][,][, ,][][][][] m_abField1;
    public static float m_fStatic1;
    public static ushort Static1(ref char[, ,] param1, ref byte[, ,] param2, ulong
        param3, bool[, ,] param4)
    {
        short local1 = App.m_shFwd1;
        while (App.m_bFwd2)
        {
            object local2 = ((object)(TestEnum.red));
            byte local3 = ((byte)(88u));
            long local4 = App.m_lFwd3;
            short local5 = App.m_shFwd1;
            try
            {
                byte local6 = ((byte)(37u));
                local6 = (local6 += local3);
            }
            catch (InvalidOperationException)
            {
                sbyte[, ,][][][] local7 = (new sbyte[89u, 48u, 47u][][][]);
                ulong local8 = ((ulong)(67u));
#pragma warning disable 1717
                local3 = (local3 = local3);
                AA.m_fStatic1 = AA.m_fStatic1;
#pragma warning restore 1717
            }
            do
            {
                AA.m_fStatic1 = (45.0f + local4);
                try
                {
                    goto label1;
                }
                catch (NullReferenceException)
                {
                    param2[109, 35, 92] = (local3 += local3);
                }
            label1:
                do
                {
#pragma warning disable 1717
                    AA.m_fStatic1 *= (AA.m_fStatic1 = AA.m_fStatic1);
#pragma warning restore 1717
                    do
                    {
                    }
                    while (((bool)(local2)));
                }
                while (((bool)(local2)));
            }
            while (((bool)(local2)));
            local5 += local1;
        }
        for (App.m_sbyFwd4 = ((sbyte)(local1)); App.m_bFwd2; local1 *= (local1 -= local1)
            )
        {
        }
        param1[74, 65, ((int)(AA.m_fStatic1))] = '\x30';
        return ((ushort)(33u));
    }
    public static uint Static2(String[,] param1, double param2, ref long param3)
    {
        for (App.m_iFwd5 -= 20; (87.0 == param2); App.m_chFwd6 /= '\x2e')
        {
            Array[,][] local9 = (new Array[36u, 24u][]);
            char local10 = ((char)(121));
            bool local11 = false;
            String local12 = "120";
            String local13 = "110";
            try
            {
                ushort[,] local14 = (new ushort[80u, 97u]);
                sbyte local15 = Convert.ToSByte('\x72');
                ushort local16 = Convert.ToUInt16(56.0);
                param1[((int)(param2)), 17] = "35";
                while (local11)
                {
                    AA.Static1(
                        ref App.m_achFwd7,
                        ref App.m_abyFwd8,
                        App.m_ulFwd9,
                        (new bool[20u, 47u, 26u]));
                    if (local11)
                        try
                        {
                            throw new InvalidOperationException();
                        }
                        catch (NullReferenceException)
                        {
                            continue;
                        }
#pragma warning disable 1717
                    local11 = local11;
#pragma warning restore 1717
                }
            }
            finally
            {
                do
                {
                }
                while ((local11 || true));
                local10 = '\x11';
                do
                {
                }
                while (local11);
            }
            if (local11)
                return 93u;
            continue;
        }
        try
        {
        }
        catch (Exception)
        {
        }
        param1[106, ((int)('\x40'))] = "34";
        return 17u;
    }
    public static byte Static3(ref byte param1, ref char param2, ref char[,][,][, ,]
         param3, ref ulong param4, double param5, TestEnum[, ,] param6, sbyte param7,
        ulong[, , ,][, ,][, ,] param8)
    {
        return param1;
    }
    public static double[, ,] Static4(Array[][, ,] param1, long param2, ushort param3
        , ref Array param4, float[][] param5, ref byte[] param6, float[,] param7, ref 
		TestEnum param8)
    {
        double[][,] local17 = (new double[101u][,]);
        int[,] local18 = (new int[85u, 101u]);
        ushort local19 = ((ushort)(77.0f));
        return (new double[48u, 34u, 29u]);
    }
    public static sbyte[][,] Static5(double[] param1, ref char param2, ref 
		object[,] param3, ushort param4, bool[][] param5, ref float param6, uint[, ,][]
         param7, long param8)
    {
        AA.m_fStatic1 /= AA.m_fStatic1;
        try
        {
            float local20 = ((float)(50));
            double[,] local21 = (new double[91u, 31u]);
            TestEnum[, ,] local22 = (new TestEnum[69u, 7u, 94u]);
            for (param2 += '\x6d'; Convert.ToBoolean(AA.m_fStatic1); App.m_uFwd10 /= AA.
                Static2((new String[36u, 114u]), 48.0, ref param8))
            {
                byte[][][, , ,][, ,] local23 = new byte[][][,,,][,,]{(new byte[36u][,,,][,,]), 
					(new byte[85u][,,,][,,]), (new byte[77u][,,,][,,]), new byte[][,,,][,,]{
					(new byte[122u, 118u, 41u, 13u][,,]), (new byte[20u, 126u, 99u, 44u][,,]), 
					(new byte[18u, 96u, 14u, 125u][,,]) }, (new byte[37u][,,,][,,]) };
                sbyte[,][, ,][,][, ,][][, , ,] local24 = (new sbyte[66u, 74u][, ,][,][,,][][,,,])
                    ;
                TestEnum[,] local25 = (new TestEnum[112u, 103u]);
                String[,] local26 = (new String[114u, 47u]);
                goto label2;
            }
            goto label3;
        }
        finally
        {
            ushort local27 = ((ushort)(17.0));
#pragma warning disable 1717
            for (App.m_ulFwd9 *= ((ulong)(85.0)); Convert.ToBoolean(param8); param2 -= param2
                )
            {
                AA.m_fStatic1 += (param6 = param6);
#pragma warning restore 1717
                do
                {
                    AA.Static3(
                        ref App.m_byFwd11,
                        ref param2,
                        ref App.m_achFwd12,
                        ref App.m_ulFwd9,
                        (67.0 - param6),
                        (new TestEnum[41u, 27u, 5u]),
                        App.m_sbyFwd4,
                        (new ulong[54u, 94u, 4u, 113u][, ,][,,]));
                    try
                    {
                        while (App.m_bFwd2)
                        {
                            param7[123, 77, 111][63] -= AA.Static2((new String[113u, 113u]), 117.0,
                                ref param8);
                        }
                        do
                        {
                        }
                        while (App.m_bFwd2);
                        for (param8 /= (param8 | param8); App.m_bFwd2; App.m_uFwd10 -= ((uint)(110.0))
                            )
                        {
                        }
                    }
                    catch (Exception)
                    {
                    }
                    param4 *= param4;
                }
                while (App.m_bFwd2);
                AA.m_fStatic1 /= AA.m_fStatic1;
            }
        }
    label3:
    label2:
        return new sbyte[][,] { (new sbyte[50u, 121u]), (new sbyte[59u, 10u]) };
    }
}

[StructLayout(LayoutKind.Sequential)]
public class App
{
    [Fact]
    public static void TestEntryPoint()
    {
        try
        {
            Console.WriteLine("Testing AA::Static1");
            AA.Static1(
                ref App.m_achFwd7,
                ref App.m_abyFwd8,
                App.m_ulFwd9,
                (new bool[2u, 84u, 69u]));
        }
        catch (Exception x)
        {
            Console.WriteLine("Exception handled: " + x.ToString());
        }
        try
        {
            Console.WriteLine("Testing AA::Static2");
            AA.Static2(
                (new String[13u, 8u]),
                55.0,
                ref App.m_lFwd3);
        }
        catch (Exception x)
        {
            Console.WriteLine("Exception handled: " + x.ToString());
        }
        try
        {
            Console.WriteLine("Testing AA::Static3");
            AA.Static3(
                ref App.m_byFwd11,
                ref App.m_chFwd6,
                ref App.m_achFwd12,
                ref App.m_ulFwd9,
                118.0,
                (new TestEnum[46u, 80u, 35u]),
                ((sbyte)(72)),
                (new ulong[97u, 36u, 52u, 126u][, ,][,,]));
        }
        catch (Exception x)
        {
            Console.WriteLine("Exception handled: " + x.ToString());
        }
        try
        {
            Console.WriteLine("Testing AA::Static4");
            AA.Static4(
                (new Array[80u][, ,]),
                ((long)(88)),
                ((ushort)(AA.m_fStatic1)),
                ref App.m_xFwd13,
                (new float[16u][]),
                ref App.m_abyFwd14,
                (new float[93u, 70u]),
                ref App.m_xFwd15);
        }
        catch (Exception x)
        {
            Console.WriteLine("Exception handled: " + x.ToString());
        }
        try
        {
            Console.WriteLine("Testing AA::Static5");
            AA.Static5(
                (new double[66u]),
                ref App.m_chFwd6,
                ref App.m_aobjFwd16,
                ((ushort)(119u)),
                new bool[][]{new bool[]{true, false, false }, new bool[]{true, true, true }
					, new bool[]{false, true }, (new bool[126u]), (new bool[4u]) },
                ref AA.m_fStatic1,
                (new uint[52u, 87u, 34u][]),
                App.m_lFwd3);
        }
        catch (Exception x)
        {
            Console.WriteLine("Exception handled: " + x.ToString());
        }
        Console.WriteLine("Passed.");
    }
    public static short m_shFwd1;
    public static bool m_bFwd2;
    public static long m_lFwd3;
    public static sbyte m_sbyFwd4;
    public static int m_iFwd5;
    public static char m_chFwd6;
    public static char[, ,] m_achFwd7;
    public static byte[, ,] m_abyFwd8;
    public static ulong m_ulFwd9;
    public static uint m_uFwd10;
    public static byte m_byFwd11;
    public static char[,][,][, ,] m_achFwd12;
    public static Array m_xFwd13;
    public static byte[] m_abyFwd14;
    public static TestEnum m_xFwd15;
    public static object[,] m_aobjFwd16;
}
