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


void script_5999(int a0,int a1,int a2,int a3) {
	int v6;
	int v2;
	int v5 = cs2method_10968(cs2method_10060(a2, a1), 2);
	int v1 = globalarray_0[v5];
	globalarray_0[v5] = globalarray_0[a1];
	globalarray_0[a1] = v1;
	for (int v3 = a2, int v7 = a2, int v0 = 0, int v4 = 0, int v8 = 0; v7 < a1; v7 = cs2method_10060(v7, 1)) {
		if (idx22mapAttribute(idx17mapData('i', 'J', a0, globalarray_0[v7]), 1933) > 0) {
			v2 = idx22mapAttribute(idx17mapData('i', 'J', a0, globalarray_0[v7]), 1933);
		} else {
			v2 = idx22mapAttribute(idx17mapData('i', 'J', a0, globalarray_0[v7]), 1932);
		}
		if (idx22mapAttribute(idx17mapData('i', 'J', a0, v1), 1933) > 0) {
			v6 = idx22mapAttribute(idx17mapData('i', 'J', a0, v1), 1933);
		} else {
			v6 = idx22mapAttribute(idx17mapData('i', 'J', a0, v1), 1932);
		}
		if (v2 < v6) {
			int v9 = globalarray_0[v7];
			globalarray_0[v7] = globalarray_0[v3];
			globalarray_0[v3] = v9;
			v3 = cs2method_10060(v3, 1);
		}
	}
	globalarray_0[a1] = globalarray_0[v3];
	globalarray_0[v3] = v1;
	if (a2 < cs2method_10461(v3, 1)) {
		script_5999(0, a2, cs2method_10461(v3, 1), a0);
	}
	if (cs2method_10060(v3, 1) < a1) {
		script_5999(0, cs2method_10060(v3, 1), a1, a0);
	}
	return;
}
