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

; 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.R3Line = type { %class.R3Point, %class.R3Vector }
%class.R3Point = type { [3 x double] }
%class.R3Vector = type { [3 x double] }
%class.R3Triangle = type <{ %class.R3Surface, [3 x ptr], %class.R3Plane, %class.R3Box, %class.RNFlags, i32, [4 x i8] }>
%class.R3Surface = type { %class.R3Shape }
%class.R3Shape = type { ptr }
%class.R3Plane = type { %class.R3Vector, double }
%class.R3Box = type { %class.R3Solid, %class.R3Point, %class.R3Point }
%class.R3Solid = type { %class.R3Shape }
%class.RNFlags = type { i64 }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK10R3Triangle8IsLinearEv(ptr noundef nonnull align 8 dereferenceable(132) %0) unnamed_addr #2 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %class.R3Line, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %4) #4
  %7 = getelementptr inbounds %class.R3Triangle, ptr %6, i32 0, i32 1
  %8 = getelementptr inbounds [3 x ptr], ptr %7, i64 0, i64 0
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %9)
  %11 = getelementptr inbounds %class.R3Triangle, ptr %6, i32 0, i32 1
  %12 = getelementptr inbounds [3 x ptr], ptr %11, i64 0, i64 1
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %13)
  call void @_ZN6R3LineC1ERK7R3PointS2_(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(24) %14)
  %15 = getelementptr inbounds %class.R3Triangle, ptr %6, i32 0, i32 1
  %16 = getelementptr inbounds [3 x ptr], ptr %15, i64 0, i64 2
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %17)
  %19 = call noundef i32 @_Z10R3ContainsRK6R3LineRK7R3Point(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(24) %18)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %23

22:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %23

23:                                               ; preds = %22, %21
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #4
  %24 = load i32, ptr %2, align 4
  ret i32 %24
}

declare void @_ZN6R3LineC1ERK7R3PointS2_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3

declare noundef i32 @_Z10R3ContainsRK6R3LineRK7R3Point(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(24)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { "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 }

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

%class.R3Line = type { %class.R3Point, %class.R3Vector }
%class.R3Point = type { [3 x double] }
%class.R3Vector = type { [3 x double] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK10R3Triangle8IsLinearEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(132) %0) unnamed_addr #2 align 2 {
  %2 = alloca %class.R3Line, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %4)
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %7)
  call void @_ZN6R3LineC1ERK7R3PointS2_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %8)
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK16R3TriangleVertex8PositionEv(ptr noundef nonnull align 8 dereferenceable(100) %10)
  %12 = call noundef i32 @_Z10R3ContainsRK6R3LineRK7R3Point(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 8 dereferenceable(24) %11)
  %.not = icmp ne i32 %12, 0
  %. = zext i1 %.not to i32
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #4
  ret i32 %.
}

declare void @_ZN6R3LineC1ERK7R3PointS2_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3

declare noundef i32 @_Z10R3ContainsRK6R3LineRK7R3Point(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { "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 }

!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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass