; LLVM IR from erwincoumans/tiny-differentiable-simulator :: third_party/dear_imgui/imnodes.ll (ZN7imnodes19SetNodeGridSpacePosEiRK6ImVec2)

; 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.imnodes::EditorContext" = type { %"struct.imnodes::(anonymous namespace)::ObjectPool", %"struct.imnodes::(anonymous namespace)::ObjectPool.6", %"struct.imnodes::(anonymous namespace)::ObjectPool.8", %struct.ImVector.0, %struct.ImVec2, %struct.ImVector.0, %struct.ImVector.0, i32, %"struct.imnodes::(anonymous namespace)::ClickInteractionState" }
%"struct.imnodes::(anonymous namespace)::ObjectPool" = type { %struct.ImVector.4, %struct.ImVector.5, %struct.ImVector.0, %struct.ImGuiStorage }
%struct.ImVector.4 = type { i32, i32, ptr }
%struct.ImVector.5 = type { i32, i32, ptr }
%struct.ImGuiStorage = type { %struct.ImVector }
%struct.ImVector = type { i32, i32, ptr }
%"struct.imnodes::(anonymous namespace)::ObjectPool.6" = type { %struct.ImVector.7, %struct.ImVector.5, %struct.ImVector.0, %struct.ImGuiStorage }
%struct.ImVector.7 = type { i32, i32, ptr }
%"struct.imnodes::(anonymous namespace)::ObjectPool.8" = type { %struct.ImVector.9, %struct.ImVector.5, %struct.ImVector.0, %struct.ImGuiStorage }
%struct.ImVector.9 = type { i32, i32, ptr }
%struct.ImVec2 = type { float, float }
%struct.ImVector.0 = type { i32, i32, ptr }
%"struct.imnodes::(anonymous namespace)::ClickInteractionState" = type { %struct.anon.10, %struct.anon.11 }
%struct.anon.10 = type { i32, %"struct.imnodes::(anonymous namespace)::OptionalIndex", i32 }
%"struct.imnodes::(anonymous namespace)::OptionalIndex" = type { i32 }
%struct.anon.11 = type { %struct.ImRect }
%struct.ImRect = type { %struct.ImVec2, %struct.ImVec2 }
%"struct.imnodes::(anonymous namespace)::NodeData" = type <{ i32, %struct.ImVec2, %struct.ImRect, %struct.ImRect, %struct.anon.12, %struct.anon.13, [4 x i8], %struct.ImVector.0, i8, [7 x i8] }>
%struct.anon.12 = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.anon.13 = type { float, %struct.ImVec2 }

@_ZN7imnodes12_GLOBAL__N_111initializedE = external hidden global i8, align 1
@.str.1 = external hidden unnamed_addr constant [111 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__._ZN7imnodes19SetNodeGridSpacePosEiRK6ImVec2 = external hidden unnamed_addr constant [55 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(280) ptr @_ZN7imnodes12_GLOBAL__N_118editor_context_getEv() #1

; 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) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef nonnull align 8 dereferenceable(105) ptr @_ZN7imnodes12_GLOBAL__N_133object_pool_find_or_create_objectINS0_8NodeDataEEERT_RNS0_10ObjectPoolIS3_EEi(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7imnodes19SetNodeGridSpacePosEiRK6ImVec2(i32 noundef %0, ptr noundef nonnull align 4 dereferenceable(8) %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  %7 = load i8, ptr @_ZN7imnodes12_GLOBAL__N_111initializedE, align 1, !tbaa !11, !range !13, !noundef !14
  %8 = trunc i8 %7 to i1
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  br label %12

10:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 2387, ptr noundef @__PRETTY_FUNCTION__._ZN7imnodes19SetNodeGridSpacePosEiRK6ImVec2) #5
  unreachable

11:                                               ; No predecessors!
  br label %12

12:                                               ; preds = %11, %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %13 = call noundef nonnull align 8 dereferenceable(280) ptr @_ZN7imnodes12_GLOBAL__N_118editor_context_getEv()
  store ptr %13, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds %"struct.imnodes::EditorContext", ptr %14, i32 0, i32 0
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = call noundef nonnull align 8 dereferenceable(105) ptr @_ZN7imnodes12_GLOBAL__N_133object_pool_find_or_create_objectINS0_8NodeDataEEERT_RNS0_10ObjectPoolIS3_EEi(ptr noundef nonnull align 8 dereferenceable(64) %15, i32 noundef %16)
  store ptr %17, ptr %6, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.imnodes::(anonymous namespace)::NodeData", ptr %19, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %18, i64 8, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #5 = { noreturn nounwind }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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"

@_ZN7imnodes12_GLOBAL__N_111initializedE = external hidden local_unnamed_addr global i8, align 1
@.str.1 = external hidden unnamed_addr constant [111 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__._ZN7imnodes19SetNodeGridSpacePosEiRK6ImVec2 = external hidden unnamed_addr constant [55 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(280) ptr @_ZN7imnodes12_GLOBAL__N_118editor_context_getEv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef nonnull align 8 dereferenceable(105) ptr @_ZN7imnodes12_GLOBAL__N_133object_pool_find_or_create_objectINS0_8NodeDataEEERT_RNS0_10ObjectPoolIS3_EEi(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7imnodes19SetNodeGridSpacePosEiRK6ImVec2(i32 noundef %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %1) local_unnamed_addr #1 {
  %3 = load i8, ptr @_ZN7imnodes12_GLOBAL__N_111initializedE, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %6, label %5

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

6:                                                ; preds = %2
  %7 = tail call noundef nonnull align 8 dereferenceable(280) ptr @_ZN7imnodes12_GLOBAL__N_118editor_context_getEv()
  %8 = tail call noundef nonnull align 8 dereferenceable(105) ptr @_ZN7imnodes12_GLOBAL__N_133object_pool_find_or_create_objectINS0_8NodeDataEEERT_RNS0_10ObjectPoolIS3_EEi(ptr noundef nonnull align 8 dereferenceable(64) %7, i32 noundef %0)
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  %10 = load i64, ptr %1, align 4
  store i64 %10, ptr %9, align 4
  ret void
}

attributes #0 = { 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 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 "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 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}


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