; LLVM IR from chrr/libECP :: src (util)

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

@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.gtoRadius = external hidden unnamed_addr constant [70 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

; 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 @sqrt(double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind uwtable
define dso_local double @gtoRadius(double noundef %0, double noundef %1, i32 noundef %2, double noundef %3) #4 {
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca double, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store double 0.000000e+00, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 40, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = call double @llvm.fabs.f64(double %18)
  %20 = load double, ptr %8, align 8, !tbaa !5
  %21 = call double @llvm.fabs.f64(double %20)
  %22 = fdiv double %19, %21
  %23 = call double @log(double noundef %22) #5
  store double %23, ptr %17, align 8, !tbaa !5
  %24 = load double, ptr %17, align 8, !tbaa !5
  %25 = load double, ptr %6, align 8, !tbaa !5
  %26 = fdiv double %24, %25
  store double %26, ptr %11, align 8, !tbaa !5
  %27 = load double, ptr %11, align 8, !tbaa !5
  %28 = load double, ptr %8, align 8, !tbaa !5
  %29 = fcmp ogt double %27, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %4
  %31 = load double, ptr %11, align 8, !tbaa !5
  br label %34

32:                                               ; preds = %4
  %33 = load double, ptr %8, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %32, %30
  %35 = phi double [ %31, %30 ], [ %33, %32 ]
  store double %35, ptr %14, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = icmp ne i32 0, %36
  br i1 %37, label %38, label %123

38:                                               ; preds = %34
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = icmp slt i32 0, %39
  br i1 %40, label %41, label %67

41:                                               ; preds = %38
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = sitofp i32 %42 to double
  %44 = fmul double 5.000000e-01, %43
  %45 = load double, ptr %5, align 8, !tbaa !5
  %46 = call double @llvm.fabs.f64(double %45)
  %47 = fdiv double %44, %46
  %48 = call double @sqrt(double noundef %47) #5
  store double %48, ptr %11, align 8, !tbaa !5
  %49 = load double, ptr %11, align 8, !tbaa !5
  %50 = load double, ptr %8, align 8, !tbaa !5
  %51 = fcmp ogt double %49, %50
  br i1 %51, label %52, label %54

52:                                               ; preds = %41
  %53 = load double, ptr %11, align 8, !tbaa !5
  br label %56

54:                                               ; preds = %41
  %55 = load double, ptr %8, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %54, %52
  %57 = phi double [ %53, %52 ], [ %55, %54 ]
  store double %57, ptr %12, align 8, !tbaa !5
  %58 = load double, ptr %12, align 8, !tbaa !5
  %59 = load double, ptr %14, align 8, !tbaa !5
  %60 = fcmp ogt double %58, %59
  br i1 %60, label %61, label %66

61:                                               ; preds = %56
  %62 = load double, ptr %14, align 8, !tbaa !5
  %63 = load double, ptr %12, align 8, !tbaa !5
  %64 = fadd double %62, %63
  %65 = fmul double 5.000000e-01, %64
  store double %65, ptr %14, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %61, %56
  br label %67

67:                                               ; preds = %66, %38
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %114, %67
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = icmp slt i32 %69, 40
  br i1 %70, label %71, label %117

71:                                               ; preds = %68
  %72 = load double, ptr %6, align 8, !tbaa !5
  %73 = load double, ptr %14, align 8, !tbaa !5
  %74 = fmul double %72, %73
  store double %74, ptr %13, align 8, !tbaa !5
  %75 = load double, ptr %17, align 8, !tbaa !5
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = sitofp i32 %76 to double
  %78 = load double, ptr %14, align 8, !tbaa !5
  %79 = call double @log(double noundef %78) #5
  %80 = call double @llvm.fmuladd.f64(double %77, double %79, double %75)
  %81 = load double, ptr %13, align 8, !tbaa !5
  %82 = load double, ptr %14, align 8, !tbaa !5
  %83 = fneg double %81
  %84 = call double @llvm.fmuladd.f64(double %83, double %82, double %80)
  store double %84, ptr %12, align 8, !tbaa !5
  %85 = load double, ptr %12, align 8, !tbaa !5
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = sitofp i32 %86 to double
  %88 = load double, ptr %14, align 8, !tbaa !5
  %89 = fdiv double %87, %88
  %90 = load double, ptr %13, align 8, !tbaa !5
  %91 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %90, double %89)
  %92 = fdiv double %85, %91
  store double %92, ptr %10, align 8, !tbaa !5
  %93 = load double, ptr %14, align 8, !tbaa !5
  %94 = load double, ptr %10, align 8, !tbaa !5
  %95 = fsub double %93, %94
  store double %95, ptr %11, align 8, !tbaa !5
  %96 = load double, ptr %11, align 8, !tbaa !5
  %97 = load double, ptr %8, align 8, !tbaa !5
  %98 = fcmp ogt double %96, %97
  br i1 %98, label %99, label %101

99:                                               ; preds = %71
  %100 = load double, ptr %11, align 8, !tbaa !5
  br label %103

101:                                              ; preds = %71
  %102 = load double, ptr %8, align 8, !tbaa !5
  br label %103

103:                                              ; preds = %101, %99
  %104 = phi double [ %100, %99 ], [ %102, %101 ]
  store double %104, ptr %14, align 8, !tbaa !5
  %105 = load double, ptr %10, align 8, !tbaa !5
  %106 = call double @llvm.fabs.f64(double %105)
  %107 = load double, ptr %8, align 8, !tbaa !5
  %108 = fcmp olt double %106, %107
  br i1 %108, label %109, label %113

109:                                              ; preds = %103
  %110 = load double, ptr %14, align 8, !tbaa !5
  %111 = load double, ptr %14, align 8, !tbaa !5
  %112 = fmul double %111, %110
  store double %112, ptr %14, align 8, !tbaa !5
  store i32 1, ptr %16, align 4, !tbaa !9
  br label %117

113:                                              ; preds = %103
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = add nsw i32 %115, 1
  store i32 %116, ptr %9, align 4, !tbaa !9
  br label %68, !llvm.loop !11

117:                                              ; preds = %109, %68
  %118 = load i32, ptr %16, align 4, !tbaa !9
  %119 = icmp ne i32 0, %118
  br i1 %119, label %120, label %121

120:                                              ; preds = %117
  br label %122

121:                                              ; preds = %117
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 169, ptr noundef @__PRETTY_FUNCTION__.gtoRadius) #6
  unreachable

122:                                              ; preds = %120
  br label %123

123:                                              ; preds = %122, %34
  %124 = load double, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret double %124
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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"}


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

@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.gtoRadius = external hidden unnamed_addr constant [70 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local double @gtoRadius(double noundef %0, double noundef %1, i32 noundef %2, double noundef %3) local_unnamed_addr #3 {
  %5 = tail call double @llvm.fabs.f64(double %0)
  %6 = fdiv double %0, %3
  %7 = tail call double @llvm.fabs.f64(double %6)
  %8 = tail call double @log(double noundef %7) #4
  %9 = fdiv double %8, %1
  %10 = fcmp ogt double %9, %3
  %11 = select i1 %10, double %9, double %3
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %46, label %12

12:                                               ; preds = %4
  %13 = icmp sgt i32 %2, 0
  br i1 %13, label %14, label %25

14:                                               ; preds = %12
  %15 = uitofp nneg i32 %2 to double
  %16 = fmul double %15, 5.000000e-01
  %17 = fdiv double %16, %5
  %18 = tail call double @sqrt(double noundef %17) #4
  %19 = fcmp ogt double %18, %3
  %20 = select i1 %19, double %18, double %3
  %21 = fcmp ogt double %20, %11
  br i1 %21, label %22, label %25

22:                                               ; preds = %14
  %23 = fadd double %11, %20
  %24 = fmul double %23, 5.000000e-01
  br label %25

25:                                               ; preds = %14, %22, %12
  %.045 = phi double [ %24, %22 ], [ %11, %14 ], [ %11, %12 ]
  %26 = sitofp i32 %2 to double
  br label %29

27:                                               ; preds = %29
  %28 = add nuw nsw i32 %.053, 1
  %exitcond = icmp eq i32 %28, 40
  br i1 %exitcond, label %45, label %29, !llvm.loop !5

29:                                               ; preds = %25, %27
  %.053 = phi i32 [ 0, %25 ], [ %28, %27 ]
  %.152 = phi double [ %.045, %25 ], [ %40, %27 ]
  %30 = fmul double %.152, %1
  %31 = tail call double @log(double noundef %.152) #4
  %32 = tail call double @llvm.fmuladd.f64(double %26, double %31, double %8)
  %33 = fneg double %30
  %34 = tail call double @llvm.fmuladd.f64(double %33, double %.152, double %32)
  %35 = fdiv double %26, %.152
  %36 = tail call double @llvm.fmuladd.f64(double %30, double -2.000000e+00, double %35)
  %37 = fdiv double %34, %36
  %38 = fsub double %.152, %37
  %39 = fcmp ogt double %38, %3
  %40 = select i1 %39, double %38, double %3
  %41 = tail call double @llvm.fabs.f64(double %37)
  %42 = fcmp olt double %41, %3
  br i1 %42, label %43, label %27

43:                                               ; preds = %29
  %44 = fmul double %40, %40
  br label %46

45:                                               ; preds = %27
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 169, ptr noundef nonnull @__PRETTY_FUNCTION__.gtoRadius) #5
  unreachable

46:                                               ; preds = %43, %4
  %.3 = phi double [ %44, %43 ], [ %11, %4 ]
  ret double %.3
}

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

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 }
attributes #5 = { noreturn 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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass