; LLVM IR from Eukky/TRender :: RenderCore/Gui/Imgui/ImguiGLFW.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.ImGuiIO = type { i32, i32, %struct.ImVec2, float, float, ptr, ptr, float, float, float, [21 x i32], float, float, ptr, ptr, float, i8, ptr, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, %struct.ImVec2, [5 x i8], float, float, i8, i8, i8, i8, i8, [512 x i8], [17 x i16], [21 x float], i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, %struct.ImVec2, %struct.ImVec2, [5 x %struct.ImVec2], [5 x float], [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], [21 x float], [21 x float] }
%struct.ImVec2 = type { float, float }

; 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(5400) ptr @_ZN5ImGui5GetIOEv() #1

; 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 @_Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #2 {
  %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
  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
  %12 = call noundef nonnull align 8 dereferenceable(5400) ptr @_ZN5ImGui5GetIOEv()
  store ptr %12, ptr %11, align 8, !tbaa !5
  %13 = load i32, ptr %9, align 4, !tbaa !9
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %21

15:                                               ; preds = %5
  %16 = load ptr, ptr %11, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ImGuiIO, ptr %16, i32 0, i32 38
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [512 x i8], ptr %17, i64 0, i64 %19
  store i8 1, ptr %20, align 1, !tbaa !11
  br label %21

21:                                               ; preds = %15, %5
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %21
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ImGuiIO, ptr %25, i32 0, i32 38
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [512 x i8], ptr %26, i64 0, i64 %28
  store i8 0, ptr %29, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %24, %21
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ImGuiIO, ptr %31, i32 0, i32 38
  %33 = getelementptr inbounds [512 x i8], ptr %32, i64 0, i64 341
  %34 = load i8, ptr %33, align 1, !tbaa !11, !range !13, !noundef !14
  %35 = trunc i8 %34 to i1
  br i1 %35, label %42, label %36

36:                                               ; preds = %30
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ImGuiIO, ptr %37, i32 0, i32 38
  %39 = getelementptr inbounds [512 x i8], ptr %38, i64 0, i64 345
  %40 = load i8, ptr %39, align 1, !tbaa !11, !range !13, !noundef !14
  %41 = trunc i8 %40 to i1
  br label %42

42:                                               ; preds = %36, %30
  %43 = phi i1 [ true, %30 ], [ %41, %36 ]
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ImGuiIO, ptr %44, i32 0, i32 34
  %46 = zext i1 %43 to i8
  store i8 %46, ptr %45, align 1, !tbaa !15
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ImGuiIO, ptr %47, i32 0, i32 38
  %49 = getelementptr inbounds [512 x i8], ptr %48, i64 0, i64 340
  %50 = load i8, ptr %49, align 1, !tbaa !11, !range !13, !noundef !14
  %51 = trunc i8 %50 to i1
  br i1 %51, label %58, label %52

52:                                               ; preds = %42
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ImGuiIO, ptr %53, i32 0, i32 38
  %55 = getelementptr inbounds [512 x i8], ptr %54, i64 0, i64 344
  %56 = load i8, ptr %55, align 1, !tbaa !11, !range !13, !noundef !14
  %57 = trunc i8 %56 to i1
  br label %58

58:                                               ; preds = %52, %42
  %59 = phi i1 [ true, %42 ], [ %57, %52 ]
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ImGuiIO, ptr %60, i32 0, i32 35
  %62 = zext i1 %59 to i8
  store i8 %62, ptr %61, align 2, !tbaa !19
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ImGuiIO, ptr %63, i32 0, i32 38
  %65 = getelementptr inbounds [512 x i8], ptr %64, i64 0, i64 342
  %66 = load i8, ptr %65, align 1, !tbaa !11, !range !13, !noundef !14
  %67 = trunc i8 %66 to i1
  br i1 %67, label %74, label %68

68:                                               ; preds = %58
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ImGuiIO, ptr %69, i32 0, i32 38
  %71 = getelementptr inbounds [512 x i8], ptr %70, i64 0, i64 346
  %72 = load i8, ptr %71, align 1, !tbaa !11, !range !13, !noundef !14
  %73 = trunc i8 %72 to i1
  br label %74

74:                                               ; preds = %68, %58
  %75 = phi i1 [ true, %58 ], [ %73, %68 ]
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ImGuiIO, ptr %76, i32 0, i32 36
  %78 = zext i1 %75 to i8
  store i8 %78, ptr %77, align 1, !tbaa !20
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ImGuiIO, ptr %79, i32 0, i32 38
  %81 = getelementptr inbounds [512 x i8], ptr %80, i64 0, i64 343
  %82 = load i8, ptr %81, align 1, !tbaa !11, !range !13, !noundef !14
  %83 = trunc i8 %82 to i1
  br i1 %83, label %90, label %84

84:                                               ; preds = %74
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ImGuiIO, ptr %85, i32 0, i32 38
  %87 = getelementptr inbounds [512 x i8], ptr %86, i64 0, i64 347
  %88 = load i8, ptr %87, align 1, !tbaa !11, !range !13, !noundef !14
  %89 = trunc i8 %88 to i1
  br label %90

90:                                               ; preds = %84, %74
  %91 = phi i1 [ true, %74 ], [ %89, %84 ]
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.ImGuiIO, ptr %92, i32 0, i32 37
  %94 = zext i1 %91 to i8
  store i8 %94, ptr %93, align 4, !tbaa !21
  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 = { "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 = { 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 = !{!16, !12, i64 281}
!16 = !{!"_ZTS7ImGuiIO", !10, i64 0, !10, i64 4, !17, i64 8, !18, i64 16, !18, i64 20, !6, i64 24, !6, i64 32, !18, i64 40, !18, i64 44, !18, i64 48, !7, i64 52, !18, i64 136, !18, i64 140, !6, i64 144, !6, i64 152, !18, i64 160, !12, i64 164, !6, i64 168, !17, i64 176, !17, i64 184, !17, i64 192, !12, i64 200, !12, i64 201, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !17, i64 256, !7, i64 264, !18, i64 272, !18, i64 276, !12, i64 280, !12, i64 281, !12, i64 282, !12, i64 283, !12, i64 284, !7, i64 285, !7, i64 798, !7, i64 832, !12, i64 916, !12, i64 917, !12, i64 918, !12, i64 919, !12, i64 920, !12, i64 921, !12, i64 922, !18, i64 924, !10, i64 928, !10, i64 932, !10, i64 936, !17, i64 940, !17, i64 948, !7, i64 956, !7, i64 996, !7, i64 1016, !7, i64 1021, !7, i64 1026, !7, i64 1031, !7, i64 1036, !7, i64 1056, !7, i64 1076, !7, i64 1116, !7, i64 1136, !7, i64 3184, !7, i64 5232, !7, i64 5316}
!17 = !{!"_ZTS6ImVec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !7, i64 0}
!19 = !{!16, !12, i64 282}
!20 = !{!16, !12, i64 283}
!21 = !{!16, !12, i64 284}


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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z26ImGui_ImplGlfw_KeyCallbackP10GLFWwindowiiii(ptr nocapture noundef readnone %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = tail call noundef nonnull align 8 dereferenceable(5400) ptr @_ZN5ImGui5GetIOEv()
  switch i32 %3, label %11 [
    i32 1, label %.sink.split
    i32 0, label %7
  ]

7:                                                ; preds = %5
  br label %.sink.split

.sink.split:                                      ; preds = %5, %7
  %.sink = phi i8 [ 0, %7 ], [ 1, %5 ]
  %8 = getelementptr inbounds i8, ptr %6, i64 285
  %9 = sext i32 %1 to i64
  %10 = getelementptr inbounds [512 x i8], ptr %8, i64 0, i64 %9
  store i8 %.sink, ptr %10, align 1, !tbaa !5
  br label %11

11:                                               ; preds = %.sink.split, %5
  %12 = getelementptr inbounds i8, ptr %6, i64 281
  %13 = getelementptr inbounds i8, ptr %6, i64 625
  %14 = getelementptr inbounds i8, ptr %6, i64 629
  %15 = load <4 x i8>, ptr %13, align 1, !tbaa !5
  %16 = trunc <4 x i8> %15 to <4 x i1>
  %17 = load <4 x i8>, ptr %14, align 1
  %18 = select <4 x i1> %16, <4 x i8> <i8 1, i8 1, i8 1, i8 1>, <4 x i8> %17
  %19 = shufflevector <4 x i8> %18, <4 x i8> poison, <4 x i32> <i32 1, i32 0, i32 2, i32 3>
  store <4 x i8> %19, ptr %12, align 1, !tbaa !5
  ret void
}

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

!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"}


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