; LLVM IR from romerojosh/zefr :: src/tets.ll (ZN4Tets18project_face_pointEiPKdPd)

; 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 nounwind uwtable
define dso_local void @_ZN4Tets18project_face_pointEiPKdPd(ptr noundef nonnull align 8 dereferenceable(14304) %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8
  %10 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %10, label %72 [
    i32 0, label %11
    i32 1, label %24
    i32 2, label %37
    i32 3, label %50
  ]

11:                                               ; preds = %4
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds double, ptr %12, i64 0
  %14 = load double, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = getelementptr inbounds double, ptr %15, i64 0
  store double %14, ptr %16, align 8, !tbaa !11
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds double, ptr %17, i64 1
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %20, i64 1
  store double %19, ptr %21, align 8, !tbaa !11
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %22, i64 2
  store double -1.000000e+00, ptr %23, align 8, !tbaa !11
  br label %72

24:                                               ; preds = %4
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 0
  %27 = load double, ptr %26, align 8, !tbaa !11
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds double, ptr %28, i64 0
  store double %27, ptr %29, align 8, !tbaa !11
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 1
  store double -1.000000e+00, ptr %31, align 8, !tbaa !11
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 1
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 2
  store double %34, ptr %36, align 8, !tbaa !11
  br label %72

37:                                               ; preds = %4
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 0
  store double -1.000000e+00, ptr %39, align 8, !tbaa !11
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds double, ptr %40, i64 1
  %42 = load double, ptr %41, align 8, !tbaa !11
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %43, i64 1
  store double %42, ptr %44, align 8, !tbaa !11
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds double, ptr %45, i64 0
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %48, i64 2
  store double %47, ptr %49, align 8, !tbaa !11
  br label %72

50:                                               ; preds = %4
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds double, ptr %51, i64 0
  %53 = load double, ptr %52, align 8, !tbaa !11
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %54, i64 0
  store double %53, ptr %55, align 8, !tbaa !11
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds double, ptr %56, i64 1
  %58 = load double, ptr %57, align 8, !tbaa !11
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 1
  store double %58, ptr %60, align 8, !tbaa !11
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %61, i64 0
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds double, ptr %64, i64 1
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = fadd double %63, %66
  %68 = fadd double %67, 1.000000e+00
  %69 = fneg double %68
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds double, ptr %70, i64 2
  store double %69, ptr %71, align 8, !tbaa !11
  br label %72

72:                                               ; preds = %50, %37, %24, %11, %4
  ret void
}

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

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN4Tets18project_face_pointEiPKdPd(ptr nocapture noundef nonnull readnone align 8 dereferenceable(14304) %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) unnamed_addr #0 align 2 {
  switch i32 %1, label %30 [
    i32 0, label %5
    i32 1, label %10
    i32 2, label %15
    i32 3, label %20
  ]

5:                                                ; preds = %4
  %6 = load double, ptr %2, align 8, !tbaa !5
  store double %6, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  store double %8, ptr %9, align 8, !tbaa !5
  br label %.sink.split

10:                                               ; preds = %4
  %11 = load double, ptr %2, align 8, !tbaa !5
  store double %11, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %3, i64 8
  store double -1.000000e+00, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %2, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !5
  br label %.sink.split

15:                                               ; preds = %4
  store double -1.000000e+00, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %2, i64 8
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  store double %17, ptr %18, align 8, !tbaa !5
  %19 = load double, ptr %2, align 8, !tbaa !5
  br label %.sink.split

20:                                               ; preds = %4
  %21 = load double, ptr %2, align 8, !tbaa !5
  store double %21, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %2, i64 8
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %3, i64 8
  store double %23, ptr %24, align 8, !tbaa !5
  %25 = load double, ptr %2, align 8, !tbaa !5
  %26 = fadd double %25, %23
  %27 = fadd double %26, 1.000000e+00
  %28 = fneg double %27
  br label %.sink.split

.sink.split:                                      ; preds = %5, %10, %15, %20
  %.sink = phi double [ %28, %20 ], [ %19, %15 ], [ %14, %10 ], [ -1.000000e+00, %5 ]
  %29 = getelementptr inbounds i8, ptr %3, i64 16
  store double %.sink, ptr %29, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %.sink.split, %4
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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" }

!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,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass