; LLVM IR from erwincoumans/tiny-differentiable-simulator :: third_party/dear_imgui (imgui)

; 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.ImGuiDockPreviewData = type { %struct.ImGuiDockNode, i8, i8, i8, i8, ptr, i32, float, [5 x %struct.ImRect] }
%struct.ImGuiDockNode = type <{ i32, i32, i32, [4 x i8], ptr, [2 x ptr], %struct.ImVector.5, ptr, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, i32, %struct.ImGuiWindowClass, i32, [4 x i8], ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i16, i8, [5 x i8] }>
%struct.ImVector.5 = type { i32, i32, ptr }
%struct.ImVec2 = type { float, float }
%struct.ImGuiWindowClass = type <{ i32, i32, i32, i32, i32, i32, i8, i8, [2 x i8] }>
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }

@.str.3 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui32DockContextCalcDropPosForDockingEP11ImGuiWindowP13ImGuiDockNodeS1_ibP6ImVec2 = external hidden unnamed_addr constant [118 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZNK6ImRect9GetCenterEv(ptr noundef nonnull align 4 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5ImGui32DockContextCalcDropPosForDockingEP11ImGuiWindowP13ImGuiDockNodeS1_ibP6ImVec2(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i1 noundef zeroext %4, ptr noundef %5) #3 personality ptr @__gxx_personality_v0 {
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca ptr, align 8
  %14 = alloca %struct.ImGuiDockPreviewData, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.ImVec2, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  %19 = zext i1 %4 to i8
  store i8 %19, ptr %12, align 1, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !5
  %20 = load i8, ptr %12, align 1, !tbaa !11, !range !13, !noundef !14
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %23

22:                                               ; preds = %6
  call void @__assert_fail(ptr noundef @.str.63, ptr noundef @.str.3, i32 noundef 12370, ptr noundef @__PRETTY_FUNCTION__._ZN5ImGui32DockContextCalcDropPosForDockingEP11ImGuiWindowP13ImGuiDockNodeS1_ibP6ImVec2) #7
  unreachable

23:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 296, ptr %14) #8
  call void @_ZN20ImGuiDockPreviewDataC2Ev(ptr noundef nonnull align 8 dereferenceable(296) %14)
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = load i8, ptr %12, align 1, !tbaa !11, !range !13, !noundef !14
  %28 = trunc i8 %27 to i1
  invoke void @_ZN5ImGuiL24DockNodePreviewDockSetupEP11ImGuiWindowP13ImGuiDockNodeS1_P20ImGuiDockPreviewDatabb(ptr noundef %24, ptr noundef %25, ptr noundef %26, ptr noundef %14, i1 noundef zeroext false, i1 noundef zeroext %28)
          to label %29 unwind label %38

29:                                               ; preds = %23
  %30 = getelementptr inbounds %struct.ImGuiDockPreviewData, ptr %14, i32 0, i32 8
  %31 = load i32, ptr %11, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [5 x %struct.ImRect], ptr %30, i64 0, i64 %33
  %35 = invoke noundef zeroext i1 @_ZNK6ImRect10IsInvertedEv(ptr noundef nonnull align 4 dereferenceable(16) %34)
          to label %36 unwind label %38

36:                                               ; preds = %29
  br i1 %35, label %37, label %42

37:                                               ; preds = %36
  store i1 false, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %55

38:                                               ; preds = %29, %23
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %15, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %16, align 4
  br label %57

42:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  %43 = getelementptr inbounds %struct.ImGuiDockPreviewData, ptr %14, i32 0, i32 8
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = add nsw i32 %44, 1
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [5 x %struct.ImRect], ptr %43, i64 0, i64 %46
  %48 = invoke <2 x float> @_ZNK6ImRect9GetCenterEv(ptr noundef nonnull align 4 dereferenceable(16) %47)
          to label %49 unwind label %51

49:                                               ; preds = %42
  store <2 x float> %48, ptr %18, align 4
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %50, ptr align 4 %18, i64 8, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  store i1 true, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %55

51:                                               ; preds = %42
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %15, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  br label %57

55:                                               ; preds = %49, %37
  call void @_ZN20ImGuiDockPreviewDataD2Ev(ptr noundef nonnull align 8 dereferenceable(296) %14) #8
  call void @llvm.lifetime.end.p0(i64 296, ptr %14) #8
  %56 = load i1, ptr %7, align 1
  ret i1 %56

57:                                               ; preds = %51, %38
  call void @_ZN20ImGuiDockPreviewDataD2Ev(ptr noundef nonnull align 8 dereferenceable(296) %14) #8
  call void @llvm.lifetime.end.p0(i64 296, ptr %14) #8
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %15, align 8
  %60 = load i32, ptr %16, align 4
  %61 = insertvalue { ptr, i32 } poison, ptr %59, 0
  %62 = insertvalue { ptr, i32 } %61, i32 %60, 1
  resume { ptr, i32 } %62
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN20ImGuiDockPreviewDataC2Ev(ptr noundef nonnull align 8 dereferenceable(296)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5ImGuiL24DockNodePreviewDockSetupEP11ImGuiWindowP13ImGuiDockNodeS1_P20ImGuiDockPreviewDatabb(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6ImRect10IsInvertedEv(ptr noundef nonnull align 4 dereferenceable(16)) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN20ImGuiDockPreviewDataD2Ev(ptr noundef nonnull align 8 dereferenceable(296)) unnamed_addr #6 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 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 #6 = { 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 #7 = { noreturn nounwind }
attributes #8 = { 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !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"

%struct.ImGuiDockPreviewData = type { %struct.ImGuiDockNode, i8, i8, i8, i8, ptr, i32, float, [5 x %struct.ImRect] }
%struct.ImGuiDockNode = type <{ i32, i32, i32, [4 x i8], ptr, [2 x ptr], %struct.ImVector.5, ptr, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, i32, %struct.ImGuiWindowClass, i32, [4 x i8], ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i16, i8, [5 x i8] }>
%struct.ImVector.5 = type { i32, i32, ptr }
%struct.ImVec2 = type { float, float }
%struct.ImGuiWindowClass = type <{ i32, i32, i32, i32, i32, i32, i8, i8, [2 x i8] }>
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }

@.str.3 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._ZN5ImGui32DockContextCalcDropPosForDockingEP11ImGuiWindowP13ImGuiDockNodeS1_ibP6ImVec2 = external hidden unnamed_addr constant [118 x i8], align 1

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZNK6ImRect9GetCenterEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5ImGui32DockContextCalcDropPosForDockingEP11ImGuiWindowP13ImGuiDockNodeS1_ibP6ImVec2(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i1 noundef zeroext %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %7 = alloca %struct.ImGuiDockPreviewData, align 8
  br i1 %4, label %8, label %9

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.63, ptr noundef nonnull @.str.3, i32 noundef 12370, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5ImGui32DockContextCalcDropPosForDockingEP11ImGuiWindowP13ImGuiDockNodeS1_ibP6ImVec2) #6
  unreachable

9:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 296, ptr nonnull %7) #7
  call void @_ZN20ImGuiDockPreviewDataC2Ev(ptr noundef nonnull align 8 dereferenceable(296) %7)
  invoke void @_ZN5ImGuiL24DockNodePreviewDockSetupEP11ImGuiWindowP13ImGuiDockNodeS1_P20ImGuiDockPreviewDatabb(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull %7, i1 noundef zeroext false, i1 noundef zeroext false)
          to label %10 unwind label %16

10:                                               ; preds = %9
  %11 = getelementptr inbounds i8, ptr %7, i64 216
  %12 = add nsw i32 %3, 1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [5 x %struct.ImRect], ptr %11, i64 0, i64 %13
  %15 = call noundef zeroext i1 @_ZNK6ImRect10IsInvertedEv(ptr noundef nonnull align 4 dereferenceable(16) %14)
  br i1 %15, label %23, label %18

16:                                               ; preds = %9
  %17 = landingpad { ptr, i32 }
          cleanup
  br label %24

18:                                               ; preds = %10
  %19 = invoke <2 x float> @_ZNK6ImRect9GetCenterEv(ptr noundef nonnull align 4 dereferenceable(16) %14)
          to label %20 unwind label %21

20:                                               ; preds = %18
  store <2 x float> %19, ptr %5, align 4
  br label %23

21:                                               ; preds = %18
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %24

23:                                               ; preds = %10, %20
  %.0 = xor i1 %15, true
  call void @_ZN20ImGuiDockPreviewDataD2Ev(ptr noundef nonnull align 8 dereferenceable(296) %7) #7
  call void @llvm.lifetime.end.p0(i64 296, ptr nonnull %7) #7
  ret i1 %.0

24:                                               ; preds = %21, %16
  %.pn = phi { ptr, i32 } [ %22, %21 ], [ %17, %16 ]
  call void @_ZN20ImGuiDockPreviewDataD2Ev(ptr noundef nonnull align 8 dereferenceable(296) %7) #7
  call void @llvm.lifetime.end.p0(i64 296, ptr nonnull %7) #7
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN20ImGuiDockPreviewDataC2Ev(ptr noundef nonnull align 8 dereferenceable(296)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN5ImGuiL24DockNodePreviewDockSetupEP11ImGuiWindowP13ImGuiDockNodeS1_P20ImGuiDockPreviewDatabb(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6ImRect10IsInvertedEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN20ImGuiDockPreviewDataD2Ev(ptr noundef nonnull align 8 dereferenceable(296)) unnamed_addr #5 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { 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 #5 = { 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 #6 = { noreturn nounwind }
attributes #7 = { 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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass