// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdi, -0x38(%rbp)
movl $0x6672, %ecx           # imm = 0x6672
xorl 0x40c(%rbp), %ecx
movzbl 0x40e(%rbp), %edx
xorl %eax, %eax
orw %cx, %dx
setne %r9b
je 0xae3a
leaq 0x10(%rbp), %rcx
movzwl 0x3fc(%rcx), %edx
xorl $0x736c, %edx           # imm = 0x736C
movzbl 0x3fe(%rcx), %r8d
orw %dx, %r8w
je 0xae3e
movzwl 0x3fc(%rcx), %edx
xorl $0x6462, %edx           # imm = 0x6462
movzbl 0x3fe(%rcx), %ecx
orw %dx, %cx
setne %dl
sete %r8b
xorl %ecx, %ecx
jmp 0xae45
xorl %ecx, %ecx
jmp 0xae40
movb $0x1, %cl
xorl %edx, %edx
xorl %r8d, %r8d
testl %esi, %esi
jle 0xaf82
movb %r9b, %al
addq $0x1dc, -0x38(%rbp)     # imm = 0x1DC
movl $0x1, %edi
movl %esi, %r9d
movl %esi, -0x2c(%rbp)
movq %rdi, -0x40(%rbp)
cmpl %esi, %edi
jge 0xaf6b
movl %r9d, %r11d
decq %r11
movq -0x38(%rbp), %rbx
testl %eax, %eax
jne 0xae8a
movl -0xe4(%rbx), %r14d
cmpl -0x3c(%rbx), %r14d
jg 0xaeca
testb %cl, %cl
je 0xae9d
movsd -0x114(%rbx), %xmm0
ucomisd -0x6c(%rbx), %xmm0
ja 0xaeca
testb %dl, %dl
je 0xaeae
movl -0xe0(%rbx), %r14d
cmpl -0x38(%rbx), %r14d
jg 0xaeca
testb %r8b, %r8b
je 0xaf5b
movsd -0x104(%rbx), %xmm0
ucomisd -0x5c(%rbx), %xmm0
jbe 0xaf5b
movl -0xe4(%rbx), %r14d
movsd -0x114(%rbx), %xmm0
movsd -0x104(%rbx), %xmm1
movl -0xe0(%rbx), %r15d
movq -0xb4(%rbx), %r12
movl -0xac(%rbx), %r13d
movl -0xa8(%rbx), %r10d
movq -0x3c(%rbx), %rdi
movq %rdi, -0xe4(%rbx)
movsd -0x6c(%rbx), %xmm2
movsd %xmm2, -0x114(%rbx)
movsd -0x5c(%rbx), %xmm2
movsd %xmm2, -0x104(%rbx)
movq -0xc(%rbx), %rdi
movq %rdi, -0xb4(%rbx)
movl -0x4(%rbx), %edi
movl %edi, -0xac(%rbx)
movl (%rbx), %edi
movl %edi, -0xa8(%rbx)
movl %r14d, -0x3c(%rbx)
movsd %xmm0, -0x6c(%rbx)
movsd %xmm1, -0x5c(%rbx)
movl %r15d, -0x38(%rbx)
movq %r12, -0xc(%rbx)
movl %r13d, -0x4(%rbx)
movl %r10d, (%rbx)
addq $0xa8, %rbx
decq %r11
jne 0xae79
movq -0x40(%rbp), %r10
leal 0x1(%r10), %edi
decl %r9d
movl -0x2c(%rbp), %esi
cmpl %esi, %r10d
jne 0xae63
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq