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

; Function Attrs: nounwind uwtable
define dso_local double @r8_roundx(i32 noundef %0, double noundef %1) #2 {
  %3 = alloca double, align 8
  %4 = alloca i32, align 4
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 1.000000e+01, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store double 0.000000e+00, ptr %11, align 8, !tbaa !9
  %14 = load double, ptr %5, align 8, !tbaa !9
  %15 = fcmp oeq double %14, 0.000000e+00
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = load double, ptr %11, align 8, !tbaa !9
  store double %17, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %91

18:                                               ; preds = %2
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp sle i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %18
  %22 = load double, ptr %11, align 8, !tbaa !9
  store double %22, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %91

23:                                               ; preds = %18
  %24 = load double, ptr %5, align 8, !tbaa !9
  %25 = fcmp olt double 0.000000e+00, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  store i32 1, ptr %7, align 4, !tbaa !5
  %27 = load double, ptr %5, align 8, !tbaa !9
  store double %27, ptr %12, align 8, !tbaa !9
  br label %31

28:                                               ; preds = %23
  store i32 -1, ptr %7, align 4, !tbaa !5
  %29 = load double, ptr %5, align 8, !tbaa !9
  %30 = fneg double %29
  store double %30, ptr %12, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %28, %26
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %35, %31
  %33 = load double, ptr %5, align 8, !tbaa !9
  %34 = fcmp ole double 1.000000e+01, %33
  br i1 %34, label %35, label %40

35:                                               ; preds = %32
  %36 = load double, ptr %12, align 8, !tbaa !9
  %37 = fdiv double %36, 1.000000e+01
  store double %37, ptr %12, align 8, !tbaa !9
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %8, align 4, !tbaa !5
  br label %32, !llvm.loop !11

40:                                               ; preds = %32
  br label %41

41:                                               ; preds = %44, %40
  %42 = load double, ptr %12, align 8, !tbaa !9
  %43 = fcmp olt double %42, 1.000000e+00
  br i1 %43, label %44, label %49

44:                                               ; preds = %41
  %45 = load double, ptr %12, align 8, !tbaa !9
  %46 = fmul double %45, 1.000000e+01
  store double %46, ptr %12, align 8, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  store i32 %48, ptr %8, align 4, !tbaa !5
  br label %41, !llvm.loop !13

49:                                               ; preds = %41
  store double 0.000000e+00, ptr %10, align 8, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %84, %49
  %51 = load double, ptr %10, align 8, !tbaa !9
  %52 = fmul double 1.000000e+01, %51
  store double %52, ptr %10, align 8, !tbaa !9
  %53 = load double, ptr %12, align 8, !tbaa !9
  %54 = fcmp ole double 1.000000e+00, %53
  br i1 %54, label %55, label %66

55:                                               ; preds = %50
  %56 = load double, ptr %10, align 8, !tbaa !9
  %57 = load double, ptr %12, align 8, !tbaa !9
  %58 = fptosi double %57 to i32
  %59 = sitofp i32 %58 to double
  %60 = fadd double %56, %59
  store double %60, ptr %10, align 8, !tbaa !9
  %61 = load double, ptr %12, align 8, !tbaa !9
  %62 = load double, ptr %12, align 8, !tbaa !9
  %63 = fptosi double %62 to i32
  %64 = sitofp i32 %63 to double
  %65 = fsub double %61, %64
  store double %65, ptr %12, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %55, %50
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !5
  %69 = load double, ptr %12, align 8, !tbaa !9
  %70 = fcmp oeq double %69, 0.000000e+00
  br i1 %70, label %75, label %71

71:                                               ; preds = %66
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %75, label %84

75:                                               ; preds = %71, %66
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = sitofp i32 %76 to double
  %78 = load double, ptr %10, align 8, !tbaa !9
  %79 = fmul double %77, %78
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = sitofp i32 %80 to double
  %82 = call double @pow(double noundef 1.000000e+01, double noundef %81) #3
  %83 = fmul double %79, %82
  store double %83, ptr %11, align 8, !tbaa !9
  br label %89

84:                                               ; preds = %71
  %85 = load i32, ptr %8, align 4, !tbaa !5
  %86 = sub nsw i32 %85, 1
  store i32 %86, ptr %8, align 4, !tbaa !5
  %87 = load double, ptr %12, align 8, !tbaa !9
  %88 = fmul double %87, 1.000000e+01
  store double %88, ptr %12, align 8, !tbaa !9
  br label %50

89:                                               ; preds = %75
  %90 = load double, ptr %11, align 8, !tbaa !9
  store double %90, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %91

91:                                               ; preds = %89, %21, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %92 = load double, ptr %3, align 8
  ret double %92
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 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 #3 = { 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 = !{!"double", !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: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(write) uwtable
define dso_local double @r8_roundx(i32 noundef %0, double noundef %1) local_unnamed_addr #1 {
  %3 = fcmp oeq double %1, 0.000000e+00
  %4 = icmp slt i32 %0, 1
  %or.cond40 = or i1 %4, %3
  br i1 %or.cond40, label %30, label %5

5:                                                ; preds = %2
  %6 = fcmp ogt double %1, 0.000000e+00
  %7 = fcmp ult double %1, 1.000000e+01
  br i1 %7, label %.preheader41, label %.lr.ph.split

.preheader41:                                     ; preds = %5
  %8 = fneg double %1
  %.0 = select i1 %6, double %1, double %8
  %9 = fcmp olt double %.0, 1.000000e+00
  br i1 %9, label %.lr.ph48, label %.preheader.preheader

.lr.ph.split:                                     ; preds = %5, %.lr.ph.split
  br label %.lr.ph.split

.lr.ph48:                                         ; preds = %.preheader41, %.lr.ph48
  %.247 = phi double [ %10, %.lr.ph48 ], [ %.0, %.preheader41 ]
  %.13346 = phi i32 [ %11, %.lr.ph48 ], [ 0, %.preheader41 ]
  %10 = fmul double %.247, 1.000000e+01
  %11 = add nsw i32 %.13346, -1
  %12 = fcmp olt double %10, 1.000000e+00
  br i1 %12, label %.lr.ph48, label %.preheader.preheader, !llvm.loop !5

.preheader.preheader:                             ; preds = %.lr.ph48, %.preheader41
  %.234.ph = phi i32 [ 0, %.preheader41 ], [ %11, %.lr.ph48 ]
  %.3.ph = phi double [ %.0, %.preheader41 ], [ %10, %.lr.ph48 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %27
  %.036 = phi i32 [ %19, %27 ], [ 0, %.preheader.preheader ]
  %.234 = phi i32 [ %28, %27 ], [ %.234.ph, %.preheader.preheader ]
  %.029 = phi double [ %.130, %27 ], [ 0.000000e+00, %.preheader.preheader ]
  %.3 = phi double [ %29, %27 ], [ %.3.ph, %.preheader.preheader ]
  %13 = fmul double %.029, 1.000000e+01
  %14 = fcmp ult double %.3, 1.000000e+00
  %15 = fptosi double %.3 to i32
  %16 = sitofp i32 %15 to double
  %17 = fadd double %13, %16
  %18 = fsub double %.3, %16
  %.130 = select i1 %14, double %13, double %17
  %.4 = select i1 %14, double %.3, double %18
  %19 = add nuw nsw i32 %.036, 1
  %20 = fcmp une double %.4, 0.000000e+00
  %.not = icmp slt i32 %19, %0
  %or.cond = select i1 %20, i1 %.not, i1 false
  br i1 %or.cond, label %27, label %21

21:                                               ; preds = %.preheader
  %22 = fneg double %.130
  %23 = select i1 %6, double %.130, double %22
  %24 = sitofp i32 %.234 to double
  %25 = tail call double @pow(double noundef 1.000000e+01, double noundef %24) #2
  %26 = fmul double %23, %25
  br label %30

27:                                               ; preds = %.preheader
  %28 = add nsw i32 %.234, -1
  %29 = fmul double %.4, 1.000000e+01
  br label %.preheader

30:                                               ; preds = %2, %21
  %.031 = phi double [ %26, %21 ], [ 0.000000e+00, %2 ]
  ret double %.031
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 #1 = { nofree nounwind memory(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" }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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