; LLVM IR from yangfengzzz/DigitalVox4 :: editor/imgui_canvas.ll (ZN7ImGuiEx6Canvas7SuspendEv)

; 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.ImGuiEx::Canvas" = type <{ i8, [3 x i8], %struct.ImVec2, %struct.ImVec2, %struct.ImRect, [4 x i8], ptr, i32, i32, i32, %"struct.ImGuiEx::CanvasView", %struct.ImRect, %struct.ImVec2, i32, float, %struct.ImVec2, %struct.ImVec2, [5 x %struct.ImVec2], %struct.ImVec2, [4 x i8] }>
%"struct.ImGuiEx::CanvasView" = type { %struct.ImVec2, float, float }
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%struct.ImVec2 = type { float, float }
%struct.ImDrawList = type <{ %struct.ImVector, %struct.ImVector.0, %struct.ImVector.1, i32, i32, ptr, ptr, ptr, ptr, %struct.ImVector.2, %struct.ImVector.3, %struct.ImVector.4, %struct.ImDrawCmdHeader, %struct.ImDrawListSplitter, float, [4 x i8] }>
%struct.ImVector = type { i32, i32, ptr }
%struct.ImVector.0 = type { i32, i32, ptr }
%struct.ImVector.1 = type { i32, i32, ptr }
%struct.ImVector.2 = type { i32, i32, ptr }
%struct.ImVector.3 = type { i32, i32, ptr }
%struct.ImVector.4 = type { i32, i32, ptr }
%struct.ImDrawCmdHeader = type <{ %struct.ImVec4, ptr, i32, [4 x i8] }>
%struct.ImVec4 = type { float, float, float, float }
%struct.ImDrawListSplitter = type { i32, i32, %struct.ImVector.5 }
%struct.ImVector.5 = type { i32, i32, ptr }

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [52 x i8], align 1
@__PRETTY_FUNCTION__._ZN7ImGuiEx6Canvas7SuspendEv = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7ImGuiEx6Canvas15LeaveLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiEx6Canvas7SuspendEv(ptr noundef nonnull align 8 dereferenceable(172) %0) #1 align 2 {
  %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.ImGuiEx::Canvas", ptr %3, i32 0, i32 6
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %struct.ImDrawList, ptr %5, i32 0, i32 13
  %7 = getelementptr inbounds %struct.ImDrawListSplitter, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 8, !tbaa !17
  %9 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %3, i32 0, i32 7
  %10 = load i32, ptr %9, align 8, !tbaa !29
  %11 = icmp eq i32 %8, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  br label %15

13:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 232, ptr noundef @__PRETTY_FUNCTION__._ZN7ImGuiEx6Canvas7SuspendEv) #2
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  %16 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %3, i32 0, i32 13
  %17 = load i32, ptr %16, align 4, !tbaa !30
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  call void @_ZN7ImGuiEx6Canvas15LeaveLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172) %3)
  br label %20

20:                                               ; preds = %19, %15
  %21 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %3, i32 0, i32 13
  %22 = load i32, ptr %21, align 4, !tbaa !30
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %21, align 4, !tbaa !30
  ret void
}

attributes #0 = { noreturn 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 #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 = { 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 40}
!10 = !{!"_ZTSN7ImGuiEx6CanvasE", !11, i64 0, !12, i64 4, !12, i64 12, !14, i64 20, !6, i64 40, !15, i64 48, !15, i64 52, !15, i64 56, !16, i64 60, !14, i64 76, !12, i64 92, !15, i64 100, !13, i64 104, !12, i64 108, !12, i64 116, !7, i64 124, !12, i64 164}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTS6ImVec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTS6ImRect", !12, i64 0, !12, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN7ImGuiEx10CanvasViewE", !12, i64 0, !13, i64 8, !13, i64 12}
!17 = !{!18, !15, i64 168}
!18 = !{!"_ZTS10ImDrawList", !19, i64 0, !20, i64 16, !21, i64 32, !15, i64 48, !15, i64 52, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !22, i64 88, !23, i64 104, !24, i64 120, !25, i64 136, !27, i64 168, !13, i64 192}
!19 = !{!"_ZTS8ImVectorI9ImDrawCmdE", !15, i64 0, !15, i64 4, !6, i64 8}
!20 = !{!"_ZTS8ImVectorItE", !15, i64 0, !15, i64 4, !6, i64 8}
!21 = !{!"_ZTS8ImVectorI10ImDrawVertE", !15, i64 0, !15, i64 4, !6, i64 8}
!22 = !{!"_ZTS8ImVectorI6ImVec4E", !15, i64 0, !15, i64 4, !6, i64 8}
!23 = !{!"_ZTS8ImVectorIPvE", !15, i64 0, !15, i64 4, !6, i64 8}
!24 = !{!"_ZTS8ImVectorI6ImVec2E", !15, i64 0, !15, i64 4, !6, i64 8}
!25 = !{!"_ZTS15ImDrawCmdHeader", !26, i64 0, !6, i64 16, !15, i64 24}
!26 = !{!"_ZTS6ImVec4", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!27 = !{!"_ZTS18ImDrawListSplitter", !15, i64 0, !15, i64 4, !28, i64 8}
!28 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !15, i64 0, !15, i64 4, !6, i64 8}
!29 = !{!10, !15, i64 48}
!30 = !{!10, !15, i64 100}


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

@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [52 x i8], align 1
@__PRETTY_FUNCTION__._ZN7ImGuiEx6Canvas7SuspendEv = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7ImGuiEx6Canvas15LeaveLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiEx6Canvas7SuspendEv(ptr noundef nonnull align 8 dereferenceable(172) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 168
  %5 = load i32, ptr %4, align 8, !tbaa !16
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i32, ptr %6, align 8, !tbaa !28
  %8 = icmp eq i32 %5, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 232, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7ImGuiEx6Canvas7SuspendEv) #2
  unreachable

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 100
  %12 = load i32, ptr %11, align 4, !tbaa !29
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  tail call void @_ZN7ImGuiEx6Canvas15LeaveLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172) %0)
  %.pre = load i32, ptr %11, align 4, !tbaa !29
  br label %15

15:                                               ; preds = %14, %10
  %16 = phi i32 [ %.pre, %14 ], [ %12, %10 ]
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %11, align 4, !tbaa !29
  ret void
}

attributes #0 = { noreturn 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 #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 = { 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, !13, i64 40}
!6 = !{!"_ZTSN7ImGuiEx6CanvasE", !7, i64 0, !10, i64 4, !10, i64 12, !12, i64 20, !13, i64 40, !14, i64 48, !14, i64 52, !14, i64 56, !15, i64 60, !12, i64 76, !10, i64 92, !14, i64 100, !11, i64 104, !10, i64 108, !10, i64 116, !8, i64 124, !10, i64 164}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS6ImVec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !8, i64 0}
!12 = !{!"_ZTS6ImRect", !10, i64 0, !10, i64 8}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"_ZTSN7ImGuiEx10CanvasViewE", !10, i64 0, !11, i64 8, !11, i64 12}
!16 = !{!17, !14, i64 168}
!17 = !{!"_ZTS10ImDrawList", !18, i64 0, !19, i64 16, !20, i64 32, !14, i64 48, !14, i64 52, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !21, i64 88, !22, i64 104, !23, i64 120, !24, i64 136, !26, i64 168, !11, i64 192}
!18 = !{!"_ZTS8ImVectorI9ImDrawCmdE", !14, i64 0, !14, i64 4, !13, i64 8}
!19 = !{!"_ZTS8ImVectorItE", !14, i64 0, !14, i64 4, !13, i64 8}
!20 = !{!"_ZTS8ImVectorI10ImDrawVertE", !14, i64 0, !14, i64 4, !13, i64 8}
!21 = !{!"_ZTS8ImVectorI6ImVec4E", !14, i64 0, !14, i64 4, !13, i64 8}
!22 = !{!"_ZTS8ImVectorIPvE", !14, i64 0, !14, i64 4, !13, i64 8}
!23 = !{!"_ZTS8ImVectorI6ImVec2E", !14, i64 0, !14, i64 4, !13, i64 8}
!24 = !{!"_ZTS15ImDrawCmdHeader", !25, i64 0, !13, i64 16, !14, i64 24}
!25 = !{!"_ZTS6ImVec4", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!26 = !{!"_ZTS18ImDrawListSplitter", !14, i64 0, !14, i64 4, !27, i64 8}
!27 = !{!"_ZTS8ImVectorI13ImDrawChannelE", !14, i64 0, !14, i64 4, !13, i64 8}
!28 = !{!6, !14, i64 48}
!29 = !{!6, !14, i64 100}


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