/* 
 * Script decompiled by jagdecs2 v3.2
 * Decompiler opts:
 * --------------
 * t1LocalAnalyzer:true
 * t2LocalAnalyzer:true
 * beautifier:true
 * --------------
 * Made by mgi125 ;)
 */


void script_3852(int a0,int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8) {
	int v11 = 0;
	int v7 = 0;
	int v3 = 0;
	int v8 = cs2method_11144();
	int v6 = 5;
	int v1 = 2047;
	int v5 = 0;
	if (cs2method_11038(a7, a6) == 1 || a6 == -1 && cs2method_10324(a7) == 1) {
		int v0 = cs2method_11063();
		int v2 = cs2method_10179();
		int v10 = cs2method_10967();
		int v4 = cs2method_10215();
		if (a4 == 1) {
			a8 = cs2method_10642();
			a2 = cs2method_10286();
			a1 = cs2method_11144();
			cs2method_20680(new function<none>() {
			}, "", new WidgetPointer(a0));
			int v12 = 0;
		}
		int v15 = cs2method_10461(v8, a1);
		int v12 = cs2method_10051(v15, v6);
		int v13 = cs2method_10051(cs2method_10038(v12, v1), -1);
		int v9 = cs2method_10060(v13, a2);
		if (v9 >= v1) {
			v9 = cs2method_10461(v9, v1);
		}
		if (cs2_configs['cfg1968'] == 1) {
			if (v9 < -500) {
				v9 = cs2method_11048(v9, -500);
			} else {
				v9 = cs2method_10872(v9, 512);
			}
		}
		if (a5 == -1) {
			cs2method_10304(v2, v10, a8, v9, v0, v4);
		} else {
			int v14 = 0;
			while (v14 < a5) {
				if (cs2method_11038(a7, cs2method_10060(a6, v14)) == 1) {
					cs2method_10304(v2, v10, a8, v9, v0, v4);
				}
				v14 = cs2method_10060(v14, 1);
			}
		}
		cs2method_21073(new function<script_8482>(int a0,int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8) {
			script_3852(a7, a3, a2, a4, a6, a0, a5, a1, a8);
			return;
		}, new WidgetPointer(a0), new WidgetPointer(a7), a6, a5, 0, a8, a2, v4, a1, "IIiiiiiii", new WidgetPointer(a0));
	} else {
		script_8481(a0, a7, a6, a5);
	}
	return;
}
