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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z10dubins_RLRP25DubinsIntermediateResultsPd(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 double, align 8
  %10 = 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
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %11, i32 0, i32 8
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = fsub double 6.000000e+00, %13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %15, i32 0, i32 7
  %17 = load double, ptr %16, align 8, !tbaa !12
  %18 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %17, double %14)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %19, i32 0, i32 2
  %21 = load double, ptr %20, align 8, !tbaa !13
  %22 = fmul double 2.000000e+00, %21
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %23, i32 0, i32 3
  %25 = load double, ptr %24, align 8, !tbaa !14
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %26, i32 0, i32 4
  %28 = load double, ptr %27, align 8, !tbaa !15
  %29 = fsub double %25, %28
  %30 = call double @llvm.fmuladd.f64(double %22, double %29, double %18)
  %31 = fdiv double %30, 8.000000e+00
  store double %31, ptr %6, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %32, i32 0, i32 5
  %34 = load double, ptr %33, align 8, !tbaa !17
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %35, i32 0, i32 6
  %37 = load double, ptr %36, align 8, !tbaa !18
  %38 = fsub double %34, %37
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %39, i32 0, i32 2
  %41 = load double, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %42, i32 0, i32 3
  %44 = load double, ptr %43, align 8, !tbaa !14
  %45 = fsub double %41, %44
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %46, i32 0, i32 4
  %48 = load double, ptr %47, align 8, !tbaa !15
  %49 = fadd double %45, %48
  %50 = call double @atan2(double noundef %38, double noundef %49) #4
  store double %50, ptr %7, align 8, !tbaa !16
  %51 = load double, ptr %6, align 8, !tbaa !16
  %52 = call double @llvm.fabs.f64(double %51)
  %53 = fcmp ole double %52, 1.000000e+00
  br i1 %53, label %54, label %90

54:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %55 = load double, ptr %6, align 8, !tbaa !16
  %56 = call double @acos(double noundef %55) #4
  %57 = fsub double 0x401921FB54442D18, %56
  %58 = call noundef double @_Z6mod2pid(double noundef %57)
  store double %58, ptr %8, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %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 = load double, ptr %7, align 8, !tbaa !16
  %63 = fsub double %61, %62
  %64 = load double, ptr %8, align 8, !tbaa !16
  %65 = fdiv double %64, 2.000000e+00
  %66 = call noundef double @_Z6mod2pid(double noundef %65)
  %67 = fadd double %63, %66
  %68 = call noundef double @_Z6mod2pid(double noundef %67)
  store double %68, ptr %9, align 8, !tbaa !16
  %69 = load double, ptr %9, align 8, !tbaa !16
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds double, ptr %70, i64 0
  store double %69, ptr %71, align 8, !tbaa !16
  %72 = load double, ptr %8, align 8, !tbaa !16
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds double, ptr %73, i64 1
  store double %72, ptr %74, align 8, !tbaa !16
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %75, i32 0, i32 0
  %77 = load double, ptr %76, align 8, !tbaa !19
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.DubinsIntermediateResults, ptr %78, i32 0, i32 1
  %80 = load double, ptr %79, align 8, !tbaa !20
  %81 = fsub double %77, %80
  %82 = load double, ptr %9, align 8, !tbaa !16
  %83 = fsub double %81, %82
  %84 = load double, ptr %8, align 8, !tbaa !16
  %85 = call noundef double @_Z6mod2pid(double noundef %84)
  %86 = fadd double %83, %85
  %87 = call noundef double @_Z6mod2pid(double noundef %86)
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds double, ptr %88, i64 2
  store double %87, ptr %89, align 8, !tbaa !16
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %91

90:                                               ; preds = %2
  store i32 4, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %91

91:                                               ; preds = %90, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %92 = load i32, ptr %3, align 4
  ret i32 %92
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 5) i32 @_Z10dubins_RLRP25DubinsIntermediateResultsPd(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 = fsub double 6.000000e+00, %4
  %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 = fsub double %13, %15
  %17 = tail call double @llvm.fmuladd.f64(double %11, double %16, double %8)
  %18 = fmul double %17, 1.250000e-01
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %0, i64 48
  %22 = load double, ptr %21, align 8, !tbaa !15
  %23 = fsub double %20, %22
  %24 = fsub double %10, %13
  %25 = fadd double %24, %15
  %26 = tail call double @atan2(double noundef %23, double noundef %25) #3
  %27 = tail call double @llvm.fabs.f64(double %18)
  %28 = fcmp ugt double %27, 1.000000e+00
  br i1 %28, label %49, label %29

29:                                               ; preds = %2
  %30 = tail call double @acos(double noundef %18) #3
  %31 = fsub double 0x401921FB54442D18, %30
  %32 = tail call noundef double @_Z6mod2pid(double noundef %31)
  %33 = load double, ptr %0, align 8, !tbaa !16
  %34 = fsub double %33, %26
  %35 = fmul double %32, 5.000000e-01
  %36 = tail call noundef double @_Z6mod2pid(double noundef %35)
  %37 = fadd double %34, %36
  %38 = tail call noundef double @_Z6mod2pid(double noundef %37)
  store double %38, ptr %1, align 8, !tbaa !17
  %39 = getelementptr inbounds i8, ptr %1, i64 8
  store double %32, ptr %39, align 8, !tbaa !17
  %40 = load double, ptr %0, align 8, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %0, i64 8
  %42 = load double, ptr %41, align 8, !tbaa !18
  %43 = fsub double %40, %42
  %44 = fsub double %43, %38
  %45 = tail call noundef double @_Z6mod2pid(double noundef %32)
  %46 = fadd double %45, %44
  %47 = tail call noundef double @_Z6mod2pid(double noundef %46)
  %48 = getelementptr inbounds i8, ptr %1, i64 16
  store double %47, ptr %48, align 8, !tbaa !17
  br label %49

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

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

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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass