; LLVM IR from NTHU-LSALAB/Gemini :: src/schd-priority.ll (Z13schd_priorityRK17valid_candidate_tS1_)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.valid_candidate_t = type { double, double, double, double, %"struct.std::_List_iterator" }
%"struct.std::_List_iterator" = type { ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z13schd_priorityRK17valid_candidate_tS1_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.valid_candidate_t, ptr %6, i32 0, i32 0
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = fcmp ogt double %8, 0.000000e+00
  br i1 %9, label %10, label %39

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.valid_candidate_t, ptr %11, i32 0, i32 0
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = fcmp ogt double %13, 0.000000e+00
  br i1 %14, label %15, label %39

15:                                               ; preds = %10
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.valid_candidate_t, ptr %16, i32 0, i32 0
  %18 = load double, ptr %17, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.valid_candidate_t, ptr %19, i32 0, i32 0
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.valid_candidate_t, ptr %22, i32 0, i32 2
  %24 = load double, ptr %23, align 8, !tbaa !13
  %25 = fadd double %21, %24
  %26 = fdiv double %18, %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.valid_candidate_t, ptr %27, i32 0, i32 0
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.valid_candidate_t, ptr %30, i32 0, i32 0
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.valid_candidate_t, ptr %33, i32 0, i32 2
  %35 = load double, ptr %34, align 8, !tbaa !13
  %36 = fadd double %32, %35
  %37 = fdiv double %29, %36
  %38 = fcmp ogt double %26, %37
  store i1 %38, ptr %3, align 1
  br label %69

39:                                               ; preds = %10, %2
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.valid_candidate_t, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = fcmp ogt double %42, 0.000000e+00
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.valid_candidate_t, ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = fcmp olt double %47, 0.000000e+00
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  store i1 true, ptr %3, align 1
  br label %69

50:                                               ; preds = %44, %39
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.valid_candidate_t, ptr %51, i32 0, i32 0
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = fcmp olt double %53, 0.000000e+00
  br i1 %54, label %55, label %61

55:                                               ; preds = %50
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.valid_candidate_t, ptr %56, i32 0, i32 0
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = fcmp ogt double %58, 0.000000e+00
  br i1 %59, label %60, label %61

60:                                               ; preds = %55
  store i1 false, ptr %3, align 1
  br label %69

61:                                               ; preds = %55, %50
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.valid_candidate_t, ptr %62, i32 0, i32 2
  %64 = load double, ptr %63, align 8, !tbaa !13
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.valid_candidate_t, ptr %65, i32 0, i32 2
  %67 = load double, ptr %66, align 8, !tbaa !13
  %68 = fcmp olt double %64, %67
  store i1 %68, ptr %3, align 1
  br label %69

69:                                               ; preds = %61, %60, %49, %15
  %70 = load i1, ptr %3, align 1
  ret i1 %70
}

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS17valid_candidate_t", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32}
!11 = !{!"double", !7, i64 0}
!12 = !{!"_ZTSSt14_List_iteratorI11candidate_tE", !6, i64 0}
!13 = !{!10, !11, i64 16}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_Z13schd_priorityRK17valid_candidate_tS1_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %1) local_unnamed_addr #0 {
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = fcmp ogt double %3, 0.000000e+00
  %5 = load double, ptr %1, align 8
  %6 = fcmp ogt double %5, 0.000000e+00
  br i1 %4, label %7, label %23

7:                                                ; preds = %2
  br i1 %6, label %8, label %21

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load <2 x double>, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = insertelement <2 x double> poison, double %3, i64 0
  %14 = insertelement <2 x double> %13, double %5, i64 1
  %15 = insertelement <2 x double> %10, double %12, i64 1
  %16 = fadd <2 x double> %14, %15
  %17 = fdiv <2 x double> %14, %16
  %18 = extractelement <2 x double> %17, i64 0
  %19 = extractelement <2 x double> %17, i64 1
  %20 = fcmp ogt double %18, %19
  br label %30

21:                                               ; preds = %7
  %22 = fcmp olt double %5, 0.000000e+00
  br i1 %22, label %30, label %.thread21

23:                                               ; preds = %2
  %24 = fcmp olt double %3, 0.000000e+00
  %or.cond19 = select i1 %24, i1 %6, i1 false
  br i1 %or.cond19, label %30, label %.thread21

.thread21:                                        ; preds = %21, %23
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load double, ptr %25, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %1, i64 16
  %28 = load double, ptr %27, align 8, !tbaa !12
  %29 = fcmp olt double %26, %28
  br label %30

30:                                               ; preds = %23, %21, %.thread21, %8
  %.0 = phi i1 [ %20, %8 ], [ %29, %.thread21 ], [ true, %21 ], [ false, %23 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTS17valid_candidate_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt14_List_iteratorI11candidate_tE", !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass