; 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 double @r8_rise(double noundef %0, i32 noundef %1) #1 {
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  store double %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store double 1.000000e+00, ptr %6, align 8, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 0, %7
  br i1 %8, label %9, label %24

9:                                                ; preds = %2
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %20, %9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %14, label %23

14:                                               ; preds = %10
  %15 = load double, ptr %6, align 8, !tbaa !5
  %16 = load double, ptr %3, align 8, !tbaa !5
  %17 = fmul double %15, %16
  store double %17, ptr %6, align 8, !tbaa !5
  %18 = load double, ptr %3, align 8, !tbaa !5
  %19 = fadd double %18, 1.000000e+00
  store double %19, ptr %3, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %14
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %5, align 4, !tbaa !9
  br label %10, !llvm.loop !11

23:                                               ; preds = %10
  br label %43

24:                                               ; preds = %2
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %42

27:                                               ; preds = %24
  store i32 -1, ptr %5, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %38, %27
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = icmp sle i32 %29, %30
  br i1 %31, label %32, label %41

32:                                               ; preds = %28
  %33 = load double, ptr %6, align 8, !tbaa !5
  %34 = load double, ptr %3, align 8, !tbaa !5
  %35 = fmul double %33, %34
  store double %35, ptr %6, align 8, !tbaa !5
  %36 = load double, ptr %3, align 8, !tbaa !5
  %37 = fsub double %36, 1.000000e+00
  store double %37, ptr %3, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %32
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr %5, align 4, !tbaa !9
  br label %28, !llvm.loop !13

41:                                               ; preds = %28
  br label %42

42:                                               ; preds = %41, %24
  br label %43

43:                                               ; preds = %42, %23
  %44 = load double, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret double %44
}

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


; 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(none) uwtable
define dso_local double @r8_rise(double noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %1, 0
  br i1 %3, label %.preheader.preheader, label %21

.preheader.preheader:                             ; preds = %2
  %xtraiter38 = and i32 %1, 7
  %4 = icmp ult i32 %1, 8
  br i1 %4, label %.loopexit.loopexit.unr-lcssa, label %.preheader.preheader.new

.preheader.preheader.new:                         ; preds = %.preheader.preheader
  %unroll_iter42 = and i32 %1, 2147483640
  br label %.preheader

.preheader:                                       ; preds = %.preheader, %.preheader.preheader.new
  %.028 = phi double [ 1.000000e+00, %.preheader.preheader.new ], [ %19, %.preheader ]
  %.01626 = phi double [ %0, %.preheader.preheader.new ], [ %20, %.preheader ]
  %niter43 = phi i32 [ 0, %.preheader.preheader.new ], [ %niter43.next.7, %.preheader ]
  %5 = fmul double %.01626, %.028
  %6 = fadd double %.01626, 1.000000e+00
  %7 = fmul double %6, %5
  %8 = fadd double %6, 1.000000e+00
  %9 = fmul double %8, %7
  %10 = fadd double %8, 1.000000e+00
  %11 = fmul double %10, %9
  %12 = fadd double %10, 1.000000e+00
  %13 = fmul double %12, %11
  %14 = fadd double %12, 1.000000e+00
  %15 = fmul double %14, %13
  %16 = fadd double %14, 1.000000e+00
  %17 = fmul double %16, %15
  %18 = fadd double %16, 1.000000e+00
  %19 = fmul double %18, %17
  %20 = fadd double %18, 1.000000e+00
  %niter43.next.7 = add i32 %niter43, 8
  %niter43.ncmp.7 = icmp eq i32 %niter43.next.7, %unroll_iter42
  br i1 %niter43.ncmp.7, label %.loopexit.loopexit.unr-lcssa, label %.preheader, !llvm.loop !5

21:                                               ; preds = %2
  %22 = icmp slt i32 %1, 0
  br i1 %22, label %.preheader21.preheader, label %.loopexit

.preheader21.preheader:                           ; preds = %21
  %23 = sub i32 0, %1
  %xtraiter = and i32 %23, 7
  %24 = icmp ugt i32 %1, -8
  br i1 %24, label %.loopexit.loopexit35.unr-lcssa, label %.preheader21.preheader.new

.preheader21.preheader.new:                       ; preds = %.preheader21.preheader
  %unroll_iter = and i32 %23, -8
  br label %.preheader21

.preheader21:                                     ; preds = %.preheader21, %.preheader21.preheader.new
  %.125 = phi double [ 1.000000e+00, %.preheader21.preheader.new ], [ %39, %.preheader21 ]
  %.11723 = phi double [ %0, %.preheader21.preheader.new ], [ %40, %.preheader21 ]
  %niter = phi i32 [ 0, %.preheader21.preheader.new ], [ %niter.next.7, %.preheader21 ]
  %25 = fmul double %.11723, %.125
  %26 = fadd double %.11723, -1.000000e+00
  %27 = fmul double %26, %25
  %28 = fadd double %26, -1.000000e+00
  %29 = fmul double %28, %27
  %30 = fadd double %28, -1.000000e+00
  %31 = fmul double %30, %29
  %32 = fadd double %30, -1.000000e+00
  %33 = fmul double %32, %31
  %34 = fadd double %32, -1.000000e+00
  %35 = fmul double %34, %33
  %36 = fadd double %34, -1.000000e+00
  %37 = fmul double %36, %35
  %38 = fadd double %36, -1.000000e+00
  %39 = fmul double %38, %37
  %40 = fadd double %38, -1.000000e+00
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7.not = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7.not, label %.loopexit.loopexit35.unr-lcssa, label %.preheader21, !llvm.loop !7

.loopexit.loopexit.unr-lcssa:                     ; preds = %.preheader, %.preheader.preheader
  %.lcssa.ph = phi double [ poison, %.preheader.preheader ], [ %19, %.preheader ]
  %.028.unr = phi double [ 1.000000e+00, %.preheader.preheader ], [ %19, %.preheader ]
  %.01626.unr = phi double [ %0, %.preheader.preheader ], [ %20, %.preheader ]
  %lcmp.mod40.not = icmp eq i32 %xtraiter38, 0
  br i1 %lcmp.mod40.not, label %.loopexit, label %.preheader.epil

.preheader.epil:                                  ; preds = %.loopexit.loopexit.unr-lcssa, %.preheader.epil
  %.028.epil = phi double [ %41, %.preheader.epil ], [ %.028.unr, %.loopexit.loopexit.unr-lcssa ]
  %.01626.epil = phi double [ %42, %.preheader.epil ], [ %.01626.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter39 = phi i32 [ %epil.iter39.next, %.preheader.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %41 = fmul double %.01626.epil, %.028.epil
  %42 = fadd double %.01626.epil, 1.000000e+00
  %epil.iter39.next = add i32 %epil.iter39, 1
  %epil.iter39.cmp.not = icmp eq i32 %epil.iter39.next, %xtraiter38
  br i1 %epil.iter39.cmp.not, label %.loopexit, label %.preheader.epil, !llvm.loop !8

.loopexit.loopexit35.unr-lcssa:                   ; preds = %.preheader21, %.preheader21.preheader
  %.lcssa36.ph = phi double [ poison, %.preheader21.preheader ], [ %39, %.preheader21 ]
  %.125.unr = phi double [ 1.000000e+00, %.preheader21.preheader ], [ %39, %.preheader21 ]
  %.11723.unr = phi double [ %0, %.preheader21.preheader ], [ %40, %.preheader21 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.preheader21.epil

.preheader21.epil:                                ; preds = %.loopexit.loopexit35.unr-lcssa, %.preheader21.epil
  %.125.epil = phi double [ %43, %.preheader21.epil ], [ %.125.unr, %.loopexit.loopexit35.unr-lcssa ]
  %.11723.epil = phi double [ %44, %.preheader21.epil ], [ %.11723.unr, %.loopexit.loopexit35.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.preheader21.epil ], [ 0, %.loopexit.loopexit35.unr-lcssa ]
  %43 = fmul double %.11723.epil, %.125.epil
  %44 = fadd double %.11723.epil, -1.000000e+00
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.preheader21.epil, !llvm.loop !10

.loopexit:                                        ; preds = %.loopexit.loopexit35.unr-lcssa, %.preheader21.epil, %.loopexit.loopexit.unr-lcssa, %.preheader.epil, %21
  %.2 = phi double [ 1.000000e+00, %21 ], [ %.lcssa.ph, %.loopexit.loopexit.unr-lcssa ], [ %41, %.preheader.epil ], [ %.lcssa36.ph, %.loopexit.loopexit35.unr-lcssa ], [ %43, %.preheader21.epil ]
  ret double %.2
}

attributes #0 = { nofree norecurse nosync nounwind memory(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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.unroll.disable"}
!10 = distinct !{!10, !9}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass