; LLVM IR from jan-van-bergen/GPU-Raytracer :: include/Imgui/imgui_impl_sdl.ll (Z23ImGui_ImplSDL2_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"

%struct.ImGui_ImplSDL2_Data = type <{ ptr, ptr, i64, i32, [4 x i8], [9 x ptr], ptr, i8, [7 x i8] }>
%struct.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, float, float, float, float, float, ptr, ptr, float, i8, ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, [645 x i32], [512 x i8], %struct.ImVec2, [5 x i8], float, float, i8, i8, i8, i8, [20 x float], i32, i32, [645 x %struct.ImGuiKeyData], i8, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [5 x i8], [5 x i8], [5 x i16], [5 x i16], [5 x i8], [5 x i8], [5 x i8], [5 x float], [5 x float], [5 x float], [20 x float], [20 x float], float, i8, i8, i8, i16, %struct.ImVector }
%struct.ImGuiKeyData = type { i8, float, float, float }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__._Z23ImGui_ImplSDL2_Shutdownv = external hidden unnamed_addr constant [31 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

declare noundef nonnull align 8 dereferenceable(14160) ptr @_ZN5ImGui5GetIOEv() #1

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplSDL2_GetBackendDatav() #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z23ImGui_ImplSDL2_Shutdownv() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %4 = call noundef ptr @_ZL29ImGui_ImplSDL2_GetBackendDatav()
  store ptr %4, ptr %1, align 8, !tbaa !5
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %0
  br label %8

8:                                                ; preds = %7, %0
  %9 = phi i1 [ false, %0 ], [ true, %7 ]
  br i1 %9, label %10, label %11

10:                                               ; preds = %8
  br label %13

11:                                               ; preds = %8
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 403, ptr noundef @__PRETTY_FUNCTION__._Z23ImGui_ImplSDL2_Shutdownv) #5
  unreachable

12:                                               ; No predecessors!
  br label %13

13:                                               ; preds = %12, %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %14 = call noundef nonnull align 8 dereferenceable(14160) ptr @_ZN5ImGui5GetIOEv()
  store ptr %14, ptr %2, align 8, !tbaa !5
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ImGui_ImplSDL2_Data, ptr %15, i32 0, i32 6
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %23

19:                                               ; preds = %13
  %20 = load ptr, ptr %1, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImGui_ImplSDL2_Data, ptr %20, i32 0, i32 6
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  call void @SDL_free(ptr noundef %22)
  br label %23

23:                                               ; preds = %19, %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %24

24:                                               ; preds = %35, %23
  %25 = load i32, ptr %3, align 4, !tbaa !14
  %26 = icmp slt i32 %25, 9
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %38

28:                                               ; preds = %24
  %29 = load ptr, ptr %1, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ImGui_ImplSDL2_Data, ptr %29, i32 0, i32 5
  %31 = load i32, ptr %3, align 4, !tbaa !14
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [9 x ptr], ptr %30, i64 0, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  call void @SDL_FreeCursor(ptr noundef %34)
  br label %35

35:                                               ; preds = %28
  %36 = load i32, ptr %3, align 4, !tbaa !14
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %3, align 4, !tbaa !14
  br label %24, !llvm.loop !15

38:                                               ; preds = %27
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ImGuiIO, ptr %39, i32 0, i32 26
  store ptr null, ptr %40, align 8, !tbaa !17
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ImGuiIO, ptr %41, i32 0, i32 28
  store ptr null, ptr %42, align 8, !tbaa !23
  %43 = load ptr, ptr %1, align 8, !tbaa !5
  call void @_Z9IM_DELETEI19ImGui_ImplSDL2_DataEvPT_(ptr noundef %43)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare void @SDL_free(ptr noundef) #1

declare void @SDL_FreeCursor(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9IM_DELETEI19ImGui_ImplSDL2_DataEvPT_(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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" }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 104}
!10 = !{!"_ZTS19ImGui_ImplSDL2_Data", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 24, !7, i64 32, !6, i64 104, !13, i64 112}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !12, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !6, i64 120}
!18 = !{!"_ZTS7ImGuiIO", !12, i64 0, !12, i64 4, !19, i64 8, !20, i64 16, !20, i64 20, !6, i64 24, !6, i64 32, !20, i64 40, !20, i64 44, !20, i64 48, !20, i64 52, !20, i64 56, !6, i64 64, !6, i64 72, !20, i64 80, !13, i64 84, !6, i64 88, !19, i64 96, !13, i64 104, !13, i64 105, !13, i64 106, !13, i64 107, !13, i64 108, !13, i64 109, !13, i64 110, !20, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !13, i64 200, !13, i64 201, !13, i64 202, !13, i64 203, !13, i64 204, !13, i64 205, !13, i64 206, !20, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !12, i64 224, !12, i64 228, !19, i64 232, !7, i64 240, !7, i64 2820, !19, i64 3332, !7, i64 3340, !20, i64 3348, !20, i64 3352, !13, i64 3356, !13, i64 3357, !13, i64 3358, !13, i64 3359, !7, i64 3360, !12, i64 3440, !12, i64 3444, !7, i64 3448, !13, i64 13768, !19, i64 13772, !7, i64 13780, !7, i64 13824, !7, i64 13864, !7, i64 13869, !7, i64 13874, !7, i64 13884, !7, i64 13894, !7, i64 13899, !7, i64 13904, !7, i64 13912, !7, i64 13932, !7, i64 13952, !7, i64 13972, !7, i64 14052, !20, i64 14132, !13, i64 14136, !7, i64 14137, !13, i64 14138, !21, i64 14140, !22, i64 14144}
!19 = !{!"_ZTS6ImVec2", !20, i64 0, !20, i64 4}
!20 = !{!"float", !7, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = !{!"_ZTS8ImVectorItE", !12, i64 0, !12, i64 4, !6, i64 8}
!23 = !{!18, !6, i64 136}


; 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 [95 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [72 x i8], align 1
@__PRETTY_FUNCTION__._Z23ImGui_ImplSDL2_Shutdownv = external hidden unnamed_addr constant [31 x i8], align 1

declare noundef nonnull align 8 dereferenceable(14160) ptr @_ZN5ImGui5GetIOEv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplSDL2_GetBackendDatav() 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 @_Z23ImGui_ImplSDL2_Shutdownv() local_unnamed_addr #1 {
  %1 = tail call noundef ptr @_ZL29ImGui_ImplSDL2_GetBackendDatav()
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %2, label %3

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

3:                                                ; preds = %0
  %4 = tail call noundef nonnull align 8 dereferenceable(14160) ptr @_ZN5ImGui5GetIOEv()
  %5 = getelementptr inbounds i8, ptr %1, i64 104
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not11 = icmp eq ptr %6, null
  br i1 %.not11, label %8, label %7

7:                                                ; preds = %3
  tail call void @SDL_free(ptr noundef nonnull %6)
  br label %8

8:                                                ; preds = %7, %3
  %9 = getelementptr inbounds i8, ptr %1, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %10)
  %11 = getelementptr inbounds i8, ptr %1, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %12)
  %13 = getelementptr inbounds i8, ptr %1, i64 48
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %14)
  %15 = getelementptr inbounds i8, ptr %1, i64 56
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %16)
  %17 = getelementptr inbounds i8, ptr %1, i64 64
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %18)
  %19 = getelementptr inbounds i8, ptr %1, i64 72
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %20)
  %21 = getelementptr inbounds i8, ptr %1, i64 80
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %22)
  %23 = getelementptr inbounds i8, ptr %1, i64 88
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %24)
  %25 = getelementptr inbounds i8, ptr %1, i64 96
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  tail call void @SDL_FreeCursor(ptr noundef %26)
  %27 = getelementptr inbounds i8, ptr %4, i64 120
  store ptr null, ptr %27, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %4, i64 136
  store ptr null, ptr %28, align 8, !tbaa !20
  tail call void @_Z9IM_DELETEI19ImGui_ImplSDL2_DataEvPT_(ptr noundef nonnull %1)
  ret void
}

declare void @SDL_free(ptr noundef) local_unnamed_addr #0

declare void @SDL_FreeCursor(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9IM_DELETEI19ImGui_ImplSDL2_DataEvPT_(ptr noundef) local_unnamed_addr #1

attributes #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, !7, i64 104}
!6 = !{!"_ZTS19ImGui_ImplSDL2_Data", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !8, i64 32, !7, i64 104, !12, i64 112}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !7, i64 120}
!15 = !{!"_ZTS7ImGuiIO", !11, i64 0, !11, i64 4, !16, i64 8, !17, i64 16, !17, i64 20, !7, i64 24, !7, i64 32, !17, i64 40, !17, i64 44, !17, i64 48, !17, i64 52, !17, i64 56, !7, i64 64, !7, i64 72, !17, i64 80, !12, i64 84, !7, i64 88, !16, i64 96, !12, i64 104, !12, i64 105, !12, i64 106, !12, i64 107, !12, i64 108, !12, i64 109, !12, i64 110, !17, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !12, i64 200, !12, i64 201, !12, i64 202, !12, i64 203, !12, i64 204, !12, i64 205, !12, i64 206, !17, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !16, i64 232, !8, i64 240, !8, i64 2820, !16, i64 3332, !8, i64 3340, !17, i64 3348, !17, i64 3352, !12, i64 3356, !12, i64 3357, !12, i64 3358, !12, i64 3359, !8, i64 3360, !11, i64 3440, !11, i64 3444, !8, i64 3448, !12, i64 13768, !16, i64 13772, !8, i64 13780, !8, i64 13824, !8, i64 13864, !8, i64 13869, !8, i64 13874, !8, i64 13884, !8, i64 13894, !8, i64 13899, !8, i64 13904, !8, i64 13912, !8, i64 13932, !8, i64 13952, !8, i64 13972, !8, i64 14052, !17, i64 14132, !12, i64 14136, !8, i64 14137, !12, i64 14138, !18, i64 14140, !19, i64 14144}
!16 = !{!"_ZTS6ImVec2", !17, i64 0, !17, i64 4}
!17 = !{!"float", !8, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = !{!"_ZTS8ImVectorItE", !11, i64 0, !11, i64 4, !7, i64 8}
!20 = !{!15, !7, i64 136}


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