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

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

; 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 zeroext i1 @_Z21ImTriangleIsClockwiseRK6ImVec2S1_S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14ImTriangulator14ReclassifyNodeEP18ImTriangulatorNode(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %10, i32 0, i32 4
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %13, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  store ptr %15, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %18, i32 0, i32 2
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %20, i32 0, i32 2
  %22 = call noundef zeroext i1 @_Z21ImTriangleIsClockwiseRK6ImVec2S1_S1_(ptr noundef nonnull align 4 dereferenceable(8) %17, ptr noundef nonnull align 4 dereferenceable(8) %19, ptr noundef nonnull align 4 dereferenceable(8) %21)
  br i1 %22, label %24, label %23

23:                                               ; preds = %2
  store i32 2, ptr %5, align 4, !tbaa !16
  br label %44

24:                                               ; preds = %2
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !17
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !17
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !17
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %38, i32 0, i32 2
  %40 = call noundef zeroext i1 @_ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_(ptr noundef nonnull align 8 dereferenceable(48) %9, i32 noundef %27, i32 noundef %30, i32 noundef %33, ptr noundef nonnull align 4 dereferenceable(8) %35, ptr noundef nonnull align 4 dereferenceable(8) %37, ptr noundef nonnull align 4 dereferenceable(8) %39)
  br i1 %40, label %41, label %42

41:                                               ; preds = %24
  store i32 1, ptr %5, align 4, !tbaa !16
  br label %43

42:                                               ; preds = %24
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %43

43:                                               ; preds = %42, %41
  br label %44

44:                                               ; preds = %43, %23
  %45 = load i32, ptr %5, align 4, !tbaa !16
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !18
  %49 = icmp eq i32 %45, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  store i32 1, ptr %8, align 4
  br label %89

51:                                               ; preds = %44
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !18
  %55 = icmp eq i32 %54, 2
  br i1 %55, label %56, label %61

56:                                               ; preds = %51
  %57 = getelementptr inbounds %struct.ImTriangulator, ptr %9, i32 0, i32 3
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !17
  call void @_ZN22ImTriangulatorNodeSpan19find_erase_unsortedEi(ptr noundef nonnull align 8 dereferenceable(12) %57, i32 noundef %60)
  br label %72

61:                                               ; preds = %51
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !18
  %65 = icmp eq i32 %64, 1
  br i1 %65, label %66, label %71

66:                                               ; preds = %61
  %67 = getelementptr inbounds %struct.ImTriangulator, ptr %9, i32 0, i32 2
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !17
  call void @_ZN22ImTriangulatorNodeSpan19find_erase_unsortedEi(ptr noundef nonnull align 8 dereferenceable(12) %67, i32 noundef %70)
  br label %71

71:                                               ; preds = %66, %61
  br label %72

72:                                               ; preds = %71, %56
  %73 = load i32, ptr %5, align 4, !tbaa !16
  %74 = icmp eq i32 %73, 2
  br i1 %74, label %75, label %78

75:                                               ; preds = %72
  %76 = getelementptr inbounds %struct.ImTriangulator, ptr %9, i32 0, i32 3
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN22ImTriangulatorNodeSpan9push_backEP18ImTriangulatorNode(ptr noundef nonnull align 8 dereferenceable(12) %76, ptr noundef %77)
  br label %85

78:                                               ; preds = %72
  %79 = load i32, ptr %5, align 4, !tbaa !16
  %80 = icmp eq i32 %79, 1
  br i1 %80, label %81, label %84

81:                                               ; preds = %78
  %82 = getelementptr inbounds %struct.ImTriangulator, ptr %9, i32 0, i32 2
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN22ImTriangulatorNodeSpan9push_backEP18ImTriangulatorNode(ptr noundef nonnull align 8 dereferenceable(12) %82, ptr noundef %83)
  br label %84

84:                                               ; preds = %81, %78
  br label %85

85:                                               ; preds = %84, %75
  %86 = load i32, ptr %5, align 4, !tbaa !16
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ImTriangulatorNode, ptr %87, i32 0, i32 0
  store i32 %86, ptr %88, align 8, !tbaa !18
  store i32 0, ptr %8, align 4
  br label %89

89:                                               ; preds = %85, %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %90 = load i32, ptr %8, align 4
  switch i32 %90, label %92 [
    i32 0, label %91
    i32 1, label %91
  ]

91:                                               ; preds = %89, %89
  ret void

92:                                               ; preds = %89
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN22ImTriangulatorNodeSpan19find_erase_unsortedEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #2 align 2

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 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 #3 = { 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 #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"}
!9 = !{!10, !6, i64 24}
!10 = !{!"_ZTS18ImTriangulatorNode", !11, i64 0, !12, i64 4, !13, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"_ZTS22ImTriangulatorNodeType", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !12, i64 4}
!18 = !{!10, !11, 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"

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z21ImTriangleIsClockwiseRK6ImVec2S1_S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN22ImTriangulatorNodeSpan9push_backEP18ImTriangulatorNode(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14ImTriangulator14ReclassifyNodeEP18ImTriangulatorNode(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  %10 = tail call noundef zeroext i1 @_Z21ImTriangleIsClockwiseRK6ImVec2S1_S1_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) %9)
  br i1 %10, label %11, label %19

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %4, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %6, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !15
  %18 = tail call noundef zeroext i1 @_ZNK14ImTriangulator5IsEarEiiiRK6ImVec2S2_S2_(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %13, i32 noundef %15, i32 noundef %17, ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) %9)
  %.24 = zext i1 %18 to i32
  br label %19

19:                                               ; preds = %11, %2
  %20 = phi i1 [ false, %2 ], [ %18, %11 ]
  %.0 = phi i32 [ 2, %2 ], [ %.24, %11 ]
  %21 = load i32, ptr %1, align 8, !tbaa !16
  %22 = icmp eq i32 %.0, %21
  br i1 %22, label %31, label %23

23:                                               ; preds = %19
  switch i32 %21, label %28 [
    i32 2, label %.sink.split
    i32 1, label %24
  ]

24:                                               ; preds = %23
  br label %.sink.split

.sink.split:                                      ; preds = %23, %24
  %.sink27 = phi i64 [ 16, %24 ], [ 32, %23 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 %.sink27
  %26 = getelementptr inbounds i8, ptr %1, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !15
  tail call void @_ZN22ImTriangulatorNodeSpan19find_erase_unsortedEi(ptr noundef nonnull align 8 dereferenceable(12) %25, i32 noundef %27)
  br label %28

28:                                               ; preds = %.sink.split, %23
  %.not = xor i1 %10, true
  %brmerge = or i1 %20, %.not
  br i1 %brmerge, label %.sink.split28, label %30

.sink.split28:                                    ; preds = %28
  %.mux = select i1 %10, i64 16, i64 32
  %29 = getelementptr inbounds i8, ptr %0, i64 %.mux
  tail call void @_ZN22ImTriangulatorNodeSpan9push_backEP18ImTriangulatorNode(ptr noundef nonnull align 8 dereferenceable(12) %29, ptr noundef nonnull %1)
  br label %30

30:                                               ; preds = %28, %.sink.split28
  store i32 %.0, ptr %1, align 8, !tbaa !16
  br label %31

31:                                               ; preds = %19, %30
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN22ImTriangulatorNodeSpan19find_erase_unsortedEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #1 align 2

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

!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, !13, i64 24}
!6 = !{!"_ZTS18ImTriangulatorNode", !7, i64 0, !10, i64 4, !11, i64 8, !13, i64 16, !13, i64 24}
!7 = !{!"_ZTS22ImTriangulatorNodeType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!6, !13, i64 16}
!15 = !{!6, !10, i64 4}
!16 = !{!6, !7, i64 0}


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