; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R3Mesh.ll (ZNK6R3Mesh16EdgeBetweenFacesEPK10R3MeshFaceS2_)

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

%class.R3MeshFace = type { ptr, [3 x ptr], [3 x ptr], %class.R3Plane, %class.R3Box, double, i32, i32, i32, i32, %class.RNFlags, double, i32, ptr }
%class.R3Plane = type { %class.R3Vector, double }
%class.R3Vector = type { [3 x double] }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Point = type { [3 x double] }
%class.RNFlags = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZNK6R3Mesh16EdgeBetweenFacesEPK10R3MeshFaceS2_(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = icmp eq ptr %9, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %56

13:                                               ; preds = %3
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %class.R3MeshFace, ptr %14, i32 0, i32 2
  %16 = getelementptr inbounds [3 x ptr], ptr %15, i64 0, i64 0
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %8, ptr noundef %17, ptr noundef %18)
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp eq ptr %19, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %13
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.R3MeshFace, ptr %23, i32 0, i32 2
  %25 = getelementptr inbounds [3 x ptr], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %26, ptr %4, align 8
  br label %56

27:                                               ; preds = %13
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.R3MeshFace, ptr %28, i32 0, i32 2
  %30 = getelementptr inbounds [3 x ptr], ptr %29, i64 0, i64 1
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %8, ptr noundef %31, ptr noundef %32)
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = icmp eq ptr %33, %34
  br i1 %35, label %36, label %41

36:                                               ; preds = %27
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.R3MeshFace, ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds [3 x ptr], ptr %38, i64 0, i64 1
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  store ptr %40, ptr %4, align 8
  br label %56

41:                                               ; preds = %27
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %class.R3MeshFace, ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds [3 x ptr], ptr %43, i64 0, i64 2
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = call noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %8, ptr noundef %45, ptr noundef %46)
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = icmp eq ptr %47, %48
  br i1 %49, label %50, label %55

50:                                               ; preds = %41
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %class.R3MeshFace, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds [3 x ptr], ptr %52, i64 0, i64 2
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  store ptr %54, ptr %4, align 8
  br label %56

55:                                               ; preds = %41
  store ptr null, ptr %4, align 8
  br label %56

56:                                               ; preds = %55, %50, %36, %22, %12
  %57 = load ptr, ptr %4, align 8
  ret ptr %57
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef) #1 align 2

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


; 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 nounwind uwtable
define dso_local noundef ptr @_ZNK6R3Mesh16EdgeBetweenFacesEPK10R3MeshFaceS2_(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef readnone %2) local_unnamed_addr #0 align 2 {
  %4 = icmp eq ptr %1, %2
  br i1 %4, label %21, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %1, i64 32
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %7, ptr noundef %1)
  %9 = icmp eq ptr %8, %2
  br i1 %9, label %.sink.split, label %10

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %1, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = tail call noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %12, ptr noundef nonnull %1)
  %14 = icmp eq ptr %13, %2
  br i1 %14, label %.sink.split, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %1, i64 48
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = tail call noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %17, ptr noundef nonnull %1)
  %19 = icmp eq ptr %18, %2
  br i1 %19, label %.sink.split, label %21

.sink.split:                                      ; preds = %15, %10, %5
  %.sink = phi ptr [ %6, %5 ], [ %11, %10 ], [ %16, %15 ]
  %20 = load ptr, ptr %.sink, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %.sink.split, %15, %3
  %.0 = phi ptr [ null, %3 ], [ null, %15 ], [ %20, %.sink.split ]
  ret ptr %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6R3Mesh14FaceAcrossEdgeEPK10R3MeshEdgePK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

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


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