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