; LLVM IR from xhub/reshop :: gui/external/imgui/imgui_draw.ll (ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_)

; 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.ImTriangulator = type { i32, ptr, %struct.ImTriangulatorNodeSpan, %struct.ImTriangulatorNodeSpan }
%struct.ImTriangulatorNodeSpan = type <{ ptr, i32, [4 x i8] }>
%struct.ImTriangulatorNode = type { i32, i32, %struct.ImVec2, ptr, ptr }
%struct.ImVec2 = type { float, float }

; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6) #1 align 2 {
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %21 = getelementptr inbounds %struct.ImTriangulator, ptr %20, i32 0, i32 3
  %22 = getelementptr inbounds %struct.ImTriangulatorNodeSpan, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct.ImTriangulator, ptr %20, i32 0, i32 3
  %25 = getelementptr inbounds %struct.ImTriangulatorNodeSpan, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 8, !tbaa !14
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds ptr, ptr %23, i64 %27
  store ptr %28, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %29 = getelementptr inbounds %struct.ImTriangulator, ptr %20, i32 0, i32 3
  %30 = getelementptr inbounds %struct.ImTriangulatorNodeSpan, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  store ptr %31, ptr %17, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %70, %7
  %33 = load ptr, ptr %17, align 8, !tbaa !5
  %34 = load ptr, ptr %16, align 8, !tbaa !5
  %35 = icmp ult ptr %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 2, ptr %18, align 4
  br label %73

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %38 = load ptr, ptr %17, align 8, !tbaa !5
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  store ptr %39, ptr %19, align 8, !tbaa !5
  %40 = load ptr, ptr %19, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !15
  %43 = load i32, ptr %10, align 4, !tbaa !9
  %44 = icmp ne i32 %42, %43
  br i1 %44, label %45, label %66

45:                                               ; preds = %37
  %46 = load ptr, ptr %19, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !15
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = icmp ne i32 %48, %49
  br i1 %50, label %51, label %66

51:                                               ; preds = %45
  %52 = load ptr, ptr %19, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !15
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = icmp ne i32 %54, %55
  br i1 %56, label %57, label %66

57:                                               ; preds = %51
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = load ptr, ptr %19, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %61, i32 0, i32 2
  %63 = call noundef zeroext i1 @_Z23ImTriangleContainsPointRK6ImVec2S1_S1_S1_(ptr noundef nonnull align 4 dereferenceable(8) %58, ptr noundef nonnull align 4 dereferenceable(8) %59, ptr noundef nonnull align 4 dereferenceable(8) %60, ptr noundef nonnull align 4 dereferenceable(8) %62)
  br i1 %63, label %64, label %65

64:                                               ; preds = %57
  store i1 false, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %67

65:                                               ; preds = %57
  br label %66

66:                                               ; preds = %65, %51, %45, %37
  store i32 0, ptr %18, align 4
  br label %67

67:                                               ; preds = %66, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  %68 = load i32, ptr %18, align 4
  switch i32 %68, label %73 [
    i32 0, label %69
  ]

69:                                               ; preds = %67
  br label %70

70:                                               ; preds = %69
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds ptr, ptr %71, i32 1
  store ptr %72, ptr %17, align 8, !tbaa !5
  br label %32, !llvm.loop !20

73:                                               ; preds = %67, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  %74 = load i32, ptr %18, align 4
  switch i32 %74, label %76 [
    i32 2, label %75
  ]

75:                                               ; preds = %73
  store i1 true, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %76

76:                                               ; preds = %75, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %77 = load i1, ptr %8, align 1
  ret i1 %77
}

declare noundef zeroext i1 @_Z23ImTriangleContainsPointRK6ImVec2S1_S1_S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTS14ImTriangulator", !10, i64 0, !6, i64 8, !13, i64 16, !13, i64 32}
!13 = !{!"_ZTS22ImTriangulatorNodeSpan", !6, i64 0, !10, i64 8}
!14 = !{!12, !10, i64 40}
!15 = !{!16, !10, i64 4}
!16 = !{!"_ZTS18ImTriangulatorNode", !17, i64 0, !10, i64 4, !18, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"_ZTS22ImTriangulatorNodeType", !7, i64 0}
!18 = !{!"_ZTS6ImVec2", !19, i64 0, !19, i64 4}
!19 = !{!"float", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; 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 noundef zeroext i1 @_ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6) local_unnamed_addr #0 align 2 {
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds ptr, ptr %9, i64 %12
  %.not2428 = icmp slt i32 %11, 1
  br i1 %.not2428, label %.critedge27, label %.lr.ph

.lr.ph:                                           ; preds = %7, %.critedge
  %.02029 = phi ptr [ %20, %.critedge ], [ %9, %7 ]
  %14 = load ptr, ptr %.02029, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %14, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %.not = icmp eq i32 %16, %1
  %.not22 = icmp eq i32 %16, %2
  %or.cond = or i1 %.not, %.not22
  %.not23 = icmp eq i32 %16, %3
  %or.cond25 = or i1 %.not23, %or.cond
  br i1 %or.cond25, label %.critedge, label %17

17:                                               ; preds = %.lr.ph
  %18 = getelementptr inbounds i8, ptr %14, i64 8
  %19 = tail call noundef zeroext i1 @_Z23ImTriangleContainsPointRK6ImVec2S1_S1_S1_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) %18)
  br i1 %19, label %.critedge27, label %.critedge

.critedge:                                        ; preds = %17, %.lr.ph
  %20 = getelementptr inbounds i8, ptr %.02029, i64 8
  %.not24.not = icmp ult ptr %20, %13
  br i1 %.not24.not, label %.lr.ph, label %.critedge27, !llvm.loop !19

.critedge27:                                      ; preds = %17, %.critedge, %7
  %.not24.lcssa = phi i1 [ true, %7 ], [ true, %.critedge ], [ false, %17 ]
  ret i1 %.not24.lcssa
}

declare noundef zeroext i1 @_Z23ImTriangleContainsPointRK6ImVec2S1_S1_S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

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 = { "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, !10, i64 32}
!6 = !{!"_ZTS14ImTriangulator", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS22ImTriangulatorNodeSpan", !10, i64 0, !7, i64 8}
!12 = !{!6, !7, i64 40}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !7, i64 4}
!15 = !{!"_ZTS18ImTriangulatorNode", !16, i64 0, !7, i64 4, !17, i64 8, !10, i64 16, !10, i64 24}
!16 = !{!"_ZTS22ImTriangulatorNodeType", !8, i64 0}
!17 = !{!"_ZTS6ImVec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass