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

@r8_epsilon_compute.value = external hidden global double, align 8

; 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
declare dso_local double @r8_add(double noundef, double noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @r8_epsilon_compute() #1 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load double, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %5 = fcmp oeq double %4, 0.000000e+00
  br i1 %5, label %6, label %25

6:                                                ; preds = %0
  store double 1.000000e+00, ptr %1, align 8, !tbaa !5
  %7 = load double, ptr %1, align 8, !tbaa !5
  store double %7, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %8 = load double, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %9 = fdiv double %8, 2.000000e+00
  store double %9, ptr %2, align 8, !tbaa !5
  %10 = load double, ptr %1, align 8, !tbaa !5
  %11 = load double, ptr %2, align 8, !tbaa !5
  %12 = call double @r8_add(double noundef %10, double noundef %11)
  store double %12, ptr %3, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %17, %6
  %14 = load double, ptr %1, align 8, !tbaa !5
  %15 = load double, ptr %3, align 8, !tbaa !5
  %16 = fcmp olt double %14, %15
  br i1 %16, label %17, label %24

17:                                               ; preds = %13
  %18 = load double, ptr %2, align 8, !tbaa !5
  store double %18, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %19 = load double, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %20 = fdiv double %19, 2.000000e+00
  store double %20, ptr %2, align 8, !tbaa !5
  %21 = load double, ptr %1, align 8, !tbaa !5
  %22 = load double, ptr %2, align 8, !tbaa !5
  %23 = call double @r8_add(double noundef %21, double noundef %22)
  store double %23, ptr %3, align 8, !tbaa !5
  br label %13, !llvm.loop !9

24:                                               ; preds = %13
  br label %25

25:                                               ; preds = %24, %0
  %26 = load double, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  ret double %26
}

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 = distinct !{!9, !10}
!10 = !{!"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"

@r8_epsilon_compute.value = external hidden local_unnamed_addr global double, align 8

; Function Attrs: nounwind uwtable
declare dso_local double @r8_add(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local double @r8_epsilon_compute() local_unnamed_addr #0 {
  %1 = load double, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %2 = fcmp oeq double %1, 0.000000e+00
  br i1 %2, label %3, label %.loopexit

3:                                                ; preds = %0
  store double 1.000000e+00, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %4 = tail call double @r8_add(double noundef 1.000000e+00, double noundef 5.000000e-01)
  %5 = fcmp ogt double %4, 1.000000e+00
  br i1 %5, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.089 = phi double [ %6, %.lr.ph ], [ 5.000000e-01, %3 ]
  store double %.089, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  %6 = fmul double %.089, 5.000000e-01
  %7 = tail call double @r8_add(double noundef 1.000000e+00, double noundef %6)
  %8 = fcmp ogt double %7, 1.000000e+00
  br i1 %8, label %.lr.ph, label %.loopexit, !llvm.loop !9

.loopexit:                                        ; preds = %.lr.ph, %3, %0
  %9 = load double, ptr @r8_epsilon_compute.value, align 8, !tbaa !5
  ret double %9
}

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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass