//package compiler.c2.aarch64;
import java.lang.reflect.Field;
import jdk.internal.misc.Unsafe;

class TestUnsafeVolatileStore
{
    public volatile int f_int = 0;
    public volatile Integer f_obj = Integer.valueOf(0);

    public static Unsafe unsafe = Unsafe.getUnsafe();
    public static Field f_int_field;
    public static Field f_obj_field;
    public static long f_int_off;
    public static long f_obj_off;

    static {
        try {
            f_int_field = TestUnsafeVolatileStore.class.getField("f_int");
            f_obj_field = TestUnsafeVolatileStore.class.getField("f_obj");
            f_int_off = unsafe.objectFieldOffset(f_int_field);
            f_obj_off = unsafe.objectFieldOffset(f_obj_field);
        } catch (Exception e) {
            System.out.println("reflection failed " + e);
            e.printStackTrace();
        }
    }

    public static void main(String[] args)
    {
        final TestUnsafeVolatileStore t = new TestUnsafeVolatileStore();
        for (int i = 0; i < 100_000; i++) {
            t.f_int = -1;
            t.testInt(i);
            if (t.f_int != i) {
                throw new RuntimeException("bad result!");
            }
        }
        for (int i = 0; i < 100_000; i++) {
            t.f_obj = null;
            t.testObj(Integer.valueOf(i));
            if (t.f_obj != i) {
                throw new RuntimeException("bad result!");
            }
        }
    }
    
public static long method7(long var) {
return var + 8217;
}

public static int method10(long var) {
return var == 0? 0:(int)(var * 8217/var);
}

public static int method43(long var) {
return var == 0? 0:(int)(var * 339/var);
}

public static long method56(long var) {
return var + 3086;
}

public static int method80(long var) {
return var == 0? 0:(int)(var * 339/var);
}

public static long method81(long var) {
return var + 0;
}
public void testInt(int i)
    {
        synchronized (TestUnsafeVolatileStore.class) {


try {
Class <?> Class18 = Class.forName("TestUnsafeVolatileStore");


Class <?> Class35 = Class.forName("TestUnsafeVolatileStore");

Class <?> Class51 = Class.forName("TestUnsafeVolatileStore");


unsafe.putIntVolatile(this, (((long)Class18.getDeclaredMethod("method7", long.class).invoke(null, (method56((long)(~(((long)(f_int_off << 0))&(method81(f_int_off)))))-3086)))-((int)Class35.getDeclaredMethod("method10", long.class).invoke(null, (long)(f_int_off + 0)))), (int)((((i-method80(f_int_off))*1+1160)-(496+1160))+(1*((int)Class51.getDeclaredMethod("method43", long.class).invoke(null, (long)(~((f_int_off)|(f_int_off)))))+496)));

}catch (Exception eeeeeeee){throw new RuntimeException(eeeeeeee);}

}
    }
    public void testObj(Object o)
    {
        unsafe.putObjectVolatile(this, f_obj_off, o);
    }
}