// File: dcarrey[P]hgt-detection/./fonctions.cpp
// Function: sortHGT(HGT*, int, Parameters)
void sortHGT(struct HGT *tabHGT,int nbHGT,struct Parameters param){
	
	int i,j;
	int criterion;
	int a,b,c,d,rf,qd;
	double ls,bd;

	if(strcmp(param.criterion,"rf")==0)
		criterion = 1;
	else if(strcmp(param.criterion,"ls")==0)
		criterion = 2;
	else if(strcmp(param.criterion,"bd")==0)
		criterion = 3;
	else
		criterion = 4;

	for(i=1;i<=nbHGT;i++){
		for(j=1;j<=nbHGT-i;j++){
			if( ((criterion == 1) && (tabHGT[j].crit.RF > tabHGT[j+1].crit.RF)) ||
				((criterion == 2) && (tabHGT[j].crit.LS > tabHGT[j+1].crit.LS)) ||
				((criterion == 4) && (tabHGT[j].crit.QD > tabHGT[j+1].crit.QD)) ||
				((criterion == 3) && (tabHGT[j].crit.BD > tabHGT[j+1].crit.BD)) ){
				rf = tabHGT[j].crit.RF;
				ls = tabHGT[j].crit.LS;
				bd = tabHGT[j].crit.BD;
				qd = tabHGT[j].crit.QD;
				a = tabHGT[j].source_A;
				b = tabHGT[j].source_B;
				c = tabHGT[j].dest_A;
				d = tabHGT[j].dest_B;
				tabHGT[j].crit.RF = tabHGT[j+1].crit.RF;
				tabHGT[j].crit.LS = tabHGT[j+1].crit.LS;
				tabHGT[j].crit.BD = tabHGT[j+1].crit.BD;
				tabHGT[j].crit.QD = tabHGT[j+1].crit.QD;
				tabHGT[j].source_A = tabHGT[j+1].source_A;
				tabHGT[j].source_B = tabHGT[j+1].source_B;
				tabHGT[j].dest_A = tabHGT[j+1].dest_A;
				tabHGT[j].dest_B = tabHGT[j+1].dest_B;
				tabHGT[j+1].crit.RF = rf;
				tabHGT[j+1].crit.LS = ls;
				tabHGT[j+1].crit.BD = bd;
				tabHGT[j+1].crit.QD = qd;
				tabHGT[j+1].source_A = a;
				tabHGT[j+1].source_B = b;
				tabHGT[j+1].dest_A = c;
				tabHGT[j+1].dest_B = d;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, %rax
leaq 0x10(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movq %rax, -0x8(%rbp)
movl %esi, -0xc(%rbp)
addq $0x3fc, %rdi            # imm = 0x3FC
leaq 0x126f9(%rip), %rsi     # 0x258b1
callq 0x1130
cmpl $0x0, %eax
jne 0x131cb
movl $0x1, -0x18(%rbp)
jmp 0x13220
movq -0x48(%rbp), %rdi
addq $0x3fc, %rdi            # imm = 0x3FC
leaq 0x13385(%rip), %rsi     # 0x26562
callq 0x1130
cmpl $0x0, %eax
jne 0x131f0
movl $0x2, -0x18(%rbp)
jmp 0x1321e
movq -0x48(%rbp), %rdi
addq $0x3fc, %rdi            # imm = 0x3FC
leaq 0x126dd(%rip), %rsi     # 0x258df
callq 0x1130
cmpl $0x0, %eax
jne 0x13215
movl $0x3, -0x18(%rbp)
jmp 0x1321c
movl $0x4, -0x18(%rbp)
jmp 0x1321e
jmp 0x13220
movl $0x1, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x136c3
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl -0xc(%rbp), %ecx
subl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jg 0x136b3
cmpl $0x1, -0x18(%rbp)
jne 0x13286
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x50(%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x50(%rcx), %eax
jg 0x1333b
cmpl $0x2, -0x18(%rbp)
jne 0x132c1
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
ucomisd 0x20(%rax), %xmm0
ja 0x1333b
cmpl $0x4, -0x18(%rbp)
jne 0x132f8
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x54(%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x54(%rcx), %eax
jg 0x1333b
cmpl $0x3, -0x18(%rbp)
jne 0x136a3
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd 0x30(%rax), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
ucomisd 0x30(%rax), %xmm0
jbe 0x136a3
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x50(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x54(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x80(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x84(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x88(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x8c(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x50(%rax), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd 0x30(%rax), %xmm0
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x54(%rax), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x54(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x80(%rax), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x80(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x84(%rax), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x84(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x88(%rax), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x88(%rax)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x8c(%rax), %ecx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8c(%rax)
movl -0x2c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movsd -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movl -0x30(%rbp), %ecx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x54(%rax)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x80(%rax)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x84(%rax)
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x88(%rax)
movl -0x28(%rbp), %ecx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8c(%rax)
jmp 0x136a5
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1323a
jmp 0x136b5
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x13227
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)