; LLVM IR from QUILL-PIC/Quill :: src/low-level.ll (Z8regulateRdS_S_)

; 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.vector3d = type { double, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8regulateRdS_S_(ptr dead_on_unwind noalias writable sret(%struct.vector3d) align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  store ptr %3, ptr %7, align 8, !tbaa !5
  call void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = fcmp ogt double %9, %11
  br i1 %12, label %13, label %54

13:                                               ; preds = %4
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = fcmp ogt double %15, %17
  br i1 %18, label %19, label %29

19:                                               ; preds = %13
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 0
  store double %21, ptr %22, align 8, !tbaa !11
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %24, ptr %25, align 8, !tbaa !13
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 2
  store double %27, ptr %28, align 8, !tbaa !14
  br label %53

29:                                               ; preds = %13
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 2
  store double %31, ptr %32, align 8, !tbaa !14
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = fcmp ogt double %34, %36
  br i1 %37, label %38, label %45

38:                                               ; preds = %29
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load double, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 0
  store double %40, ptr %41, align 8, !tbaa !11
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %43, ptr %44, align 8, !tbaa !13
  br label %52

45:                                               ; preds = %29
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 0
  store double %47, ptr %48, align 8, !tbaa !11
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %50, ptr %51, align 8, !tbaa !13
  br label %52

52:                                               ; preds = %45, %38
  br label %53

53:                                               ; preds = %52, %19
  br label %95

54:                                               ; preds = %4
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = fcmp ogt double %56, %58
  br i1 %59, label %60, label %70

60:                                               ; preds = %54
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 0
  store double %62, ptr %63, align 8, !tbaa !11
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load double, ptr %64, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %65, ptr %66, align 8, !tbaa !13
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load double, ptr %67, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 2
  store double %68, ptr %69, align 8, !tbaa !14
  br label %94

70:                                               ; preds = %54
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 0
  store double %72, ptr %73, align 8, !tbaa !11
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load double, ptr %74, align 8, !tbaa !9
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = fcmp ogt double %75, %77
  br i1 %78, label %79, label %86

79:                                               ; preds = %70
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load double, ptr %80, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %81, ptr %82, align 8, !tbaa !13
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = load double, ptr %83, align 8, !tbaa !9
  %85 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 2
  store double %84, ptr %85, align 8, !tbaa !14
  br label %93

86:                                               ; preds = %70
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = load double, ptr %87, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 1
  store double %88, ptr %89, align 8, !tbaa !13
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = load double, ptr %90, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.vector3d, ptr %0, i32 0, i32 2
  store double %91, ptr %92, align 8, !tbaa !14
  br label %93

93:                                               ; preds = %86, %79
  br label %94

94:                                               ; preds = %93, %60
  br label %95

95:                                               ; preds = %94, %53
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #1 align 2

attributes #0 = { mustprogress 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" }
attributes #1 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS8vector3d", !10, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, 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"

%struct.vector3d = type { double, double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z8regulateRdS_S_(ptr dead_on_unwind noalias nonnull writable sret(%struct.vector3d) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %2, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %3) local_unnamed_addr #0 {
  tail call void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0)
  %5 = load double, ptr %1, align 8, !tbaa !5
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = fcmp ogt double %5, %6
  %8 = load double, ptr %3, align 8, !tbaa !5
  br i1 %7, label %9, label %20

9:                                                ; preds = %4
  %10 = fcmp ogt double %6, %8
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  store double %5, ptr %0, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store double %6, ptr %12, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  store double %8, ptr %13, align 8, !tbaa !12
  br label %30

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store double %6, ptr %15, align 8, !tbaa !12
  %16 = fcmp ogt double %5, %8
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %16, label %18, label %19

18:                                               ; preds = %14
  store double %5, ptr %0, align 8, !tbaa !9
  store double %8, ptr %17, align 8, !tbaa !11
  br label %30

19:                                               ; preds = %14
  store double %8, ptr %0, align 8, !tbaa !9
  store double %5, ptr %17, align 8, !tbaa !11
  br label %30

20:                                               ; preds = %4
  %21 = fcmp ogt double %8, %6
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  br i1 %21, label %23, label %25

23:                                               ; preds = %20
  store double %8, ptr %0, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  store double %6, ptr %24, align 8, !tbaa !11
  store double %5, ptr %22, align 8, !tbaa !12
  br label %30

25:                                               ; preds = %20
  store double %6, ptr %0, align 8, !tbaa !9
  %26 = fcmp ogt double %5, %8
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %26, label %28, label %29

28:                                               ; preds = %25
  store double %5, ptr %27, align 8, !tbaa !11
  store double %8, ptr %22, align 8, !tbaa !12
  br label %30

29:                                               ; preds = %25
  store double %8, ptr %27, align 8, !tbaa !11
  store double %5, ptr %22, align 8, !tbaa !12
  br label %30

30:                                               ; preds = %23, %29, %28, %11, %19, %18
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8vector3dC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS8vector3d", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass