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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiEx6Canvas7SetViewERKNS_10CanvasViewE(ptr noundef nonnull align 8 dereferenceable(172) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 0
  %7 = load i8, ptr %6, align 8, !tbaa !9, !range !17, !noundef !18
  %8 = trunc i8 %7 to i1
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  call void @_ZN7ImGuiEx6Canvas15LeaveLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172) %5)
  br label %10

10:                                               ; preds = %9, %2
  %11 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 10
  %12 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.ImVec2, ptr %12, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !19
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.ImVec2, ptr %16, i32 0, i32 0
  %18 = load float, ptr %17, align 4, !tbaa !20
  %19 = fcmp une float %14, %18
  br i1 %19, label %30, label %20

20:                                               ; preds = %10
  %21 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 10
  %22 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.ImVec2, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !21
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %struct.ImVec2, ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !22
  %29 = fcmp une float %24, %28
  br i1 %29, label %30, label %35

30:                                               ; preds = %20, %10
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 10
  %34 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %33, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %32, i64 8, i1 false), !tbaa.struct !23
  call void @_ZN7ImGuiEx6Canvas27UpdateViewTransformPositionEv(ptr noundef nonnull align 8 dereferenceable(172) %5)
  br label %35

35:                                               ; preds = %30, %20
  %36 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 10
  %37 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %36, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !25
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %39, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !26
  %42 = fcmp une float %38, %41
  br i1 %42, label %43, label %54

43:                                               ; preds = %35
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %44, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !26
  %47 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 10
  %48 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %47, i32 0, i32 1
  store float %46, ptr %48, align 4, !tbaa !25
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %49, i32 0, i32 2
  %51 = load float, ptr %50, align 4, !tbaa !27
  %52 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 10
  %53 = getelementptr inbounds %"struct.ImGuiEx::CanvasView", ptr %52, i32 0, i32 2
  store float %51, ptr %53, align 4, !tbaa !28
  br label %54

54:                                               ; preds = %43, %35
  %55 = getelementptr inbounds %"struct.ImGuiEx::Canvas", ptr %5, i32 0, i32 0
  %56 = load i8, ptr %55, align 8, !tbaa !9, !range !17, !noundef !18
  %57 = trunc i8 %56 to i1
  br i1 %57, label %58, label %59

58:                                               ; preds = %54
  call void @_ZN7ImGuiEx6Canvas15EnterLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172) %5)
  br label %59

59:                                               ; preds = %58, %54
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="64" "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!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 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!10, !13, i64 60}
!20 = !{!16, !13, i64 0}
!21 = !{!10, !13, i64 64}
!22 = !{!16, !13, i64 4}
!23 = !{i64 0, i64 4, !24, i64 4, i64 4, !24}
!24 = !{!13, !13, i64 0}
!25 = !{!10, !13, i64 68}
!26 = !{!16, !13, i64 8}
!27 = !{!16, !13, i64 12}
!28 = !{!10, !13, i64 72}


; 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
declare dso_local void @_ZN7ImGuiEx6Canvas27UpdateViewTransformPositionEv(ptr noundef nonnull align 8 dereferenceable(172)) local_unnamed_addr #0 align 2

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

; 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 @_ZN7ImGuiEx6Canvas7SetViewERKNS_10CanvasViewE(ptr noundef nonnull align 8 dereferenceable(172) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %1) local_unnamed_addr #1 align 2 {
  %3 = load i8, ptr %0, align 8, !tbaa !5, !range !16, !noundef !17
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %6

5:                                                ; preds = %2
  tail call void @_ZN7ImGuiEx6Canvas15LeaveLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172) %0)
  br label %6

6:                                                ; preds = %5, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 60
  %8 = load float, ptr %7, align 4, !tbaa !18
  %9 = load float, ptr %1, align 4, !tbaa !19
  %10 = fcmp une float %8, %9
  br i1 %10, label %17, label %11

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  %13 = load float, ptr %12, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  %15 = load float, ptr %14, align 4, !tbaa !21
  %16 = fcmp une float %13, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %11, %6
  %18 = load i64, ptr %1, align 4
  store i64 %18, ptr %7, align 4
  tail call void @_ZN7ImGuiEx6Canvas27UpdateViewTransformPositionEv(ptr noundef nonnull align 8 dereferenceable(172) %0)
  br label %19

19:                                               ; preds = %17, %11
  %20 = getelementptr inbounds i8, ptr %0, i64 68
  %21 = load float, ptr %20, align 4, !tbaa !22
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  %23 = load float, ptr %22, align 4, !tbaa !23
  %24 = fcmp une float %21, %23
  br i1 %24, label %25, label %29

25:                                               ; preds = %19
  store float %23, ptr %20, align 4, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %1, i64 12
  %27 = load float, ptr %26, align 4, !tbaa !24
  %28 = getelementptr inbounds i8, ptr %0, i64 72
  store float %27, ptr %28, align 8, !tbaa !25
  br label %29

29:                                               ; preds = %25, %19
  %30 = load i8, ptr %0, align 8, !tbaa !5, !range !16, !noundef !17
  %31 = trunc nuw i8 %30 to i1
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  tail call void @_ZN7ImGuiEx6Canvas15EnterLocalSpaceEv(ptr noundef nonnull align 8 dereferenceable(172) %0)
  br label %33

33:                                               ; preds = %32, %29
  ret void
}

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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" }

!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, !7, i64 0}
!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 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !11, i64 60}
!19 = !{!15, !11, i64 0}
!20 = !{!6, !11, i64 64}
!21 = !{!15, !11, i64 4}
!22 = !{!6, !11, i64 68}
!23 = !{!15, !11, i64 8}
!24 = !{!15, !11, i64 12}
!25 = !{!6, !11, i64 72}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass