; LLVM IR from pmla/polyhedral-template-matching :: ptm_convex_hull_incremental.ll (ZN3ptm9add_facetEPA3_KdiiiPaPdS4_)

; 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
define dso_local void @_ZN3ptm9add_facetEPA3_KdiiiPaPdS4_(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = load i32, ptr %10, align 4, !tbaa !9
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZN3ptmL22calculate_plane_normalEPA3_KdiiiPd(ptr noundef %15, i32 noundef %16, i32 noundef %17, i32 noundef %18, ptr noundef %19)
  %20 = load ptr, ptr %14, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [3 x double], ptr %21, i64 %23
  %25 = getelementptr inbounds [3 x double], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %13, align 8, !tbaa !5
  %27 = call noundef zeroext i1 @_ZN3ptmL7visibleEPKdS1_S1_(ptr noundef %20, ptr noundef %25, ptr noundef %26)
  br i1 %27, label %28, label %59

28:                                               ; preds = %7
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 0
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = fneg double %31
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %33, i64 0
  store double %32, ptr %34, align 8, !tbaa !11
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 1
  %37 = load double, ptr %36, align 8, !tbaa !11
  %38 = fneg double %37
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 1
  store double %38, ptr %40, align 8, !tbaa !11
  %41 = load ptr, ptr %13, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %41, i64 2
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = fneg double %43
  %45 = load ptr, ptr %13, align 8, !tbaa !5
  %46 = getelementptr inbounds double, ptr %45, i64 2
  store double %44, ptr %46, align 8, !tbaa !11
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 0
  store i8 %48, ptr %50, align 1, !tbaa !13
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = trunc i32 %51 to i8
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i64 1
  store i8 %52, ptr %54, align 1, !tbaa !13
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = trunc i32 %55 to i8
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 2
  store i8 %56, ptr %58, align 1, !tbaa !13
  br label %72

59:                                               ; preds = %7
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = trunc i32 %60 to i8
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 0
  store i8 %61, ptr %63, align 1, !tbaa !13
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = trunc i32 %64 to i8
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 1
  store i8 %65, ptr %67, align 1, !tbaa !13
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = trunc i32 %68 to i8
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %70, i64 2
  store i8 %69, ptr %71, align 1, !tbaa !13
  br label %72

72:                                               ; preds = %59, %28
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN3ptmL22calculate_plane_normalEPA3_KdiiiPd(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN3ptmL7visibleEPKdS1_S1_(ptr noundef, ptr noundef, ptr noundef) #0

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

!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}
!13 = !{!7, !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
define dso_local void @_ZN3ptm9add_facetEPA3_KdiiiPaPdS4_(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #0 {
  tail call void @_ZN3ptmL22calculate_plane_normalEPA3_KdiiiPd(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %5)
  %8 = sext i32 %1 to i64
  %9 = getelementptr inbounds [3 x double], ptr %0, i64 %8
  %10 = tail call noundef zeroext i1 @_ZN3ptmL7visibleEPKdS1_S1_(ptr noundef %6, ptr noundef %9, ptr noundef %5)
  br i1 %10, label %11, label %17

11:                                               ; preds = %7
  %12 = load <2 x double>, ptr %5, align 8, !tbaa !5
  %13 = fneg <2 x double> %12
  store <2 x double> %13, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %5, i64 16
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fneg double %15
  store double %16, ptr %14, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %7, %11
  %.sink27.in = phi i32 [ %2, %11 ], [ %1, %7 ]
  %.sink26.in = phi i32 [ %1, %11 ], [ %2, %7 ]
  %.sink = trunc i32 %3 to i8
  %.sink26 = trunc i32 %.sink26.in to i8
  %.sink27 = trunc i32 %.sink27.in to i8
  store i8 %.sink27, ptr %4, align 1
  %18 = getelementptr inbounds i8, ptr %4, i64 1
  store i8 %.sink26, ptr %18, align 1
  %19 = getelementptr inbounds i8, ptr %4, i64 2
  store i8 %.sink, ptr %19, align 1
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN3ptmL22calculate_plane_normalEPA3_KdiiiPd(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN3ptmL7visibleEPKdS1_S1_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

!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,GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass