; LLVM IR from Razakhel/RaZ :: extern/imgui/imgui_impl_glfw.ll (Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii)

; 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_ImplGlfw_Data = type { ptr, i32, double, ptr, [5 x i8], [9 x ptr], i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, float, float, float, [22 x i32], float, float, ptr, ptr, float, i8, ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.ImVec2, [5 x i8], float, float, i8, i8, i8, i8, [512 x i8], [20 x float], i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, i32, i32, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [5 x i8], [5 x i8], [5 x i8], [5 x i8], [5 x i8], [5 x float], [5 x float], [5 x %struct.ImVec2], [5 x float], [512 x float], [512 x float], [20 x float], [20 x float], float, i16, %struct.ImVector }
%struct.ImVec2 = type { float, float }
%struct.ImVector = type { i32, i32, ptr }

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

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() #1

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

declare noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv() #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %13 = call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  store ptr %13, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %11, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %14, i32 0, i32 11
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %33

18:                                               ; preds = %5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %11, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = icmp eq ptr %19, %22
  br i1 %23, label %24, label %33

24:                                               ; preds = %18
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ImGui_ImplGlfw_Data, ptr %25, i32 0, i32 11
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = load i32, ptr %10, align 4, !tbaa !9
  call void %27(ptr noundef %28, i32 noundef %29, i32 noundef %30, i32 noundef %31, i32 noundef %32)
  br label %33

33:                                               ; preds = %24, %18, %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %34 = call noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv()
  store ptr %34, ptr %12, align 8, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = icmp sge i32 %35, 0
  br i1 %36, label %37, label %59

37:                                               ; preds = %33
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = icmp slt i32 %38, 512
  br i1 %39, label %40, label %59

40:                                               ; preds = %37
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %49

43:                                               ; preds = %40
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ImGuiIO, ptr %44, i32 0, i32 44
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [512 x i8], ptr %45, i64 0, i64 %47
  store i8 1, ptr %48, align 1, !tbaa !17
  br label %49

49:                                               ; preds = %43, %40
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %58

52:                                               ; preds = %49
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ImGuiIO, ptr %53, i32 0, i32 44
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [512 x i8], ptr %54, i64 0, i64 %56
  store i8 0, ptr %57, align 1, !tbaa !17
  br label %58

58:                                               ; preds = %52, %49
  br label %59

59:                                               ; preds = %58, %37, %33
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ImGuiIO, ptr %60, i32 0, i32 44
  %62 = getelementptr inbounds [512 x i8], ptr %61, i64 0, i64 341
  %63 = load i8, ptr %62, align 1, !tbaa !17, !range !18, !noundef !19
  %64 = trunc i8 %63 to i1
  br i1 %64, label %71, label %65

65:                                               ; preds = %59
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.ImGuiIO, ptr %66, i32 0, i32 44
  %68 = getelementptr inbounds [512 x i8], ptr %67, i64 0, i64 345
  %69 = load i8, ptr %68, align 1, !tbaa !17, !range !18, !noundef !19
  %70 = trunc i8 %69 to i1
  br label %71

71:                                               ; preds = %65, %59
  %72 = phi i1 [ true, %59 ], [ %70, %65 ]
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.ImGuiIO, ptr %73, i32 0, i32 40
  %75 = zext i1 %72 to i8
  store i8 %75, ptr %74, align 8, !tbaa !20
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ImGuiIO, ptr %76, i32 0, i32 44
  %78 = getelementptr inbounds [512 x i8], ptr %77, i64 0, i64 340
  %79 = load i8, ptr %78, align 4, !tbaa !17, !range !18, !noundef !19
  %80 = trunc i8 %79 to i1
  br i1 %80, label %87, label %81

81:                                               ; preds = %71
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.ImGuiIO, ptr %82, i32 0, i32 44
  %84 = getelementptr inbounds [512 x i8], ptr %83, i64 0, i64 344
  %85 = load i8, ptr %84, align 4, !tbaa !17, !range !18, !noundef !19
  %86 = trunc i8 %85 to i1
  br label %87

87:                                               ; preds = %81, %71
  %88 = phi i1 [ true, %71 ], [ %86, %81 ]
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ImGuiIO, ptr %89, i32 0, i32 41
  %91 = zext i1 %88 to i8
  store i8 %91, ptr %90, align 1, !tbaa !26
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.ImGuiIO, ptr %92, i32 0, i32 44
  %94 = getelementptr inbounds [512 x i8], ptr %93, i64 0, i64 342
  %95 = load i8, ptr %94, align 2, !tbaa !17, !range !18, !noundef !19
  %96 = trunc i8 %95 to i1
  br i1 %96, label %103, label %97

97:                                               ; preds = %87
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.ImGuiIO, ptr %98, i32 0, i32 44
  %100 = getelementptr inbounds [512 x i8], ptr %99, i64 0, i64 346
  %101 = load i8, ptr %100, align 2, !tbaa !17, !range !18, !noundef !19
  %102 = trunc i8 %101 to i1
  br label %103

103:                                              ; preds = %97, %87
  %104 = phi i1 [ true, %87 ], [ %102, %97 ]
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.ImGuiIO, ptr %105, i32 0, i32 42
  %107 = zext i1 %104 to i8
  store i8 %107, ptr %106, align 2, !tbaa !27
  %108 = load ptr, ptr %12, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.ImGuiIO, ptr %108, i32 0, i32 44
  %110 = getelementptr inbounds [512 x i8], ptr %109, i64 0, i64 343
  %111 = load i8, ptr %110, align 1, !tbaa !17, !range !18, !noundef !19
  %112 = trunc i8 %111 to i1
  br i1 %112, label %119, label %113

113:                                              ; preds = %103
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.ImGuiIO, ptr %114, i32 0, i32 44
  %116 = getelementptr inbounds [512 x i8], ptr %115, i64 0, i64 347
  %117 = load i8, ptr %116, align 1, !tbaa !17, !range !18, !noundef !19
  %118 = trunc i8 %117 to i1
  br label %119

119:                                              ; preds = %113, %103
  %120 = phi i1 [ true, %103 ], [ %118, %113 ]
  %121 = load ptr, ptr %12, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.ImGuiIO, ptr %121, i32 0, i32 43
  %123 = zext i1 %120 to i8
  store i8 %123, ptr %122, align 1, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret void
}

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 = { "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 = { 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, !6, i64 152}
!12 = !{!"_ZTS19ImGui_ImplGlfw_Data", !6, i64 0, !13, i64 8, !14, i64 16, !6, i64 24, !7, i64 32, !7, i64 40, !15, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168}
!13 = !{!"_ZTS13GlfwClientApi", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!12, !6, i64 0}
!17 = !{!15, !15, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!21, !15, i64 312}
!21 = !{!"_ZTS7ImGuiIO", !10, i64 0, !10, i64 4, !22, i64 8, !23, i64 16, !23, i64 20, !6, i64 24, !6, i64 32, !23, i64 40, !23, i64 44, !23, i64 48, !7, i64 52, !23, i64 140, !23, i64 144, !6, i64 152, !6, i64 160, !23, i64 168, !15, i64 172, !6, i64 176, !22, i64 184, !15, i64 192, !15, i64 193, !15, i64 194, !15, i64 195, !15, i64 196, !15, i64 197, !23, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !22, i64 288, !7, i64 296, !23, i64 304, !23, i64 308, !15, i64 312, !15, i64 313, !15, i64 314, !15, i64 315, !7, i64 316, !7, i64 828, !15, i64 908, !15, i64 909, !15, i64 910, !15, i64 911, !15, i64 912, !15, i64 913, !15, i64 914, !23, i64 916, !10, i64 920, !10, i64 924, !10, i64 928, !10, i64 932, !10, i64 936, !22, i64 940, !10, i64 948, !10, i64 952, !22, i64 956, !7, i64 964, !7, i64 1008, !7, i64 1048, !7, i64 1053, !7, i64 1058, !7, i64 1063, !7, i64 1068, !7, i64 1076, !7, i64 1096, !7, i64 1116, !7, i64 1156, !7, i64 1176, !7, i64 3224, !7, i64 5272, !7, i64 5352, !23, i64 5432, !24, i64 5436, !25, i64 5440}
!22 = !{!"_ZTS6ImVec2", !23, i64 0, !23, i64 4}
!23 = !{!"float", !7, i64 0}
!24 = !{!"short", !7, i64 0}
!25 = !{!"_ZTS8ImVectorItE", !10, i64 0, !10, i64 4, !6, i64 8}
!26 = !{!21, !15, i64 313}
!27 = !{!21, !15, i64 314}
!28 = !{!21, !15, i64 315}


; 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 hidden noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav() local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call noundef ptr @_ZL29ImGui_ImplGlfw_GetBackendDatav()
  %7 = getelementptr inbounds i8, ptr %6, i64 152
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %13, label %9

9:                                                ; preds = %5
  %10 = load ptr, ptr %6, align 8, !tbaa !13
  %11 = icmp eq ptr %10, %0
  br i1 %11, label %12, label %13

12:                                               ; preds = %9
  tail call void %8(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4)
  br label %13

13:                                               ; preds = %12, %9, %5
  %14 = tail call noundef nonnull align 8 dereferenceable(5456) ptr @_ZN5ImGui5GetIOEv()
  %or.cond = icmp ult i32 %1, 512
  br i1 %or.cond, label %15, label %20

15:                                               ; preds = %13
  switch i32 %3, label %20 [
    i32 1, label %.sink.split
    i32 0, label %16
  ]

16:                                               ; preds = %15
  br label %.sink.split

.sink.split:                                      ; preds = %15, %16
  %.sink = phi i8 [ 0, %16 ], [ 1, %15 ]
  %17 = getelementptr inbounds i8, ptr %14, i64 316
  %18 = zext nneg i32 %1 to i64
  %19 = getelementptr inbounds [512 x i8], ptr %17, i64 0, i64 %18
  store i8 %.sink, ptr %19, align 1, !tbaa !14
  br label %20

20:                                               ; preds = %.sink.split, %15, %13
  %21 = getelementptr inbounds i8, ptr %14, i64 312
  %22 = getelementptr inbounds i8, ptr %14, i64 656
  %23 = getelementptr inbounds i8, ptr %14, i64 660
  %24 = load <4 x i8>, ptr %22, align 8, !tbaa !14
  %25 = trunc <4 x i8> %24 to <4 x i1>
  %26 = load <4 x i8>, ptr %23, align 4
  %27 = select <4 x i1> %25, <4 x i8> <i8 1, i8 1, i8 1, i8 1>, <4 x i8> %26
  %28 = shufflevector <4 x i8> %27, <4 x i8> poison, <4 x i32> <i32 1, i32 0, i32 2, i32 3>
  store <4 x i8> %28, ptr %21, align 8, !tbaa !14
  ret void
}

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 = { "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 152}
!6 = !{!"_ZTS19ImGui_ImplGlfw_Data", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !8, i64 32, !8, i64 40, !12, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS13GlfwClientApi", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!12, !12, i64 0}


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