; LLVM IR from CLASS-SZ/class_sz :: class-sz/tools (hyperspherical)

; 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"

; Function Attrs: nounwind uwtable
define dso_local i32 @ClosedModY(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %9, align 8, !tbaa !9
  store i32 1, ptr %11, align 4, !tbaa !5
  %12 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %17, %5
  %14 = load ptr, ptr %8, align 8, !tbaa !9
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = fcmp ogt double %15, 0x401921FB54442D18
  br i1 %16, label %17, label %21

17:                                               ; preds = %13
  %18 = load ptr, ptr %8, align 8, !tbaa !9
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = fsub double %19, 0x401921FB54442D18
  store double %20, ptr %18, align 8, !tbaa !11
  br label %13, !llvm.loop !13

21:                                               ; preds = %13
  %22 = load ptr, ptr %8, align 8, !tbaa !9
  %23 = load double, ptr %22, align 8, !tbaa !11
  %24 = fcmp ogt double %23, 0x400921FB54442D18
  br i1 %24, label %25, label %44

25:                                               ; preds = %21
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = fsub double 0x401921FB54442D18, %27
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  store double %28, ptr %29, align 8, !tbaa !11
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = srem i32 %30, 2
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %38

33:                                               ; preds = %25
  %34 = load ptr, ptr %9, align 8, !tbaa !9
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sub nsw i32 0, %35
  %37 = load ptr, ptr %9, align 8, !tbaa !9
  store i32 %36, ptr %37, align 4, !tbaa !5
  br label %43

38:                                               ; preds = %25
  %39 = load ptr, ptr %10, align 8, !tbaa !9
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sub nsw i32 0, %40
  %42 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %41, ptr %42, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %38, %33
  br label %44

44:                                               ; preds = %43, %21
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fcmp ogt double %46, 0x3FF921FB54442D18
  br i1 %47, label %48, label %69

48:                                               ; preds = %44
  %49 = load ptr, ptr %8, align 8, !tbaa !9
  %50 = load double, ptr %49, align 8, !tbaa !11
  %51 = fsub double 0x400921FB54442D18, %50
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  store double %51, ptr %52, align 8, !tbaa !11
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = sub nsw i32 %53, %54
  %56 = srem i32 %55, 2
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %63

58:                                               ; preds = %48
  %59 = load ptr, ptr %9, align 8, !tbaa !9
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sub nsw i32 0, %60
  %62 = load ptr, ptr %9, align 8, !tbaa !9
  store i32 %61, ptr %62, align 4, !tbaa !5
  br label %68

63:                                               ; preds = %48
  %64 = load ptr, ptr %10, align 8, !tbaa !9
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sub nsw i32 0, %65
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  store i32 %66, ptr %67, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %63, %58
  br label %69

69:                                               ; preds = %68, %44
  ret i32 0
}

attributes #0 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @ClosedModY(i32 noundef %0, i32 noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3, ptr nocapture noundef %4) local_unnamed_addr #0 {
  store i32 1, ptr %3, align 4, !tbaa !5
  store i32 1, ptr %4, align 4, !tbaa !5
  %.pr = load double, ptr %2, align 8, !tbaa !9
  %6 = fcmp ogt double %.pr, 0x401921FB54442D18
  br i1 %6, label %.lr.ph, label %10

.lr.ph:                                           ; preds = %5, %.lr.ph
  %7 = phi double [ %8, %.lr.ph ], [ %.pr, %5 ]
  %8 = fadd double %7, 0xC01921FB54442D18
  %9 = fcmp ogt double %8, 0x401921FB54442D18
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  store double %8, ptr %2, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %._crit_edge, %5
  %.lcssa = phi double [ %8, %._crit_edge ], [ %.pr, %5 ]
  %11 = fcmp ogt double %.lcssa, 0x400921FB54442D18
  br i1 %11, label %12, label %thread-pre-split

12:                                               ; preds = %10
  %13 = fsub double 0x401921FB54442D18, %.lcssa
  store double %13, ptr %2, align 8, !tbaa !9
  %14 = and i32 %0, -2147483647
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %16, label %19

16:                                               ; preds = %12
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sub nsw i32 0, %17
  store i32 %18, ptr %3, align 4, !tbaa !5
  br label %thread-pre-split

19:                                               ; preds = %12
  store i32 -1, ptr %4, align 4, !tbaa !5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %16, %10, %19
  %20 = phi double [ %13, %19 ], [ %.lcssa, %10 ], [ %13, %16 ]
  %21 = fcmp ogt double %20, 0x3FF921FB54442D18
  br i1 %21, label %.sink.split, label %28

.sink.split:                                      ; preds = %thread-pre-split
  %22 = fsub double 0x400921FB54442D18, %20
  store double %22, ptr %2, align 8, !tbaa !9
  %23 = sub nsw i32 %1, %0
  %24 = and i32 %23, 1
  %25 = icmp eq i32 %24, 0
  %. = select i1 %25, ptr %3, ptr %4
  %26 = load i32, ptr %., align 4, !tbaa !5
  %27 = sub nsw i32 0, %26
  store i32 %27, ptr %., align 4, !tbaa !5
  br label %28

28:                                               ; preds = %.sink.split, %thread-pre-split
  ret i32 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass