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

; 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 speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; 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
define dso_local void @sphericalCoordinates(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 0x3D06849B86A12B9B, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds double, ptr %12, i64 0
  %14 = load double, ptr %13, align 8, !tbaa !9
  store double %14, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds double, ptr %15, i64 1
  %17 = load double, ptr %16, align 8, !tbaa !9
  store double %17, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds double, ptr %18, i64 2
  %20 = load double, ptr %19, align 8, !tbaa !9
  store double %20, ptr %11, align 8, !tbaa !9
  %21 = load double, ptr %9, align 8, !tbaa !9
  %22 = load double, ptr %9, align 8, !tbaa !9
  %23 = load double, ptr %10, align 8, !tbaa !9
  %24 = load double, ptr %10, align 8, !tbaa !9
  %25 = fmul double %23, %24
  %26 = call double @llvm.fmuladd.f64(double %21, double %22, double %25)
  %27 = load double, ptr %11, align 8, !tbaa !9
  %28 = load double, ptr %11, align 8, !tbaa !9
  %29 = call double @llvm.fmuladd.f64(double %27, double %28, double %26)
  %30 = call double @sqrt(double noundef %29) #4
  store double %30, ptr %5, align 8, !tbaa !9
  %31 = load double, ptr %5, align 8, !tbaa !9
  %32 = fcmp olt double %31, 0x3D06849B86A12B9B
  br i1 %32, label %33, label %34

33:                                               ; preds = %2
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  br label %39

34:                                               ; preds = %2
  %35 = load double, ptr %11, align 8, !tbaa !9
  %36 = load double, ptr %5, align 8, !tbaa !9
  %37 = fdiv double %35, %36
  %38 = call double @acos(double noundef %37) #4
  store double %38, ptr %6, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %34, %33
  %40 = load double, ptr %9, align 8, !tbaa !9
  %41 = call double @llvm.fabs.f64(double %40)
  %42 = fcmp olt double %41, 0x3D06849B86A12B9B
  br i1 %42, label %43, label %55

43:                                               ; preds = %39
  %44 = load double, ptr %10, align 8, !tbaa !9
  %45 = call double @llvm.fabs.f64(double %44)
  %46 = fcmp olt double %45, 0x3D06849B86A12B9B
  br i1 %46, label %47, label %48

47:                                               ; preds = %43
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  br label %54

48:                                               ; preds = %43
  %49 = load double, ptr %10, align 8, !tbaa !9
  %50 = fcmp olt double %49, 0.000000e+00
  br i1 %50, label %51, label %52

51:                                               ; preds = %48
  store double 0x4012D97C7F3321D2, ptr %7, align 8, !tbaa !9
  br label %53

52:                                               ; preds = %48
  store double 0x3FF921FB54442D18, ptr %7, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %52, %51
  br label %54

54:                                               ; preds = %53, %47
  br label %70

55:                                               ; preds = %39
  %56 = load double, ptr %9, align 8, !tbaa !9
  %57 = fcmp ogt double %56, 0.000000e+00
  br i1 %57, label %58, label %63

58:                                               ; preds = %55
  %59 = load double, ptr %10, align 8, !tbaa !9
  %60 = load double, ptr %9, align 8, !tbaa !9
  %61 = fdiv double %59, %60
  %62 = call double @atan(double noundef %61) #4
  store double %62, ptr %7, align 8, !tbaa !9
  br label %69

63:                                               ; preds = %55
  %64 = load double, ptr %10, align 8, !tbaa !9
  %65 = load double, ptr %9, align 8, !tbaa !9
  %66 = fdiv double %64, %65
  %67 = call double @atan(double noundef %66) #4
  %68 = fadd double %67, 0x400921FB54442D18
  store double %68, ptr %7, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %63, %58
  br label %70

70:                                               ; preds = %69, %54
  %71 = load double, ptr %5, align 8, !tbaa !9
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds double, ptr %72, i64 0
  store double %71, ptr %73, align 8, !tbaa !9
  %74 = load double, ptr %6, align 8, !tbaa !9
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds double, ptr %75, i64 1
  store double %74, ptr %76, align 8, !tbaa !9
  %77 = load double, ptr %7, align 8, !tbaa !9
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds double, ptr %78, i64 2
  store double %77, ptr %79, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; 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) #1

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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.fabs.f64(double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @sphericalCoordinates(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = fmul double %5, %5
  %9 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %8)
  %10 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %9)
  %sqrt = tail call double @llvm.sqrt.f64(double %10)
  %11 = fcmp olt double %sqrt, 0x3D06849B86A12B9B
  br i1 %11, label %15, label %12

12:                                               ; preds = %2
  %13 = fdiv double %7, %sqrt
  %14 = tail call double @acos(double noundef %13) #4
  br label %15

15:                                               ; preds = %2, %12
  %.0 = phi double [ %14, %12 ], [ 0.000000e+00, %2 ]
  %16 = tail call double @llvm.fabs.f64(double %3)
  %17 = fcmp olt double %16, 0x3D06849B86A12B9B
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = tail call double @llvm.fabs.f64(double %5)
  %20 = fcmp olt double %19, 0x3D06849B86A12B9B
  br i1 %20, label %29, label %21

21:                                               ; preds = %18
  %22 = fcmp olt double %5, 0.000000e+00
  %. = select i1 %22, double 0x4012D97C7F3321D2, double 0x3FF921FB54442D18
  br label %29

23:                                               ; preds = %15
  %24 = fcmp ogt double %3, 0.000000e+00
  %25 = fdiv double %5, %3
  %26 = tail call double @atan(double noundef %25) #4
  br i1 %24, label %29, label %27

27:                                               ; preds = %23
  %28 = fadd double %26, 0x400921FB54442D18
  br label %29

29:                                               ; preds = %23, %21, %18, %27
  %.026 = phi double [ %28, %27 ], [ 0.000000e+00, %18 ], [ %., %21 ], [ %26, %23 ]
  store double %sqrt, ptr %1, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  store double %.0, ptr %30, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 16
  store double %.026, ptr %31, align 8, !tbaa !5
  ret void
}

; 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 @acos(double noundef) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"}


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