; LLVM IR from junhyeokahn/PyPnC :: pnc/planner/dubins/dubins.ll (Z10dubins_LSRP25DubinsIntermediateResultsPd)

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

%struct.DubinsIntermediateResults = type { double, double, double, double, double, double, double, double, double }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z6mod2pid(double noundef) #1

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z10dubins_LSRP25DubinsIntermediateResultsPd(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %10, i32 0, i32 8
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = fadd double -2.000000e+00, %12
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %14, i32 0, i32 7
  %16 = load double, ptr %15, align 8, !tbaa !12
  %17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double %13)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %18, i32 0, i32 2
  %20 = load double, ptr %19, align 8, !tbaa !13
  %21 = fmul double 2.000000e+00, %20
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %22, i32 0, i32 3
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %25, i32 0, i32 4
  %27 = load double, ptr %26, align 8, !tbaa !15
  %28 = fadd double %24, %27
  %29 = call double @llvm.fmuladd.f64(double %21, double %28, double %17)
  store double %29, ptr %6, align 8, !tbaa !16
  %30 = load double, ptr %6, align 8, !tbaa !16
  %31 = fcmp oge double %30, 0.000000e+00
  br i1 %31, label %32, label %78

32:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %33 = load double, ptr %6, align 8, !tbaa !16
  %34 = call double @sqrt(double noundef %33) #4
  store double %34, ptr %7, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %35, i32 0, i32 5
  %37 = load double, ptr %36, align 8, !tbaa !17
  %38 = fneg double %37
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %39, i32 0, i32 6
  %41 = load double, ptr %40, align 8, !tbaa !18
  %42 = fsub double %38, %41
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %43, i32 0, i32 2
  %45 = load double, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %46, i32 0, i32 3
  %48 = load double, ptr %47, align 8, !tbaa !14
  %49 = fadd double %45, %48
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %50, i32 0, i32 4
  %52 = load double, ptr %51, align 8, !tbaa !15
  %53 = fadd double %49, %52
  %54 = call double @atan2(double noundef %42, double noundef %53) #4
  %55 = load double, ptr %7, align 8, !tbaa !16
  %56 = call double @atan2(double noundef -2.000000e+00, double noundef %55) #4
  %57 = fsub double %54, %56
  store double %57, ptr %8, align 8, !tbaa !16
  %58 = load double, ptr %8, align 8, !tbaa !16
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %59, i32 0, i32 0
  %61 = load double, ptr %60, align 8, !tbaa !19
  %62 = fsub double %58, %61
  %63 = call noundef double @_Z6mod2pid(double noundef %62)
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds double, ptr %64, i64 0
  store double %63, ptr %65, align 8, !tbaa !16
  %66 = load double, ptr %7, align 8, !tbaa !16
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds double, ptr %67, i64 1
  store double %66, ptr %68, align 8, !tbaa !16
  %69 = load double, ptr %8, align 8, !tbaa !16
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %70, i32 0, i32 1
  %72 = load double, ptr %71, align 8, !tbaa !20
  %73 = call noundef double @_Z6mod2pid(double noundef %72)
  %74 = fsub double %69, %73
  %75 = call noundef double @_Z6mod2pid(double noundef %74)
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds double, ptr %76, i64 2
  store double %75, ptr %77, align 8, !tbaa !16
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %79

78:                                               ; preds = %2
  store i32 4, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %79

79:                                               ; preds = %78, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !11, i64 64}
!10 = !{!"_ZTS25DubinsIntermediateResults", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64}
!11 = !{!"double", !7, i64 0}
!12 = !{!10, !11, i64 56}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !11, i64 32}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 40}
!18 = !{!10, !11, i64 48}
!19 = !{!10, !11, i64 0}
!20 = !{!10, !11, i64 8}


; 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 nounwind uwtable
declare dso_local noundef double @_Z6mod2pid(double noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 5) i32 @_Z10dubins_LSRP25DubinsIntermediateResultsPd(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 64
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fadd double %4, -2.000000e+00
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load double, ptr %6, align 8, !tbaa !10
  %8 = tail call double @llvm.fmuladd.f64(double %7, double 2.000000e+00, double %5)
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fmul double %10, 2.000000e+00
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load double, ptr %12, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = fadd double %13, %15
  %17 = tail call double @llvm.fmuladd.f64(double %11, double %16, double %8)
  %18 = fcmp ult double %17, 0.000000e+00
  br i1 %18, label %45, label %19

19:                                               ; preds = %2
  %20 = tail call double @sqrt(double noundef %17) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 40
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = fneg double %22
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  %25 = load double, ptr %24, align 8, !tbaa !15
  %26 = fsub double %23, %25
  %27 = load double, ptr %9, align 8, !tbaa !11
  %28 = load double, ptr %12, align 8, !tbaa !12
  %29 = fadd double %27, %28
  %30 = load double, ptr %14, align 8, !tbaa !13
  %31 = fadd double %29, %30
  %32 = tail call double @atan2(double noundef %26, double noundef %31) #3
  %33 = tail call double @atan2(double noundef -2.000000e+00, double noundef %20) #3
  %34 = fsub double %32, %33
  %35 = load double, ptr %0, align 8, !tbaa !16
  %36 = fsub double %34, %35
  %37 = tail call noundef double @_Z6mod2pid(double noundef %36)
  store double %37, ptr %1, align 8, !tbaa !17
  %38 = getelementptr inbounds i8, ptr %1, i64 8
  store double %20, ptr %38, align 8, !tbaa !17
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  %40 = load double, ptr %39, align 8, !tbaa !18
  %41 = tail call noundef double @_Z6mod2pid(double noundef %40)
  %42 = fsub double %34, %41
  %43 = tail call noundef double @_Z6mod2pid(double noundef %42)
  %44 = getelementptr inbounds i8, ptr %1, i64 16
  store double %43, ptr %44, align 8, !tbaa !17
  br label %45

45:                                               ; preds = %2, %19
  %.0 = phi i32 [ 0, %19 ], [ 4, %2 ]
  ret i32 %.0
}

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

!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, !7, i64 64}
!6 = !{!"_ZTS25DubinsIntermediateResults", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 56}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !7, i64 48}
!16 = !{!6, !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !7, i64 8}


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