/* 
 * Script decompiled by jagdecs2 v3.2
 * Decompiler opts:
 * --------------
 * t1LocalAnalyzer:true
 * t2LocalAnalyzer:true
 * beautifier:true
 * --------------
 * Made by mgi125 ;)
 */
// Beautifier was aborted, because this function contains unsolved flow blocks.


int script_9846(int a0,int a1,int a2,int a3,int a4) {
	flow_0:
		if (a2 == -1) {
			return 0;
		}
		if (a3 < 0 || a3 >= cs2method_10894(a2)) {
			return 0;
		}
		if (a0 < 0 || a0 >= cs2method_10894(95)) {
			return 0;
		}
		int v3 = cs2method_10640(95, a0);
		int v2 = cs2method_10640(a2, a3);
		int v14 = cs2method_11065(95, a0);
		int v9 = cs2method_11065(a2, a3);
		int v20 = v9;
		if (v3 == -1 || v2 == -1) {
			return 0;
		}
		int v0 = client_configs['cfg160'];
		if (a2 == 94 || cs2method_10675(v3) == v3) {
			v0 = 0;
		}
		int v11 = script_1468(a0);
		int v23 = 0;
		int v6 = 0;
		if (cs2method_10991(v2) == 1) {
			if (cs2method_10936(95, v2) > 0) {
				int v16 = script_7593(v2, v9);
				if (v16 >= v9) {
					return 0;
				}
				v9 = cs2method_10461(v9, v16);
			}
		} else {
			if (v9 > 1) {
				v9 = 1;
			}
		}
		int v24 = 0;
		if (v0 == 1 && script_8887(a1, cs2method_10675(v3)) > -1) {
			v6 = script_7963(a2, cs2method_10675(v3), v14, cs2method_10894(a2));
		} else if (cs2method_10991(v3) == 1 && script_8887(a1, v3) > -1) {
			v6 = script_7963(a2, v3, v14, cs2method_10894(a2));
		} else {
			if (cs2method_11038(a1, a3) == 1 && cs2method_11089() > v9 && script_9822(a1) > -1) {
				v6 = v14;
			}
		}
		if (v6 >= v14) {
			return 0;
		}
		int v4 = cs2method_10461(v14, v6);
		int v1 = 1;
		int v8 = a0;
		int v21 = script_6971();
		if (v6 > 0 || v4 > 1 && v0 == 0 && cs2method_10991(v3) == 0) {
			v1 = 0;
			v8 = cs2method_10060(a0, 1);
		}
		int v19 = v2;
		int v12 = v9;
		int v7 = a2;
		int v5 = 1;
		int v22 = cs2method_10060(v21, v1);
		script_9832_struct(2,0,0) v15 = script_9832(v19, v12, v7, v5, v22);
		int v17 = v15.intpart_1;
		int v13 = v15.intpart_0;
		if (v17 >= v13) {
			return 0;
		}
		if (v0 == 0 && cs2method_10991(v3) == 0) {
			v4 = 1;
		}
		IF (cs2method_11038(a1, a3) == 1) 
			GOTO	flow_40
		GOTO	flow_50
	flow_40:
		if (cs2method_11089() <= v13) {
			cs2method_11070(-1, 0);
		}
		IF (cs2method_11089() > 0) 
			GOTO	flow_46
		IF (v0 == 1) 
			GOTO	flow_43
		GOTO	flow_44
	flow_43:
		IF (cs2method_10936(a2, cs2method_10675(v3)) > 0) 
			GOTO	flow_46
	flow_44:
		IF (cs2method_10991(v3) == 1 && cs2method_10936(a2, v3) > 0) 
			GOTO	flow_46
		GOTO	flow_49
	flow_46:
		if (a2 != 94) {
			int v10 = script_6505(v3, v4, a0, a2, -1, a4, a1);
			/* 
				java.lang.RuntimeException: Stack underflow
					at mgi.tools.jagdecs2.CS2Stack.pop(CS2Stack.java:46)
					at mgi.tools.jagdecs2.FlowBlocksGenerator.processFlowBlock(FlowBlocksGenerator.java:191)
					at mgi.tools.jagdecs2.FlowBlocksGenerator.processGeneration(FlowBlocksGenerator.java:52)
					at mgi.tools.jagdecs2.FlowBlocksGenerator.generate(FlowBlocksGenerator.java:35)
					at mgi.tools.jagdecs2.CS2Decompiler.decompile(CS2Decompiler.java:77)
					at tests.Main.main(Main.java:69)
				
			 */
		}
		GOTO	flow_50
	flow_49:
		int v18 = script_6505(v3, v4, a0, a2, a3, a4, a1);
		/* 
			java.lang.RuntimeException: Stack underflow
				at mgi.tools.jagdecs2.CS2Stack.pop(CS2Stack.java:46)
				at mgi.tools.jagdecs2.FlowBlocksGenerator.processFlowBlock(FlowBlocksGenerator.java:191)
				at mgi.tools.jagdecs2.FlowBlocksGenerator.processGeneration(FlowBlocksGenerator.java:52)
				at mgi.tools.jagdecs2.FlowBlocksGenerator.generate(FlowBlocksGenerator.java:35)
				at mgi.tools.jagdecs2.CS2Decompiler.decompile(CS2Decompiler.java:77)
				at tests.Main.main(Main.java:69)
			
		 */
	flow_50:
		if (script_9833(v2, v13, v8, a2, a3, 1, 1, v21, a4, a1) == 1 && cs2method_11038(a4, v8) == 1 && cs2method_10487() == v2 && cs2method_11089() == v13 && script_1468(v8) != v11) {
			script_9843(v11, v8, a4);
		}
		return -1;
}
