; 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: nounwind uwtable
define dso_local void @r8_mant(double noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  %9 = load double, ptr %5, align 8, !tbaa !5
  %10 = fcmp olt double %9, 0.000000e+00
  br i1 %10, label %11, label %13

11:                                               ; preds = %4
  %12 = load ptr, ptr %6, align 8, !tbaa !9
  store i32 -1, ptr %12, align 4, !tbaa !11
  br label %15

13:                                               ; preds = %4
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  store i32 1, ptr %14, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %13, %11
  %16 = load double, ptr %5, align 8, !tbaa !5
  %17 = fcmp olt double %16, 0.000000e+00
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load double, ptr %5, align 8, !tbaa !5
  %20 = fneg double %19
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  store double %20, ptr %21, align 8, !tbaa !5
  br label %25

22:                                               ; preds = %15
  %23 = load double, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  store double %23, ptr %24, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %22, %18
  %26 = load ptr, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %26, align 4, !tbaa !11
  %27 = load double, ptr %5, align 8, !tbaa !5
  %28 = fcmp oeq double %27, 0.000000e+00
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  br label %59

30:                                               ; preds = %25
  br label %31

31:                                               ; preds = %35, %30
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load double, ptr %32, align 8, !tbaa !5
  %34 = fcmp ole double 2.000000e+00, %33
  br i1 %34, label %35, label %44

35:                                               ; preds = %31
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fdiv double %37, 2.000000e+00
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  store double %38, ptr %39, align 8, !tbaa !5
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = add nsw i32 %41, 1
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  store i32 %42, ptr %43, align 4, !tbaa !11
  br label %31, !llvm.loop !13

44:                                               ; preds = %31
  br label %45

45:                                               ; preds = %49, %44
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = fcmp olt double %47, 1.000000e+00
  br i1 %48, label %49, label %58

49:                                               ; preds = %45
  %50 = load ptr, ptr %7, align 8, !tbaa !9
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = fmul double %51, 2.000000e+00
  %53 = load ptr, ptr %7, align 8, !tbaa !9
  store double %52, ptr %53, align 8, !tbaa !5
  %54 = load ptr, ptr %8, align 8, !tbaa !9
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = sub nsw i32 %55, 1
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  store i32 %56, ptr %57, align 4, !tbaa !11
  br label %45, !llvm.loop !15

58:                                               ; preds = %45
  br label %59

59:                                               ; preds = %58, %29
  ret void
}

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 = !{!"double", !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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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: write) uwtable
define dso_local void @r8_mant(double noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = fcmp olt double %0, 0.000000e+00
  %. = select i1 %5, i32 -1, i32 1
  store i32 %., ptr %1, align 4, !tbaa !5
  %6 = fneg double %0
  %storemerge22 = select i1 %5, double %6, double %0
  store double %storemerge22, ptr %2, align 8, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !5
  %7 = fcmp oeq double %0, 0.000000e+00
  br i1 %7, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %4
  %8 = fcmp ult double %storemerge22, 2.000000e+00
  br i1 %8, label %thread-pre-split, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %9 = phi i32 [ %12, %.lr.ph ], [ 0, %.preheader ]
  %10 = phi double [ %11, %.lr.ph ], [ %storemerge22, %.preheader ]
  %11 = fmul double %10, 5.000000e-01
  %12 = add nuw nsw i32 %9, 1
  %13 = fcmp ult double %11, 2.000000e+00
  br i1 %13, label %.thread-pre-split_crit_edge, label %.lr.ph, !llvm.loop !11

.thread-pre-split_crit_edge:                      ; preds = %.lr.ph
  store double %11, ptr %2, align 8, !tbaa !9
  store i32 %12, ptr %3, align 4, !tbaa !5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %.thread-pre-split_crit_edge, %.preheader
  %.promoted26 = phi i32 [ %12, %.thread-pre-split_crit_edge ], [ 0, %.preheader ]
  %.pr = phi double [ %11, %.thread-pre-split_crit_edge ], [ %storemerge22, %.preheader ]
  %14 = fcmp olt double %.pr, 1.000000e+00
  br i1 %14, label %.lr.ph24, label %.loopexit

.lr.ph24:                                         ; preds = %thread-pre-split, %.lr.ph24
  %15 = phi i32 [ %18, %.lr.ph24 ], [ %.promoted26, %thread-pre-split ]
  %16 = phi double [ %17, %.lr.ph24 ], [ %.pr, %thread-pre-split ]
  %17 = fmul double %16, 2.000000e+00
  %18 = add nsw i32 %15, -1
  %19 = fcmp olt double %17, 1.000000e+00
  br i1 %19, label %.lr.ph24, label %..loopexit_crit_edge, !llvm.loop !13

..loopexit_crit_edge:                             ; preds = %.lr.ph24
  store double %17, ptr %2, align 8, !tbaa !9
  store i32 %18, ptr %3, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %thread-pre-split, %..loopexit_crit_edge, %4
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: write) 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"}
!13 = distinct !{!13, !12}


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