// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r15d
movq %rdi, -0x30(%rbp)
leaq 0x40c(%rbp), %r12
leaq 0xa934(%rip), %rsi      # 0x14865
pushq $0x3
popq %rdx
movq %r12, %rdi
callq 0x1090
movl %eax, %r14d
testl %eax, %eax
je 0x9f77
leaq 0xb573(%rip), %rsi      # 0x154bd
pushq $0x3
popq %rdx
movq %r12, %rdi
callq 0x1090
testl %eax, %eax
je 0x9f7b
leaq 0xa933(%rip), %rsi      # 0x14893
pushq $0x3
popq %rdx
movq %r12, %rdi
callq 0x1090
testl %eax, %eax
sete %dl
setne %cl
xorl %eax, %eax
jmp 0x9f81
xorl %eax, %eax
jmp 0x9f7d
movb $0x1, %al
xorl %ecx, %ecx
xorl %edx, %edx
movslq %r15d, %rdi
testl %edi, %edi
movl $0x0, %esi
movq %rdi, -0x38(%rbp)
cmovgl %edi, %esi
incl %esi
movq %rsi, -0x40(%rbp)
addq $0x1dc, -0x30(%rbp)     # imm = 0x1DC
pushq $0x1
popq %r8
cmpq -0x40(%rbp), %r8
je 0xa0cf
movq -0x38(%rbp), %r9
subq %r8, %r9
movq -0x30(%rbp), %r10
pushq $0x1
popq %r11
cmpq %r9, %r11
jg 0xa0c7
testl %r14d, %r14d
jne 0x9fd8
movl -0xe4(%r10), %r15d
cmpl -0x3c(%r10), %r15d
jg 0xa01b
testb %al, %al
je 0x9fed
movsd -0x114(%r10), %xmm0
ucomisd -0x6c(%r10), %xmm0
ja 0xa01b
testb %cl, %cl
je 0x9ffe
movl -0xe0(%r10), %r15d
cmpl -0x38(%r10), %r15d
jg 0xa01b
testb %dl, %dl
je 0xa0b8
movsd -0x104(%r10), %xmm0
ucomisd -0x5c(%r10), %xmm0
jbe 0xa0b8
movl -0xe4(%r10), %r15d
movsd -0x114(%r10), %xmm0
movsd -0x104(%r10), %xmm1
movl -0xe0(%r10), %r12d
movq -0xb4(%r10), %rdi
movl -0xac(%r10), %ebx
movl -0xa8(%r10), %r13d
movq -0x3c(%r10), %rsi
movq %rsi, -0xe4(%r10)
movsd -0x6c(%r10), %xmm2
movsd %xmm2, -0x114(%r10)
movsd -0x5c(%r10), %xmm2
movsd %xmm2, -0x104(%r10)
movq -0xc(%r10), %rsi
movq %rsi, -0xb4(%r10)
movl -0x4(%r10), %esi
movl %esi, -0xac(%r10)
movl (%r10), %esi
movl %esi, -0xa8(%r10)
movl %r15d, -0x3c(%r10)
movsd %xmm0, -0x6c(%r10)
movsd %xmm1, -0x5c(%r10)
movl %r12d, -0x38(%r10)
movq %rdi, -0xc(%r10)
movl %ebx, -0x4(%r10)
movl %r13d, (%r10)
incq %r11
addq $0xa8, %r10
jmp 0x9fbd
incq %r8
jmp 0x9fa4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq