/* 
 * 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.


void script_8818(int a0,int a1) {
	if (cs2_configs['cfg2850'] <= 0) {
		return;
	}
	if (script_8815(a0) == 0) {
		switch (a0) {
			flow_4:
				default:
				script_8210(-1, -1, "Invalid key. Please enter a new one.");
				break;
				case 13:
				if (script_9666() == 1) {
					return;
				}
				script_8212(cs2_configs['cfg2850'], cs2_configs['cfg2851'], -1, -1);
				script_8820();
				break;
				case 86:
				case 81:
				case 82:
				break;
				case -1:
				IF (cs2method_10698(a1) == 1) 
					GOTO	flow_10
				IF (a1 == -1 && a1 != 96) 
					GOTO	flow_11
				break;
			flow_10:
			flow_11:
				script_8210(-1, -1, "Key not currently supported. Please enter a new one.");
		}
		return;
	}
	int v1 = 8;
	if (cs2method_10378() == 1) {
		v1 = 1;
	} else if (cs2method_10558() == 1) {
		v1 = 2;
	} else {
		if (cs2method_10862() == 1) {
			v1 = 4;
		}
	}
	int v9 = 0;
	int v3 = 0;
	int v0 = -1;
	int v6 = 0;
	int v4 = cs2method_10924(7691);
	while (v6 < v4) {
		v3 = idx17mapData('i', 'i', 7691, v6);
		v0 = script_8824(v3, a0, v1);
		if (v0 != -1) {
			v6 = v4;
		} else {
			v6 = cs2method_10060(v6, 1);
		}
	}
	object v20 = "";
	int v13 = cs2_configs['cfg2850'];
	int v16 = cs2_configs['cfg2851'];
	int v11 = a0;
	int v2 = v1;
	script_8823_struct(1,1,0) v7 = script_8823(v13, v16, v11, v2);
	object v17 = v7.objectpart_0;
	int v14 = v7.intpart_0;
	if (v14 == 0) {
		if (cs2method_10846(v17, "") == 0) {
			v17 = "Key bind failed. Please try again later.";
		}
		script_8210(-1, -1, v17);
		return;
	}
	if (v0 != -1) {
		if (cs2_configs['cfg2850'] != v3 || cs2_configs['cfg2851'] != v0) {
			int v15 = v3;
			int v12 = v0;
			int v10 = 255;
			int v18 = 0;
			script_8823_struct(1,1,0) v19 = script_8823(v15, v12, v10, v18);
			int v5 = v19.intpart_0;
			v19.objectpart_0;
			int v8 = v5;
			/* 
				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)
				
			 */
		}
		v3 = -1;
		v0 = -1;
	}
	script_8212(cs2_configs['cfg2850'], cs2_configs['cfg2851'], v3, v0);
	script_8820();
	return;
}
