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

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load ptr, ptr %6, align 8, !tbaa !9
  %12 = getelementptr inbounds double, ptr %11, i64 2
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = call double @sin(double noundef %13) #3
  store double %14, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds double, ptr %15, i64 2
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = call double @cos(double noundef %17) #3
  store double %18, ptr %10, align 8, !tbaa !5
  %19 = load i32, ptr %8, align 4, !tbaa !11
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %46

21:                                               ; preds = %4
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = getelementptr inbounds double, ptr %22, i64 2
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = load double, ptr %5, align 8, !tbaa !5
  %26 = fadd double %24, %25
  %27 = call double @sin(double noundef %26) #3
  %28 = load double, ptr %9, align 8, !tbaa !5
  %29 = fsub double %27, %28
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = getelementptr inbounds double, ptr %30, i64 0
  store double %29, ptr %31, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !9
  %33 = getelementptr inbounds double, ptr %32, i64 2
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = load double, ptr %5, align 8, !tbaa !5
  %36 = fadd double %34, %35
  %37 = call double @cos(double noundef %36) #3
  %38 = fneg double %37
  %39 = load double, ptr %10, align 8, !tbaa !5
  %40 = fadd double %38, %39
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = getelementptr inbounds double, ptr %41, i64 1
  store double %40, ptr %42, align 8, !tbaa !5
  %43 = load double, ptr %5, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  %45 = getelementptr inbounds double, ptr %44, i64 2
  store double %43, ptr %45, align 8, !tbaa !5
  br label %93

46:                                               ; preds = %4
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = icmp eq i32 %47, 2
  br i1 %48, label %49, label %75

49:                                               ; preds = %46
  %50 = load ptr, ptr %6, align 8, !tbaa !9
  %51 = getelementptr inbounds double, ptr %50, i64 2
  %52 = load double, ptr %51, align 8, !tbaa !5
  %53 = load double, ptr %5, align 8, !tbaa !5
  %54 = fsub double %52, %53
  %55 = call double @sin(double noundef %54) #3
  %56 = fneg double %55
  %57 = load double, ptr %9, align 8, !tbaa !5
  %58 = fadd double %56, %57
  %59 = load ptr, ptr %7, align 8, !tbaa !9
  %60 = getelementptr inbounds double, ptr %59, i64 0
  store double %58, ptr %60, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i64 2
  %63 = load double, ptr %62, align 8, !tbaa !5
  %64 = load double, ptr %5, align 8, !tbaa !5
  %65 = fsub double %63, %64
  %66 = call double @cos(double noundef %65) #3
  %67 = load double, ptr %10, align 8, !tbaa !5
  %68 = fsub double %66, %67
  %69 = load ptr, ptr %7, align 8, !tbaa !9
  %70 = getelementptr inbounds double, ptr %69, i64 1
  store double %68, ptr %70, align 8, !tbaa !5
  %71 = load double, ptr %5, align 8, !tbaa !5
  %72 = fneg double %71
  %73 = load ptr, ptr %7, align 8, !tbaa !9
  %74 = getelementptr inbounds double, ptr %73, i64 2
  store double %72, ptr %74, align 8, !tbaa !5
  br label %92

75:                                               ; preds = %46
  %76 = load i32, ptr %8, align 4, !tbaa !11
  %77 = icmp eq i32 %76, 1
  br i1 %77, label %78, label %91

78:                                               ; preds = %75
  %79 = load double, ptr %10, align 8, !tbaa !5
  %80 = load double, ptr %5, align 8, !tbaa !5
  %81 = fmul double %79, %80
  %82 = load ptr, ptr %7, align 8, !tbaa !9
  %83 = getelementptr inbounds double, ptr %82, i64 0
  store double %81, ptr %83, align 8, !tbaa !5
  %84 = load double, ptr %9, align 8, !tbaa !5
  %85 = load double, ptr %5, align 8, !tbaa !5
  %86 = fmul double %84, %85
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  %88 = getelementptr inbounds double, ptr %87, i64 1
  store double %86, ptr %88, align 8, !tbaa !5
  %89 = load ptr, ptr %7, align 8, !tbaa !9
  %90 = getelementptr inbounds double, ptr %89, i64 2
  store double 0.000000e+00, ptr %90, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %78, %75
  br label %92

92:                                               ; preds = %91, %49
  br label %93

93:                                               ; preds = %92, %21
  %94 = load ptr, ptr %6, align 8, !tbaa !9
  %95 = getelementptr inbounds double, ptr %94, i64 0
  %96 = load double, ptr %95, align 8, !tbaa !5
  %97 = load ptr, ptr %7, align 8, !tbaa !9
  %98 = getelementptr inbounds double, ptr %97, i64 0
  %99 = load double, ptr %98, align 8, !tbaa !5
  %100 = fadd double %99, %96
  store double %100, ptr %98, align 8, !tbaa !5
  %101 = load ptr, ptr %6, align 8, !tbaa !9
  %102 = getelementptr inbounds double, ptr %101, i64 1
  %103 = load double, ptr %102, align 8, !tbaa !5
  %104 = load ptr, ptr %7, align 8, !tbaa !9
  %105 = getelementptr inbounds double, ptr %104, i64 1
  %106 = load double, ptr %105, align 8, !tbaa !5
  %107 = fadd double %106, %103
  store double %107, ptr %105, align 8, !tbaa !5
  %108 = load ptr, ptr %6, align 8, !tbaa !9
  %109 = getelementptr inbounds double, ptr %108, i64 2
  %110 = load double, ptr %109, align 8, !tbaa !5
  %111 = load ptr, ptr %7, align 8, !tbaa !9
  %112 = getelementptr inbounds double, ptr %111, i64 2
  %113 = load double, ptr %112, align 8, !tbaa !5
  %114 = fadd double %113, %110
  store double %114, ptr %112, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !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}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS11SegmentType", !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 nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @_Z14dubins_segmentdPdS_11SegmentType(double noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = tail call double @sin(double noundef %6) #2
  %8 = load double, ptr %5, align 8, !tbaa !5
  %9 = tail call double @cos(double noundef %8) #2
  switch i32 %3, label %._crit_edge [
    i32 0, label %10
    i32 2, label %21
    i32 1, label %33
  ]

._crit_edge:                                      ; preds = %4
  %.phi.trans.insert = getelementptr inbounds i8, ptr %2, i64 8
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.phi.trans.insert37 = getelementptr inbounds i8, ptr %2, i64 16
  %.pre38 = load double, ptr %.phi.trans.insert37, align 8, !tbaa !5
  br label %38

10:                                               ; preds = %4
  %11 = load double, ptr %5, align 8, !tbaa !5
  %12 = fadd double %11, %0
  %13 = tail call double @sin(double noundef %12) #2
  %14 = fsub double %13, %7
  store double %14, ptr %2, align 8, !tbaa !5
  %15 = load double, ptr %5, align 8, !tbaa !5
  %16 = fadd double %15, %0
  %17 = tail call double @cos(double noundef %16) #2
  %18 = fsub double %9, %17
  %19 = getelementptr inbounds i8, ptr %2, i64 8
  store double %18, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %2, i64 16
  store double %0, ptr %20, align 8, !tbaa !5
  br label %38

21:                                               ; preds = %4
  %22 = load double, ptr %5, align 8, !tbaa !5
  %23 = fsub double %22, %0
  %24 = tail call double @sin(double noundef %23) #2
  %25 = fsub double %7, %24
  store double %25, ptr %2, align 8, !tbaa !5
  %26 = load double, ptr %5, align 8, !tbaa !5
  %27 = fsub double %26, %0
  %28 = tail call double @cos(double noundef %27) #2
  %29 = fsub double %28, %9
  %30 = getelementptr inbounds i8, ptr %2, i64 8
  store double %29, ptr %30, align 8, !tbaa !5
  %31 = fneg double %0
  %32 = getelementptr inbounds i8, ptr %2, i64 16
  store double %31, ptr %32, align 8, !tbaa !5
  br label %38

33:                                               ; preds = %4
  %34 = fmul double %9, %0
  store double %34, ptr %2, align 8, !tbaa !5
  %35 = fmul double %7, %0
  %36 = getelementptr inbounds i8, ptr %2, i64 8
  store double %35, ptr %36, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %2, i64 16
  store double 0.000000e+00, ptr %37, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %._crit_edge, %21, %33, %10
  %39 = phi double [ %.pre38, %._crit_edge ], [ %31, %21 ], [ 0.000000e+00, %33 ], [ %0, %10 ]
  %40 = phi double [ %.pre, %._crit_edge ], [ %29, %21 ], [ %35, %33 ], [ %18, %10 ]
  %41 = load double, ptr %1, align 8, !tbaa !5
  %42 = load double, ptr %2, align 8, !tbaa !5
  %43 = fadd double %41, %42
  store double %43, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %1, i64 8
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %2, i64 8
  %47 = fadd double %45, %40
  store double %47, ptr %46, align 8, !tbaa !5
  %48 = load double, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %2, i64 16
  %50 = fadd double %48, %39
  store double %50, ptr %49, align 8, !tbaa !5
  ret void
}

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

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

attributes #0 = { 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 #1 = { 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 #2 = { 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"}


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