; LLVM IR from niessner/Matterport :: code/gaps/apps/mpview/mp.ll (ZN8MPPortalD2Ev)

; 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.MPPortal = type { ptr, i32, [2 x ptr], [2 x i32], %class.R3Span, ptr }
%class.R3Span = type { %class.R3Ray, %class.R3Point, double }
%class.R3Ray = type { %class.R3Line }
%class.R3Line = type { %class.R3Point, %class.R3Vector }
%class.R3Vector = type { [3 x double] }
%class.R3Point = type { [3 x double] }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8MPRegion12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8MPPortalD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 2
  %5 = getelementptr inbounds [2 x ptr], ptr %4, i64 0, i64 0
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %13

8:                                                ; preds = %1
  %9 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 2
  %10 = getelementptr inbounds [2 x ptr], ptr %9, i64 0, i64 0
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  invoke void @_ZN8MPRegion12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(192) %11, ptr noundef %3)
          to label %12 unwind label %39

12:                                               ; preds = %8
  br label %13

13:                                               ; preds = %12, %1
  %14 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 2
  %15 = getelementptr inbounds [2 x ptr], ptr %14, i64 0, i64 1
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %23

18:                                               ; preds = %13
  %19 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 2
  %20 = getelementptr inbounds [2 x ptr], ptr %19, i64 0, i64 1
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  invoke void @_ZN8MPRegion12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(192) %21, ptr noundef %3)
          to label %22 unwind label %39

22:                                               ; preds = %18
  br label %23

23:                                               ; preds = %22, %13
  %24 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %23
  %28 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  invoke void @_ZN7MPHouse12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(376) %29, ptr noundef %3)
          to label %30 unwind label %39

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30, %23
  %32 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 5
  %33 = load ptr, ptr %32, align 8, !tbaa !18
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %38

35:                                               ; preds = %31
  %36 = getelementptr inbounds %struct.MPPortal, ptr %3, i32 0, i32 5
  %37 = load ptr, ptr %36, align 8, !tbaa !18
  call void @free(ptr noundef %37) #4
  br label %38

38:                                               ; preds = %35, %31
  ret void

39:                                               ; preds = %27, %18, %8
  %40 = landingpad { ptr, i32 }
          catch ptr null
  %41 = extractvalue { ptr, i32 } %40, 0
  call void @__clang_call_terminate(ptr %41) #5
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7MPHouse12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(376), ptr noundef) #2 align 2

attributes #0 = { noinline noreturn nounwind uwtable "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 = { 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 #2 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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, !6, i64 0}
!10 = !{!"_ZTS8MPPortal", !6, i64 0, !11, i64 8, !7, i64 16, !7, i64 32, !12, i64 40, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS6R3Span", !13, i64 0, !15, i64 48, !17, i64 72}
!13 = !{!"_ZTS5R3Ray", !14, i64 0}
!14 = !{!"_ZTS6R3Line", !15, i64 0, !16, i64 24}
!15 = !{!"_ZTS7R3Point", !7, i64 0}
!16 = !{!"_ZTS8R3Vector", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!10, !6, i64 120}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8MPRegion12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8MPPortalD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %5, label %4

4:                                                ; preds = %1
  invoke void @_ZN8MPRegion12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(192) %3, ptr noundef nonnull %0)
          to label %5 unwind label %17

5:                                                ; preds = %4, %1
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not4 = icmp eq ptr %7, null
  br i1 %.not4, label %9, label %8

8:                                                ; preds = %5
  invoke void @_ZN8MPRegion12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(192) %7, ptr noundef nonnull %0)
          to label %9 unwind label %17

9:                                                ; preds = %8, %5
  %10 = load ptr, ptr %0, align 8, !tbaa !9
  %.not5 = icmp eq ptr %10, null
  br i1 %.not5, label %12, label %11

11:                                               ; preds = %9
  invoke void @_ZN7MPHouse12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(376) %10, ptr noundef nonnull %0)
          to label %12 unwind label %17

12:                                               ; preds = %11, %9
  %13 = getelementptr inbounds i8, ptr %0, i64 120
  %14 = load ptr, ptr %13, align 8, !tbaa !18
  %.not6 = icmp eq ptr %14, null
  br i1 %.not6, label %16, label %15

15:                                               ; preds = %12
  tail call void @free(ptr noundef nonnull %14) #4
  br label %16

16:                                               ; preds = %15, %12
  ret void

17:                                               ; preds = %11, %8, %4
  %18 = landingpad { ptr, i32 }
          catch ptr null
  %19 = extractvalue { ptr, i32 } %18, 0
  tail call void @__clang_call_terminate(ptr %19) #5
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7MPHouse12RemovePortalEP8MPPortal(ptr noundef nonnull align 8 dereferenceable(376), ptr noundef) local_unnamed_addr #2 align 2

attributes #0 = { noinline noreturn nounwind uwtable "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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, !6, i64 0}
!10 = !{!"_ZTS8MPPortal", !6, i64 0, !11, i64 8, !7, i64 16, !7, i64 32, !12, i64 40, !6, i64 120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS6R3Span", !13, i64 0, !15, i64 48, !17, i64 72}
!13 = !{!"_ZTS5R3Ray", !14, i64 0}
!14 = !{!"_ZTS6R3Line", !15, i64 0, !16, i64 24}
!15 = !{!"_ZTS7R3Point", !7, i64 0}
!16 = !{!"_ZTS8R3Vector", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!10, !6, i64 120}


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