; LLVM IR from chiraqL/Engine3D :: src/imgui/imgui_impl_glfw.ll (Z23ImGui_ImplGlfw_Shutdownv)

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

@_ZL29g_PrevUserCallbackMousebutton = external hidden global ptr, align 8
@_ZL8g_Window = external hidden global ptr, align 8
@_ZL24g_PrevUserCallbackScroll = external hidden global ptr, align 8
@_ZL21g_PrevUserCallbackKey = external hidden global ptr, align 8
@_ZL22g_PrevUserCallbackChar = external hidden global ptr, align 8
@_ZL20g_InstalledCallbacks = external hidden global i8, align 1
@_ZL14g_MouseCursors = external hidden global [9 x ptr], align 16
@_ZL11g_ClientApi = external hidden global i32, align 4

; 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 uwtable
define dso_local void @_Z23ImGui_ImplGlfw_Shutdownv() #1 {
  %1 = alloca i32, align 4
  call void @_ZL40ImGui_ImplGlfw_ShutdownPlatformInterfacev()
  %2 = load i8, ptr @_ZL20g_InstalledCallbacks, align 1, !tbaa !5, !range !9, !noundef !10
  %3 = trunc i8 %2 to i1
  br i1 %3, label %4, label %17

4:                                                ; preds = %0
  %5 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %6 = load ptr, ptr @_ZL29g_PrevUserCallbackMousebutton, align 8, !tbaa !11
  %7 = call ptr @glfwSetMouseButtonCallback(ptr noundef %5, ptr noundef %6)
  %8 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %9 = load ptr, ptr @_ZL24g_PrevUserCallbackScroll, align 8, !tbaa !11
  %10 = call ptr @glfwSetScrollCallback(ptr noundef %8, ptr noundef %9)
  %11 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %12 = load ptr, ptr @_ZL21g_PrevUserCallbackKey, align 8, !tbaa !11
  %13 = call ptr @glfwSetKeyCallback(ptr noundef %11, ptr noundef %12)
  %14 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %15 = load ptr, ptr @_ZL22g_PrevUserCallbackChar, align 8, !tbaa !11
  %16 = call ptr @glfwSetCharCallback(ptr noundef %14, ptr noundef %15)
  store i8 0, ptr @_ZL20g_InstalledCallbacks, align 1, !tbaa !5
  br label %17

17:                                               ; preds = %4, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %30, %17
  %19 = load i32, ptr %1, align 4, !tbaa !13
  %20 = icmp slt i32 %19, 9
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %33

22:                                               ; preds = %18
  %23 = load i32, ptr %1, align 4, !tbaa !13
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [9 x ptr], ptr @_ZL14g_MouseCursors, i64 0, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  call void @glfwDestroyCursor(ptr noundef %26)
  %27 = load i32, ptr %1, align 4, !tbaa !13
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [9 x ptr], ptr @_ZL14g_MouseCursors, i64 0, i64 %28
  store ptr null, ptr %29, align 8, !tbaa !11
  br label %30

30:                                               ; preds = %22
  %31 = load i32, ptr %1, align 4, !tbaa !13
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %1, align 4, !tbaa !13
  br label %18, !llvm.loop !15

33:                                               ; preds = %21
  store i32 0, ptr @_ZL11g_ClientApi, align 4, !tbaa !17
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL40ImGui_ImplGlfw_ShutdownPlatformInterfacev() #2

declare ptr @glfwSetMouseButtonCallback(ptr noundef, ptr noundef) #3

declare ptr @glfwSetScrollCallback(ptr noundef, ptr noundef) #3

declare ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) #3

declare ptr @glfwSetCharCallback(ptr noundef, ptr noundef) #3

declare void @glfwDestroyCursor(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"_ZTS13GlfwClientApi", !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"

@_ZL29g_PrevUserCallbackMousebutton = external hidden local_unnamed_addr global ptr, align 8
@_ZL8g_Window = external hidden local_unnamed_addr global ptr, align 8
@_ZL24g_PrevUserCallbackScroll = external hidden local_unnamed_addr global ptr, align 8
@_ZL21g_PrevUserCallbackKey = external hidden local_unnamed_addr global ptr, align 8
@_ZL22g_PrevUserCallbackChar = external hidden local_unnamed_addr global ptr, align 8
@_ZL20g_InstalledCallbacks = external hidden local_unnamed_addr global i8, align 1
@_ZL14g_MouseCursors = external hidden local_unnamed_addr global [9 x ptr], align 16
@_ZL11g_ClientApi = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z23ImGui_ImplGlfw_Shutdownv() local_unnamed_addr #0 {
  tail call void @_ZL40ImGui_ImplGlfw_ShutdownPlatformInterfacev()
  %1 = load i8, ptr @_ZL20g_InstalledCallbacks, align 1, !tbaa !5, !range !9, !noundef !10
  %2 = trunc nuw i8 %1 to i1
  br i1 %2, label %3, label %16

3:                                                ; preds = %0
  %4 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %5 = load ptr, ptr @_ZL29g_PrevUserCallbackMousebutton, align 8, !tbaa !11
  %6 = tail call ptr @glfwSetMouseButtonCallback(ptr noundef %4, ptr noundef %5)
  %7 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %8 = load ptr, ptr @_ZL24g_PrevUserCallbackScroll, align 8, !tbaa !11
  %9 = tail call ptr @glfwSetScrollCallback(ptr noundef %7, ptr noundef %8)
  %10 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %11 = load ptr, ptr @_ZL21g_PrevUserCallbackKey, align 8, !tbaa !11
  %12 = tail call ptr @glfwSetKeyCallback(ptr noundef %10, ptr noundef %11)
  %13 = load ptr, ptr @_ZL8g_Window, align 8, !tbaa !11
  %14 = load ptr, ptr @_ZL22g_PrevUserCallbackChar, align 8, !tbaa !11
  %15 = tail call ptr @glfwSetCharCallback(ptr noundef %13, ptr noundef %14)
  store i8 0, ptr @_ZL20g_InstalledCallbacks, align 1, !tbaa !5
  br label %16

16:                                               ; preds = %3, %0
  %17 = load ptr, ptr @_ZL14g_MouseCursors, align 16, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %17)
  store ptr null, ptr @_ZL14g_MouseCursors, align 16, !tbaa !11
  %18 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 8), align 8, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %18)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 8), align 8, !tbaa !11
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 16), align 16, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %19)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 16), align 16, !tbaa !11
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 24), align 8, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %20)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 24), align 8, !tbaa !11
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 32), align 16, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %21)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 32), align 16, !tbaa !11
  %22 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 40), align 8, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %22)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 40), align 8, !tbaa !11
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 48), align 16, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %23)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 48), align 16, !tbaa !11
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 56), align 8, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %24)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 56), align 8, !tbaa !11
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 64), align 16, !tbaa !11
  tail call void @glfwDestroyCursor(ptr noundef %25)
  store ptr null, ptr getelementptr inbounds (i8, ptr @_ZL14g_MouseCursors, i64 64), align 16, !tbaa !11
  store i32 0, ptr @_ZL11g_ClientApi, align 4, !tbaa !13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL40ImGui_ImplGlfw_ShutdownPlatformInterfacev() local_unnamed_addr #1

declare ptr @glfwSetMouseButtonCallback(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @glfwSetScrollCallback(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @glfwSetKeyCallback(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @glfwSetCharCallback(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @glfwDestroyCursor(ptr noundef) local_unnamed_addr #2

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass