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

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @asin(double noundef) #2

; Function Attrs: nounwind
declare double @asinh(double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @hyperspherical_get_xmin_from_approx(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4, ptr noundef %5, ptr noundef %6) #3 {
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  store double %2, ptr %10, align 8, !tbaa !9
  store double %3, ptr %11, align 8, !tbaa !9
  store double %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !11
  store ptr %6, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %20 = load i32, ptr %9, align 4, !tbaa !5
  %21 = sitofp i32 %20 to double
  store double %21, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = sitofp i32 %22 to double
  %24 = fadd double %23, 5.000000e-01
  store double %24, ptr %15, align 8, !tbaa !9
  %25 = load double, ptr %15, align 8, !tbaa !9
  %26 = fdiv double 1.000000e+00, %25
  %27 = load double, ptr %12, align 8, !tbaa !9
  %28 = fmul double 2.000000e+00, %27
  %29 = load double, ptr %15, align 8, !tbaa !9
  %30 = fmul double %28, %29
  %31 = call double @log(double noundef %30) #4
  %32 = fmul double %26, %31
  store double %32, ptr %16, align 8, !tbaa !9
  %33 = load double, ptr %16, align 8, !tbaa !9
  %34 = fmul double -2.000000e+00, %33
  %35 = fdiv double %34, 5.000000e+00
  %36 = load double, ptr %16, align 8, !tbaa !9
  %37 = fmul double 1.600000e+01, %36
  %38 = load double, ptr %16, align 8, !tbaa !9
  %39 = fmul double %37, %38
  %40 = fdiv double 3.750000e+02, %39
  %41 = fadd double 1.000000e+00, %40
  %42 = call double @acosh(double noundef %41) #4
  %43 = fmul double 0x3FD5555555555555, %42
  %44 = call double @cosh(double noundef %43) #4
  %45 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %44, double 1.000000e+00)
  %46 = fmul double %35, %45
  store double %46, ptr %17, align 8, !tbaa !9
  %47 = load double, ptr %15, align 8, !tbaa !9
  %48 = load double, ptr %17, align 8, !tbaa !9
  %49 = call double @cosh(double noundef %48) #4
  %50 = fdiv double %47, %49
  %51 = load double, ptr %10, align 8, !tbaa !9
  %52 = fdiv double %50, %51
  store double %52, ptr %19, align 8, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = icmp eq i32 %53, -1
  br i1 %54, label %55, label %74

55:                                               ; preds = %7
  %56 = load double, ptr %18, align 8, !tbaa !9
  %57 = load double, ptr %10, align 8, !tbaa !9
  %58 = fdiv double %56, %57
  %59 = call double @asinh(double noundef %58) #4
  %60 = load double, ptr %18, align 8, !tbaa !9
  %61 = load double, ptr %10, align 8, !tbaa !9
  %62 = fdiv double %60, %61
  %63 = fdiv double %59, %62
  %64 = load double, ptr %19, align 8, !tbaa !9
  %65 = fmul double %64, %63
  store double %65, ptr %19, align 8, !tbaa !9
  %66 = load double, ptr %10, align 8, !tbaa !9
  %67 = fadd double %66, 4.567000e-01
  %68 = load double, ptr %10, align 8, !tbaa !9
  %69 = fadd double %68, 1.240000e+00
  %70 = fdiv double %67, %69
  %71 = fsub double %70, 2.209000e-03
  %72 = load double, ptr %19, align 8, !tbaa !9
  %73 = fmul double %72, %71
  store double %73, ptr %19, align 8, !tbaa !9
  br label %89

74:                                               ; preds = %7
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = icmp eq i32 %75, 1
  br i1 %76, label %77, label %88

77:                                               ; preds = %74
  %78 = load double, ptr %18, align 8, !tbaa !9
  %79 = load double, ptr %10, align 8, !tbaa !9
  %80 = fdiv double %78, %79
  %81 = call double @asin(double noundef %80) #4
  %82 = load double, ptr %18, align 8, !tbaa !9
  %83 = load double, ptr %10, align 8, !tbaa !9
  %84 = fdiv double %82, %83
  %85 = fdiv double %81, %84
  %86 = load double, ptr %19, align 8, !tbaa !9
  %87 = fmul double %86, %85
  store double %87, ptr %19, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %77, %74
  br label %89

89:                                               ; preds = %88, %55
  %90 = load double, ptr %19, align 8, !tbaa !9
  %91 = load ptr, ptr %13, align 8, !tbaa !11
  store double %90, ptr %91, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  ret i32 0
}

; Function Attrs: nounwind
declare double @log(double noundef) #2

; Function Attrs: nounwind
declare double @cosh(double noundef) #2

; Function Attrs: nounwind
declare double @acosh(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @asin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @asinh(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local noundef i32 @hyperspherical_get_xmin_from_approx(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef readnone %6) local_unnamed_addr #2 {
  %8 = sitofp i32 %1 to double
  %9 = fadd double %8, 5.000000e-01
  %10 = fdiv double 1.000000e+00, %9
  %11 = fmul double %4, 2.000000e+00
  %12 = fmul double %9, %11
  %13 = tail call double @log(double noundef %12) #3
  %14 = fmul double %10, %13
  %15 = fmul double %14, -2.000000e+00
  %16 = fdiv double %15, 5.000000e+00
  %17 = fmul double %14, 1.600000e+01
  %18 = fmul double %14, %17
  %19 = fdiv double 3.750000e+02, %18
  %20 = fadd double %19, 1.000000e+00
  %21 = tail call double @acosh(double noundef %20) #3
  %22 = fmul double %21, 0x3FD5555555555555
  %23 = tail call double @cosh(double noundef %22) #3
  %24 = tail call double @llvm.fmuladd.f64(double %23, double 2.000000e+00, double 1.000000e+00)
  %25 = fmul double %16, %24
  %26 = tail call double @cosh(double noundef %25) #3
  %27 = fdiv double %9, %26
  %28 = fdiv double %27, %2
  switch i32 %0, label %49 [
    i32 -1, label %29
    i32 1, label %44
  ]

29:                                               ; preds = %7
  %30 = fdiv double %8, %2
  %31 = tail call double @asinh(double noundef %30) #3
  %32 = fadd double %2, 4.567000e-01
  %33 = fadd double %2, 1.240000e+00
  %34 = insertelement <2 x double> poison, double %32, i64 0
  %35 = insertelement <2 x double> %34, double %31, i64 1
  %36 = insertelement <2 x double> poison, double %33, i64 0
  %37 = insertelement <2 x double> %36, double %30, i64 1
  %38 = fdiv <2 x double> %35, %37
  %39 = extractelement <2 x double> %38, i64 0
  %40 = fadd double %39, -2.209000e-03
  %41 = extractelement <2 x double> %38, i64 1
  %42 = fmul double %28, %41
  %43 = fmul double %40, %42
  br label %49

44:                                               ; preds = %7
  %45 = fdiv double %8, %2
  %46 = tail call double @asin(double noundef %45) #3
  %47 = fdiv double %46, %45
  %48 = fmul double %28, %47
  br label %49

49:                                               ; preds = %7, %44, %29
  %.0 = phi double [ %43, %29 ], [ %48, %44 ], [ %28, %7 ]
  store double %.0, ptr %5, align 8, !tbaa !5
  ret i32 0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cosh(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @acosh(double noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { mustprogress nofree nounwind willreturn 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass