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

; 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.R3Vector = type { [3 x double] }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@RN_TWO_PI = external constant double, align 8
@RN_PI = external constant double, align 8
@.str.12 = external hidden unnamed_addr constant [39 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) #0

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

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

declare noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0

declare void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z9RNIsEqualddd(double noundef, double noundef, double noundef) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R3Mesh10EdgeVectorEPK10R3MeshEdge(ptr dead_on_unwind noalias writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK6R3Mesh17EdgeInteriorAngleEPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1) #4 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %class.R3Vector, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca %class.R3Vector, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdgei(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %16, i32 noundef 0)
  store ptr %17, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdgei(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %18, i32 noundef 1)
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %25

22:                                               ; preds = %2
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %26, label %25

25:                                               ; preds = %22, %2
  store double 0.000000e+00, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %72

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #6
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %27)
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %29)
  call void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %9, ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull align 8 dereferenceable(24) %30)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %31)
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %33)
  %35 = call noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24) %32, ptr noundef nonnull align 8 dereferenceable(24) %34)
  store double %35, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %36 = load double, ptr %10, align 8, !tbaa !9
  %37 = load double, ptr %10, align 8, !tbaa !9
  %38 = fmul double %36, %37
  %39 = call noundef i32 @_Z9RNIsEqualddd(double noundef %38, double noundef 1.000000e+00, double noundef 0x3EB0C6F7A0B5ED8D)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %26
  br label %45

42:                                               ; preds = %26
  %43 = load double, ptr %10, align 8, !tbaa !9
  %44 = call double @acos(double noundef %43) #6
  br label %45

45:                                               ; preds = %42, %41
  %46 = phi double [ 0.000000e+00, %41 ], [ %44, %42 ]
  store double %46, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #6
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNK6R3Mesh10EdgeVectorEPK10R3MeshEdge(ptr dead_on_unwind writable sret(%class.R3Vector) align 8 %13, ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %47)
  %48 = call noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %49 = fcmp ogt double %48, 0.000000e+00
  %50 = zext i1 %49 to i32
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #6
  store i32 %50, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %51 = load i32, ptr %12, align 4, !tbaa !11
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %57

53:                                               ; preds = %45
  %54 = load double, ptr @RN_PI, align 8, !tbaa !9
  %55 = load double, ptr %11, align 8, !tbaa !9
  %56 = fsub double %54, %55
  br label %61

57:                                               ; preds = %45
  %58 = load double, ptr @RN_PI, align 8, !tbaa !9
  %59 = load double, ptr %11, align 8, !tbaa !9
  %60 = fadd double %58, %59
  br label %61

61:                                               ; preds = %57, %53
  %62 = phi double [ %56, %53 ], [ %60, %57 ]
  store double %62, ptr %14, align 8, !tbaa !9
  %63 = load double, ptr %14, align 8, !tbaa !9
  %64 = fcmp oge double %63, 0.000000e+00
  br i1 %64, label %65, label %69

65:                                               ; preds = %61
  %66 = load double, ptr %14, align 8, !tbaa !9
  %67 = load double, ptr @RN_TWO_PI, align 8, !tbaa !9
  %68 = fcmp ole double %66, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %65, %61
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.12, i32 noundef 519, ptr noundef @.str.2)
  br label %70

70:                                               ; preds = %69, %65
  %71 = load double, ptr %14, align 8, !tbaa !9
  store double %71, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #6
  br label %72

72:                                               ; preds = %70, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %73 = load double, ptr %3, align 8
  ret double %73
}

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

; Function Attrs: nounwind
declare double @acos(double noundef) #5

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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 #4 = { 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 #5 = { 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 #6 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

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

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@RN_TWO_PI = external local_unnamed_addr constant double, align 8
@RN_PI = external local_unnamed_addr constant double, align 8
@.str.12 = external hidden unnamed_addr constant [39 x i8], align 1

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #0

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

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

declare noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

declare void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z9RNIsEqualddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK6R3Mesh10EdgeVectorEPK10R3MeshEdge(ptr dead_on_unwind noalias writable sret(%class.R3Vector) align 8, ptr noundef nonnull align 8 dereferenceable(272), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK6R3Mesh17EdgeInteriorAngleEPK10R3MeshEdge(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1) local_unnamed_addr #4 align 2 {
  %3 = alloca %class.R3Vector, align 8
  %4 = alloca %class.R3Vector, align 8
  %5 = tail call noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdgei(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, i32 noundef 0)
  %6 = tail call noundef ptr @_ZNK6R3Mesh10FaceOnEdgeEPK10R3MeshEdgei(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, i32 noundef 1)
  %7 = icmp ne ptr %5, null
  %8 = icmp ne ptr %6, null
  %or.cond = and i1 %7, %8
  br i1 %or.cond, label %9, label %31

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %5)
  %11 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %6)
  call void @_ZrmRK8R3VectorS1_(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %3, ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(24) %11)
  %12 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %5)
  %13 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK6R3Mesh10FaceNormalEPK10R3MeshFace(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull %6)
  %14 = call noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 8 dereferenceable(24) %13)
  %15 = fmul double %14, %14
  %16 = call noundef i32 @_Z9RNIsEqualddd(double noundef %15, double noundef 1.000000e+00, double noundef 0x3EB0C6F7A0B5ED8D)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %17, label %19

17:                                               ; preds = %9
  %18 = call double @acos(double noundef %14) #6
  br label %19

19:                                               ; preds = %9, %17
  %20 = phi double [ %18, %17 ], [ 0.000000e+00, %9 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @_ZNK6R3Mesh10EdgeVectorEPK10R3MeshEdge(ptr dead_on_unwind nonnull writable sret(%class.R3Vector) align 8 %4, ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1)
  %21 = call noundef double @_ZNK8R3Vector3DotERKS_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 8 dereferenceable(24) %4)
  %22 = fcmp ogt double %21, 0.000000e+00
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  %23 = load double, ptr @RN_PI, align 8
  %24 = fneg double %20
  %.p = select i1 %22, double %24, double %20
  %25 = fadd double %23, %.p
  %26 = fcmp ult double %25, 0.000000e+00
  %27 = load double, ptr @RN_TWO_PI, align 8
  %28 = fcmp ugt double %25, %27
  %or.cond24 = select i1 %26, i1 true, i1 %28
  br i1 %or.cond24, label %29, label %30

29:                                               ; preds = %19
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.12, i32 noundef 519, ptr noundef nonnull @.str.2)
  br label %30

30:                                               ; preds = %19, %29
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  br label %31

31:                                               ; preds = %2, %30
  %.0 = phi double [ %25, %30 ], [ 0.000000e+00, %2 ]
  ret double %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @acos(double noundef) local_unnamed_addr #5

attributes #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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 #4 = { 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 #5 = { mustprogress nofree nounwind willreturn memory(write) "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 #6 = { 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)"}


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