; LLVM IR from bark-simulator/bark :: bark/world/opendrive/odrSpiral.ll (ZN4bark5world9opendrive9odrSpiralEddPdS2_S2_)

; 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: mustprogress uwtable
declare dso_local void @_ZN4bark5world9opendrive7fresnelEdPdS2_(double noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #1

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

34:                                               ; preds = %5
  %35 = load ptr, ptr %9, align 8, !tbaa !9
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = fmul double %36, -1.000000e+00
  store double %37, ptr %35, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %34, %5
  %39 = load double, ptr %6, align 8, !tbaa !5
  %40 = load double, ptr %6, align 8, !tbaa !5
  %41 = fmul double %39, %40
  %42 = load double, ptr %7, align 8, !tbaa !5
  %43 = fmul double %41, %42
  %44 = fmul double %43, 5.000000e-01
  %45 = load ptr, ptr %10, align 8, !tbaa !9
  store double %44, ptr %45, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

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

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

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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 uwtable
declare dso_local void @_ZN4bark5world9opendrive7fresnelEdPdS2_(double noundef, ptr 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 uwtable
define dso_local void @_ZN4bark5world9opendrive9odrSpiralEddPdS2_S2_(double noundef %0, double noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %6 = tail call double @llvm.fabs.f64(double %1)
  %sqrt = tail call double @llvm.sqrt.f64(double %6)
  %7 = fdiv double 1.000000e+00, %sqrt
  %8 = fmul double %7, 0x3FFC5BF891B4EF6A
  %9 = fdiv double %0, %8
  tail call void @_ZN4bark5world9opendrive7fresnelEdPdS2_(double noundef %9, ptr noundef %3, ptr noundef %2)
  %10 = load double, ptr %2, align 8, !tbaa !5
  %11 = fmul double %8, %10
  store double %11, ptr %2, align 8, !tbaa !5
  %12 = load double, ptr %3, align 8, !tbaa !5
  %13 = fmul double %8, %12
  %14 = fcmp olt double %1, 0.000000e+00
  %15 = fneg double %13
  %storemerge = select i1 %14, double %15, double %13
  store double %storemerge, ptr %3, align 8, !tbaa !5
  %16 = fmul double %0, %0
  %17 = fmul double %16, %1
  %18 = fmul double %17, 5.000000e-01
  store double %18, ptr %4, align 8, !tbaa !5
  ret void
}

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

attributes #0 = { mustprogress 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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++ TBAA"}


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