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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @r8vec_mirror_next(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 -1, ptr %8, align 4, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %24, %2
  %11 = load i32, ptr %7, align 4, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %14, label %27

14:                                               ; preds = %10
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds double, ptr %15, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = fcmp olt double 0.000000e+00, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %14
  %22 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %22, ptr %8, align 4, !tbaa !5
  br label %27

23:                                               ; preds = %14
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %7, align 4, !tbaa !5
  br label %10, !llvm.loop !13

27:                                               ; preds = %21, %10
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %30, label %51

30:                                               ; preds = %27
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %46, %30
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %35, label %49

35:                                               ; preds = %31
  %36 = load ptr, ptr %5, align 8, !tbaa !9
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds double, ptr %36, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = fneg double %40
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds double, ptr %42, i64 %44
  store double %41, ptr %45, align 8, !tbaa !11
  br label %46

46:                                               ; preds = %35
  %47 = load i32, ptr %7, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %7, align 4, !tbaa !5
  br label %31, !llvm.loop !15

49:                                               ; preds = %31
  store i32 1, ptr %6, align 4, !tbaa !5
  %50 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %50, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %72

51:                                               ; preds = %27
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %67, %51
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = icmp sle i32 %53, %54
  br i1 %55, label %56, label %70

56:                                               ; preds = %52
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds double, ptr %57, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !11
  %62 = fneg double %61
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds double, ptr %63, i64 %65
  store double %62, ptr %66, align 8, !tbaa !11
  br label %67

67:                                               ; preds = %56
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %7, align 4, !tbaa !5
  br label %52, !llvm.loop !16

70:                                               ; preds = %52
  store i32 0, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %71, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %72

72:                                               ; preds = %70, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %73 = load i32, ptr %3, align 4
  ret i32 %73
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
attributes #2 = { nounwind }

!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"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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(argmem: readwrite) uwtable
define dso_local range(i32 0, 2) i32 @r8vec_mirror_next(i32 noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 0
  br i1 %3, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %8
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %7, %8 ]
  %4 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fcmp ogt double %5, 0.000000e+00
  %7 = add nuw i64 %indvars.iv, 1
  br i1 %6, label %.lr.ph32.preheader, label %8

8:                                                ; preds = %.lr.ph
  %exitcond.not = icmp eq i64 %7, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !9

.lr.ph32.preheader:                               ; preds = %.lr.ph
  %wide.trip.count40 = and i64 %7, 4294967295
  %min.iters.check55 = icmp ult i64 %indvars.iv, 3
  br i1 %min.iters.check55, label %.lr.ph32.preheader66, label %vector.ph56

.lr.ph32.preheader66:                             ; preds = %middle.block53, %.lr.ph32.preheader
  %indvars.iv37.ph = phi i64 [ 0, %.lr.ph32.preheader ], [ %n.vec58, %middle.block53 ]
  br label %.lr.ph32

vector.ph56:                                      ; preds = %.lr.ph32.preheader
  %n.vec58 = and i64 %7, -4
  br label %vector.body60

vector.body60:                                    ; preds = %vector.body60, %vector.ph56
  %index61 = phi i64 [ 0, %vector.ph56 ], [ %index.next64, %vector.body60 ]
  %9 = getelementptr inbounds double, ptr %1, i64 %index61
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %wide.load62 = load <2 x double>, ptr %9, align 8, !tbaa !5
  %wide.load63 = load <2 x double>, ptr %10, align 8, !tbaa !5
  %11 = fneg <2 x double> %wide.load62
  %12 = fneg <2 x double> %wide.load63
  store <2 x double> %11, ptr %9, align 8, !tbaa !5
  store <2 x double> %12, ptr %10, align 8, !tbaa !5
  %index.next64 = add nuw i64 %index61, 4
  %13 = icmp eq i64 %index.next64, %n.vec58
  br i1 %13, label %middle.block53, label %vector.body60, !llvm.loop !11

middle.block53:                                   ; preds = %vector.body60
  %cmp.n65 = icmp eq i64 %7, %n.vec58
  br i1 %cmp.n65, label %.loopexit, label %.lr.ph32.preheader66

.preheader:                                       ; preds = %8
  br i1 %3, label %.lr.ph34.preheader, label %.loopexit

.lr.ph34.preheader:                               ; preds = %.preheader
  %wide.trip.count45 = zext nneg i32 %0 to i64
  %min.iters.check = icmp ult i32 %0, 4
  br i1 %min.iters.check, label %.lr.ph34.preheader67, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph34.preheader
  %n.vec = and i64 %wide.trip.count, 2147483644
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %14 = getelementptr inbounds double, ptr %1, i64 %index
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load = load <2 x double>, ptr %14, align 8, !tbaa !5
  %wide.load52 = load <2 x double>, ptr %15, align 8, !tbaa !5
  %16 = fneg <2 x double> %wide.load
  %17 = fneg <2 x double> %wide.load52
  store <2 x double> %16, ptr %14, align 8, !tbaa !5
  store <2 x double> %17, ptr %15, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %18 = icmp eq i64 %index.next, %n.vec
  br i1 %18, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %.lr.ph34.preheader67

.lr.ph34.preheader67:                             ; preds = %middle.block, %.lr.ph34.preheader
  %indvars.iv42.ph = phi i64 [ 0, %.lr.ph34.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph34

.lr.ph34:                                         ; preds = %.lr.ph34.preheader67, %.lr.ph34
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %.lr.ph34 ], [ %indvars.iv42.ph, %.lr.ph34.preheader67 ]
  %19 = getelementptr inbounds double, ptr %1, i64 %indvars.iv42
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fneg double %20
  store double %21, ptr %19, align 8, !tbaa !5
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond46.not = icmp eq i64 %indvars.iv.next43, %wide.trip.count45
  br i1 %exitcond46.not, label %.loopexit, label %.lr.ph34, !llvm.loop !15

.lr.ph32:                                         ; preds = %.lr.ph32.preheader66, %.lr.ph32
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %.lr.ph32 ], [ %indvars.iv37.ph, %.lr.ph32.preheader66 ]
  %22 = getelementptr inbounds double, ptr %1, i64 %indvars.iv37
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fneg double %23
  store double %24, ptr %22, align 8, !tbaa !5
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next38, %wide.trip.count40
  br i1 %exitcond41.not, label %.loopexit, label %.lr.ph32, !llvm.loop !16

.loopexit:                                        ; preds = %.lr.ph34, %.lr.ph32, %middle.block, %middle.block53, %2, %.preheader
  %.024 = phi i32 [ 1, %.preheader ], [ 1, %2 ], [ 0, %middle.block53 ], [ 1, %middle.block ], [ 0, %.lr.ph32 ], [ 1, %.lr.ph34 ]
  ret i32 %.024
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10, !12, !13}
!15 = distinct !{!15, !10, !13, !12}
!16 = distinct !{!16, !10, !13, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass