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


script_5353_struct(5,0,0) script_5353(int a0,int a1,int a2,int a3,int a4,int a5,int a6,int a7,int a8,int a9) {
	int v5;
	int v13;
	int v15;
	int v31;
	int v10 = -1;
	int v21 = -1;
	int v8 = 0;
	int v52 = -1;
	int v54 = 0;
	int v6 = 0;
	int v39 = 0;
	int v53 = 0;
	while (v39 < 6) {
		switch (v39) {
			case 0:
				v10 = 5182;
				break;
			case 1:
				v10 = 3875;
				break;
			case 2:
				if (cs2method_11010() == 0) {
					v10 = 5189;
				} else {
					v10 = 5188;
				}
				break;
			case 3:
				v10 = 5184;
				break;
			case 4:
				v10 = 5183;
		}
		int v34 = 0;
		while (v34 < cs2method_10924(v10)) {
			int v36 = idx17mapData('i', 'J', v10, v34);
			if (idx22mapAttribute(v36, 1934) == 1) {
				v6 = cs2method_10060(v6, 1);
			}
			v34 = cs2method_10060(v34, 1);
		}
		v39 = cs2method_10060(v39, 1);
	}
	if (v6 < 1) {
		return new script_5353_struct(a5, a3, a6, a2, a1);
	}
	globalarray_0 = new int[v6];
	int v4 = cs2method_10461(v6, 1);
	int v43 = 0;
	while (v43 < 6) {
		switch (v43) {
			case 0:
				v10 = 5182;
				break;
			case 1:
				v10 = 3875;
				break;
			case 2:
				if (cs2method_11010() == 0) {
					v10 = 5189;
				} else {
					v10 = 5188;
				}
				break;
			case 3:
				v10 = 5184;
				break;
			case 4:
				v10 = 5183;
		}
		int v38 = 0;
		while (v38 < cs2method_10924(v10)) {
			int v16 = idx17mapData('i', 'J', v10, v38);
			if (idx22mapAttribute(v16, 1934) == 1) {
				globalarray_0[v4] = v16;
				v4 = cs2method_11048(cs2method_10461(v4, 1), 0);
			}
			v38 = cs2method_10060(v38, 1);
		}
		v43 = cs2method_10060(v43, 1);
	}
	int v55 = 0;
	int v9 = 1;
	int v33 = 0;
	int v30 = 0;
	object v12 = "";
	object v19 = "";
	int v24 = 0;
	int v45 = 0;
	switch (cs2_configs['cfg1659']) {
		while (true) {
			default:
				if (v9 == 1) {
					v9 = 0;
					int v7 = cs2method_10461(v6, 1);
					while (v7 > 0) {
						if (idx22mapAttribute(globalarray_0[v7], 1933) > 0) {
							v13 = idx22mapAttribute(globalarray_0[v7], 1933);
						} else {
							v13 = idx22mapAttribute(globalarray_0[v7], 1932);
						}
						if (idx22mapAttribute(globalarray_0[cs2method_10461(v7, 1)], 1933) > 0) {
							v31 = idx22mapAttribute(globalarray_0[cs2method_10461(v7, 1)], 1933);
						} else {
							v31 = idx22mapAttribute(globalarray_0[cs2method_10461(v7, 1)], 1932);
						}
						if (v13 < v31) {
							v9 = 1;
							int v42 = globalarray_0[cs2method_10461(v7, 1)];
							globalarray_0[cs2method_10461(v7, 1)] = globalarray_0[v7];
							globalarray_0[v7] = v42;
						}
						v7 = cs2method_10461(v7, 1);
					}
				}
		}
		flow_52:
			GOTO	flow_130
			while (true) {
				case 1:
					if (v9 == 1) {
						v9 = 0;
						int v0 = cs2method_10461(v6, 1);
						while (v0 > 0) {
							if (idx22mapAttribute(globalarray_0[v0], 1933) > 0) {
								v5 = idx22mapAttribute(globalarray_0[v0], 1933);
							} else {
								v5 = idx22mapAttribute(globalarray_0[v0], 1932);
							}
							if (idx22mapAttribute(globalarray_0[cs2method_10461(v0, 1)], 1933) > 0) {
								v15 = idx22mapAttribute(globalarray_0[cs2method_10461(v0, 1)], 1933);
							} else {
								v15 = idx22mapAttribute(globalarray_0[cs2method_10461(v0, 1)], 1932);
							}
							if (v5 > v15) {
								v9 = 1;
								int v18 = globalarray_0[cs2method_10461(v0, 1)];
								globalarray_0[cs2method_10461(v0, 1)] = globalarray_0[v0];
								globalarray_0[v0] = v18;
							}
							v0 = cs2method_10461(v0, 1);
						}
					}
			}
		flow_66:
			GOTO	flow_130
			while (true) {
				case 2:
					if (v9 == 1) {
						v9 = 0;
						int v20 = cs2method_10461(v6, 1);
						while (v20 > 0) {
							if (idx22mapAttribute(globalarray_0[v20], 1937) == 4) {
								int v11 = 0;
								int v49 = 0;
								while (v11 < cs2method_10924(5184) && v49 == 0) {
									if (idx17mapData('i', 'J', 5184, v11) == globalarray_0[v20]) {
										if (cs2method_11010() == 0) {
											v12 = idx17mapData('i', 's', 5186, v11);
										} else {
											v12 = idx17mapData('i', 's', 5187, v11);
										}
										v49 = 1;
									}
									v11 = cs2method_10060(v11, 1);
								}
							} else {
								v12 = idx22mapAttribute(globalarray_0[v20], 1930);
							}
							if (idx22mapAttribute(globalarray_0[cs2method_10461(v20, 1)], 1937) == 4) {
								int v28 = 0;
								int v51 = 0;
								while (v28 < cs2method_10924(5184) && v51 == 0) {
									if (idx17mapData('i', 'J', 5184, v28) == globalarray_0[cs2method_10461(v20, 1)]) {
										if (cs2method_11010() == 0) {
											v19 = idx17mapData('i', 's', 5186, v28);
										} else {
											v19 = idx17mapData('i', 's', 5187, v28);
										}
										v51 = 1;
									}
									v28 = cs2method_10060(v28, 1);
								}
							} else {
								v19 = idx22mapAttribute(globalarray_0[cs2method_10461(v20, 1)], 1930);
							}
							if (cs2method_10846(v12, v19) < 0) {
								v9 = 1;
								int v35 = globalarray_0[cs2method_10461(v20, 1)];
								globalarray_0[cs2method_10461(v20, 1)] = globalarray_0[v20];
								globalarray_0[v20] = v35;
							}
							v20 = cs2method_10461(v20, 1);
						}
					}
			}
		flow_98:
			GOTO	flow_130
			while (true) {
				case 3:
					if (v9 == 1) {
						v9 = 0;
						int v2 = cs2method_10461(v6, 1);
						while (v2 > 0) {
							if (idx22mapAttribute(globalarray_0[v2], 1937) == 4) {
								int v23 = 0;
								int v17 = 0;
								while (v23 < cs2method_10924(5184) && v17 == 0) {
									if (idx17mapData('i', 'J', 5184, v23) == globalarray_0[v2]) {
										if (cs2method_11010() == 0) {
											v12 = idx17mapData('i', 's', 5186, v23);
										} else {
											v12 = idx17mapData('i', 's', 5187, v23);
										}
										v17 = 1;
									}
									v23 = cs2method_10060(v23, 1);
								}
							} else {
								v12 = idx22mapAttribute(globalarray_0[v2], 1930);
							}
							if (idx22mapAttribute(globalarray_0[cs2method_10461(v2, 1)], 1937) == 4) {
								int v44 = 0;
								int v46 = 0;
								while (v44 < cs2method_10924(5184) && v46 == 0) {
									if (idx17mapData('i', 'J', 5184, v44) == globalarray_0[cs2method_10461(v2, 1)]) {
										if (cs2method_11010() == 0) {
											v19 = idx17mapData('i', 's', 5186, v44);
										} else {
											v19 = idx17mapData('i', 's', 5187, v44);
										}
										v46 = 1;
									}
									v44 = cs2method_10060(v44, 1);
								}
							} else {
								v19 = idx22mapAttribute(globalarray_0[cs2method_10461(v2, 1)], 1930);
							}
							if (cs2method_10846(v12, v19) > 0) {
								v9 = 1;
								int v48 = globalarray_0[cs2method_10461(v2, 1)];
								globalarray_0[cs2method_10461(v2, 1)] = globalarray_0[v2];
								globalarray_0[v2] = v48;
							}
							v2 = cs2method_10461(v2, 1);
						}
					}
			}
	}
	flow_130:
		int v27 = 0;
		while (v27 < v6) {
			int v26 = globalarray_0[v27];
			int v14 = v26;
			int v29 = a5;
			int v3 = a3;
			int v41 = a6;
			int v22 = a2;
			int v1 = a7;
			int v47 = a1;
			int v50 = a4;
			int v37 = a8;
			int v40 = a9;
			int v25 = a0;
			script_5351_struct(5,0,0) v32 = script_5351(v14, v29, v3, v41, v22, v1, v47, v50, v37, v40, v25);
			a1 = v32.intpart_4;
			a2 = v32.intpart_3;
			a6 = v32.intpart_2;
			a3 = v32.intpart_1;
			a5 = v32.intpart_0;
			v27 = cs2method_10060(v27, 1);
		}
		return new script_5353_struct(a5, a3, a6, a2, a1);
}
