// 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 AutoGen;
using Xunit;

// We were receiving an assert on IA64 because the code we were using to determine if a range
// check statically fails was invalid.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50606.0
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AutoGen
{
    public struct VType1
    {
        public sbyte f0;
        public sbyte f1;
        public VType1(int v)
        {
            f0 = ((sbyte)(v));
            f1 = ((sbyte)(v));
        }
    }
    public struct VType2
    {
        public long f0;
        public long f1;
        public VType2(int v)
        {
            f0 = ((long)(v));
            f1 = ((long)(v));
        }
    }
    public class Program
    {
        private int[] _callDepthTable;
        private int[] _paramValueTable;
        public Program()
        {
            _callDepthTable = new int[6];
            _paramValueTable = new int[12];
            int i;
            for (i = 0; (i < _callDepthTable.Length); i = (i + 1))
            {
                _callDepthTable[i] = i;
            }
            for (i = 0; (i < _paramValueTable.Length); i = (i + 1))
            {
                _paramValueTable[i] = i;
            }
        }

        public virtual VType1 Func1(VType1 p0, long p1, uint p2, VType2 p3)
        {
            if ((_callDepthTable[0] < 5))
            {
                _callDepthTable[0] = (_callDepthTable[0] + 1);
            }
            else
            {
                return p0;
            }

            int acc2 = 0;
            int i2 = 0;
            int[] arr02 = new int[5];
            int[] arr12 = new int[5];
            int[] arr22 = new int[5];
            int[] arr32 = new int[5];
            int[] arr42 = new int[5];
            int[] arr52 = new int[5];
            for (i2 = 0; (i2 < 5); i2 = (i2 + 1))
            {
                arr02[i2] = i2;
                arr12[i2] = arr02[i2];
                arr22[i2] = arr12[i2];
                arr32[i2] = arr22[i2];
                arr42[i2] = arr32[i2];
                arr52[i2] = arr42[i2];
            }
            i2 = 0;
            acc2 = 0;
            for (; i2 < 5; i2++)
            {
                acc2 = (acc2 + arr02[i2]);
            }

            if ((acc2 == 0))
            {
                acc2 = arr02[10];
            }
            if ((acc2 == 1))
            {
                acc2 = arr12[10];
            }
            if ((acc2 == 2))
            {
                acc2 = arr22[10];
            }
            if ((acc2 == 3))
            {
                acc2 = arr32[10];
            }
            if ((acc2 == 4))
            {
                acc2 = arr42[10];
            }
            if ((acc2 == 5))
            {
                acc2 = arr52[10];
            }
            if ((acc2 == 6))
            {
                acc2 = arr02[10];
            }
            if ((acc2 == 7))
            {
                acc2 = arr12[10];
            }
            if ((acc2 == 8))
            {
                acc2 = arr22[10];
            }
            if ((acc2 == 9))
            {
                acc2 = arr32[10];
            }


            int i4 = 0;
            int[] arr04 = new int[7];
            int[] arr14 = new int[7];
            int[] arr24 = new int[7];
            int[] arr34 = new int[7];
            int[] arr44 = new int[7];
            for (i4 = 0; (i4 < 7); i4 = (i4 + 1))
            {
                arr04[i4] = i4;
                arr14[i4] = arr04[i4];
                arr24[i4] = arr14[i4];
                arr34[i4] = arr24[i4];
                arr44[i4] = arr34[i4];
            }

            int acc5 = 0;
            int i5 = 0;
            int[] arr05 = new int[3];
            int[] arr15 = new int[3];
            int[] arr25 = new int[3];
            int[] arr35 = new int[3];
            int[] arr45 = new int[3];
            int[] arr55 = new int[3];
            for (i5 = 0; (i5 < 3); i5 = (i5 + 1))
            {
                arr05[i5] = i5;
                arr15[i5] = arr05[i5];
                arr25[i5] = arr15[i5];
                arr35[i5] = arr25[i5];
                arr45[i5] = arr35[i5];
                arr55[i5] = arr45[i5];
            }
            i5 = 0;
            acc5 = 0;
            for (; (i5 < 3); i5 = (i5 + 1))
            {
                acc5 = (acc5 + arr05[i5]);
                for (; (i5 < 3); i5 = (i5 + 1))
                {
                    acc5 = (acc5 + arr15[i5]);
                    for (; (i5 < 3); i5 = (i5 + 1))
                    {
                        acc5 = (acc5 + arr25[i5]);
                        for (; (i5 < 3); i5 = (i5 + 1))
                        {
                            acc5 = (acc5 + arr35[i5]);
                            for (; (i5 < 3); i5 = (i5 + 1))
                            {
                                acc5 = (acc5 + arr45[i5]);
                                for (; (i5 < 3); i5 = (i5 + 1))
                                {
                                    acc5 = (acc5 + arr55[i5]);
                                }
                            }
                        }
                    }
                }
            }
            if ((acc5 == 0))
            {
                acc5 = arr05[3];
            }
            if ((acc5 == 1))
            {
                acc5 = arr15[3];
            }
            if ((acc5 == 2))
            {
                acc5 = arr25[3];
            }
            if ((arr05.Length < 0))
            {
                goto L2;
            }
            acc5 = 0;
            bool stop2 = (arr05.Length > 0);
            for (i5 = 0; (stop2
                        && (i5 <= arr05[i5])); i5 = (i5 + 1))
            {
                arr05[i5] = i5;
                acc5 = (acc5 + arr05[i5]);
                for (i5 = 0; (stop2
                            && (i5 <= arr15[i5])); i5 = (i5 + 1))
                {
                    acc5 = (acc5 + arr15[i5]);
                    i5 = arr15[i5];
                    for (i5 = 0; (stop2
                                && (i5 <= arr25[i5])); i5 = (i5 + 1))
                    {
                        acc5 = (acc5 + arr25[i5]);
                        for (i5 = 0; (stop2
                                    && (i5 <= arr35[i5])); i5 = (i5 + 1))
                        {
                            acc5 = (acc5 + arr35[i5]);
                            for (i5 = 0; (stop2
                                        && (i5 <= arr45[i5])); i5 = (i5 + 1))
                            {
                                acc5 = (acc5 + arr45[i5]);
                                for (i5 = 0; (stop2
                                            && (i5 <= arr55[i5])); i5 = (i5 + 1))
                                {
                                    acc5 = (acc5 + arr55[i5]);
                                    i5 = arr55[i5];
                                    stop2 = (i5 < 2);
                                }
                                stop2 = (i5 < 2);
                            }
                            stop2 = (i5 < 2);
                        }
                        stop2 = (i5 < 2);
                    }
                    stop2 = (i5 < 2);
                }
                stop2 = (i5 < 2);
            }
        L2:
            i5 = 0;

            int acc6 = 0;
            int i6 = 0;
            int[] arr6 = new int[4];
            for (i6 = 0; i6 < 4; i6++)
            {
                arr6[i6] = i6;
            }
            i6 = 0;
            acc6 = 0;
            for (; i6 < 4; i6++)
            {
                acc6 = (acc6 + arr6[i6]);
            }
            if ((acc6 == 0))
            {
                acc6 = arr6[6];
            }

            return p0;
        }

        public virtual int Run()
        {
            try
            {
                this.Func1(new VType1(_paramValueTable[10]), ((long)(_paramValueTable[6])), ((uint)(_paramValueTable[5])), new VType2(_paramValueTable[11]));
            }
            catch (System.Exception exp)
            {
                System.Console.WriteLine("Application Check Failed!");
                System.Console.WriteLine(exp);
                return 1;
            }
            return 100;
        }
        [Fact]
        public static int TestEntryPoint()
        {
            Program prog = new Program();
            int rc = prog.Run();
            System.Console.WriteLine("rc = {0}", rc);
            return rc;
        }
    }
}
