; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

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

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

11:                                               ; preds = %2
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  store double 1.000000e+00, ptr %7, align 8, !tbaa !5
  %15 = load double, ptr %7, align 8, !tbaa !5
  store double %15, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %84

16:                                               ; preds = %11, %2
  %17 = load double, ptr %4, align 8, !tbaa !5
  %18 = fcmp oeq double %17, 0.000000e+00
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  store double 0x7FF8000000000000, ptr %7, align 8, !tbaa !5
  %23 = load double, ptr %7, align 8, !tbaa !5
  store double %23, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %84

24:                                               ; preds = %19, %16
  %25 = load double, ptr %4, align 8, !tbaa !5
  %26 = fcmp olt double %25, 0.000000e+00
  br i1 %26, label %27, label %36

27:                                               ; preds = %24
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = srem i32 %28, 2
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %36

31:                                               ; preds = %27
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = icmp slt i32 0, %32
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  store double 0x7FF8000000000000, ptr %7, align 8, !tbaa !5
  %35 = load double, ptr %7, align 8, !tbaa !5
  store double %35, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %84

36:                                               ; preds = %31, %27, %24
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  store double 1.000000e+00, ptr %7, align 8, !tbaa !5
  br label %82

40:                                               ; preds = %36
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %45

43:                                               ; preds = %40
  %44 = load double, ptr %4, align 8, !tbaa !5
  store double %44, ptr %7, align 8, !tbaa !5
  br label %81

45:                                               ; preds = %40
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = icmp eq i32 %46, -1
  br i1 %47, label %48, label %51

48:                                               ; preds = %45
  %49 = load double, ptr %4, align 8, !tbaa !5
  %50 = fdiv double 1.000000e+00, %49
  store double %50, ptr %7, align 8, !tbaa !5
  br label %80

51:                                               ; preds = %45
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = call i32 @llvm.abs.i32(i32 %52, i1 true)
  %54 = sitofp i32 %53 to double
  %55 = fdiv double 1.000000e+00, %54
  store double %55, ptr %6, align 8, !tbaa !5
  %56 = load double, ptr %4, align 8, !tbaa !5
  %57 = fcmp olt double 0.000000e+00, %56
  br i1 %57, label %58, label %62

58:                                               ; preds = %51
  %59 = load double, ptr %4, align 8, !tbaa !5
  %60 = load double, ptr %6, align 8, !tbaa !5
  %61 = call double @pow(double noundef %59, double noundef %60) #4
  store double %61, ptr %7, align 8, !tbaa !5
  br label %73

62:                                               ; preds = %51
  %63 = load double, ptr %4, align 8, !tbaa !5
  %64 = fcmp oeq double %63, 0.000000e+00
  br i1 %64, label %65, label %66

65:                                               ; preds = %62
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  br label %72

66:                                               ; preds = %62
  %67 = load double, ptr %4, align 8, !tbaa !5
  %68 = fneg double %67
  %69 = load double, ptr %6, align 8, !tbaa !5
  %70 = call double @pow(double noundef %68, double noundef %69) #4
  %71 = fneg double %70
  store double %71, ptr %7, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %66, %65
  br label %73

73:                                               ; preds = %72, %58
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = icmp slt i32 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %73
  %77 = load double, ptr %7, align 8, !tbaa !5
  %78 = fdiv double 1.000000e+00, %77
  store double %78, ptr %7, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %76, %73
  br label %80

80:                                               ; preds = %79, %48
  br label %81

81:                                               ; preds = %80, %43
  br label %82

82:                                               ; preds = %81, %39
  %83 = load double, ptr %7, align 8, !tbaa !5
  store double %83, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %84

84:                                               ; preds = %82, %34, %22, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %85 = load double, ptr %3, align 8
  ret double %85
}

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 = !{!"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}


; 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 i32 @llvm.abs.i32(i32, i1 immarg) #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local double @r8_nth_root(double noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = fcmp oeq double %0, 0.000000e+00
  %4 = icmp eq i32 %1, 0
  %or.cond = and i1 %3, %4
  br i1 %or.cond, label %32, label %5

5:                                                ; preds = %2
  %6 = icmp slt i32 %1, 0
  %or.cond3 = and i1 %3, %6
  br i1 %or.cond3, label %32, label %7

7:                                                ; preds = %5
  %8 = fcmp olt double %0, 0.000000e+00
  br i1 %8, label %9, label %13

9:                                                ; preds = %7
  %10 = and i32 %1, 1
  %11 = icmp eq i32 %10, 0
  %12 = icmp sgt i32 %1, 0
  %or.cond5 = and i1 %12, %11
  %brmerge = or i1 %4, %or.cond5
  %.mux = select i1 %or.cond5, double 0x7FF8000000000000, double 1.000000e+00
  br i1 %brmerge, label %32, label %14

13:                                               ; preds = %7
  br i1 %4, label %32, label %14

14:                                               ; preds = %9, %13
  switch i32 %1, label %17 [
    i32 1, label %32
    i32 -1, label %15
  ]

15:                                               ; preds = %14
  %16 = fdiv double 1.000000e+00, %0
  br label %32

17:                                               ; preds = %14
  %18 = tail call i32 @llvm.abs.i32(i32 %1, i1 true)
  %19 = uitofp nneg i32 %18 to double
  %20 = fdiv double 1.000000e+00, %19
  %21 = fcmp ogt double %0, 0.000000e+00
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  %23 = tail call double @pow(double noundef %0, double noundef %20) #3
  br label %29

24:                                               ; preds = %17
  br i1 %3, label %29, label %25

25:                                               ; preds = %24
  %26 = fneg double %0
  %27 = tail call double @pow(double noundef %26, double noundef %20) #3
  %28 = fneg double %27
  br label %29

29:                                               ; preds = %24, %25, %22
  %.0 = phi double [ %23, %22 ], [ %28, %25 ], [ 0.000000e+00, %24 ]
  br i1 %6, label %30, label %32

30:                                               ; preds = %29
  %31 = fdiv double 1.000000e+00, %.0
  br label %32

32:                                               ; preds = %9, %15, %30, %29, %13, %14, %5, %2
  %.030 = phi double [ 1.000000e+00, %2 ], [ 0x7FF8000000000000, %5 ], [ %.mux, %9 ], [ %16, %15 ], [ %31, %30 ], [ %.0, %29 ], [ 1.000000e+00, %13 ], [ %0, %14 ]
  ret double %.030
}

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)"}


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