; LLVM IR from Angelo1211/HybridRenderingEngine :: src/inputManager.ll (ZN12InputManager12processInputERbj)

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

%union.SDL_Event = type { %struct.SDL_TouchFingerEvent, [8 x i8] }
%struct.SDL_TouchFingerEvent = type { i32, i32, i64, i64, float, float, float, float, float }
%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, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, %struct.ImVec2, [5 x i8], float, float, i8, i8, i8, i8, [512 x i8], [17 x i16], [21 x float], i8, i8, i8, i8, i8, i8, i8, float, i32, i32, i32, i32, i32, %struct.ImVec2, %struct.ImVec2, [5 x %struct.ImVec2], [5 x double], [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 }
%class.InputManager = type { ptr, ptr }
%struct.Camera = type <{ %"struct.glm::mat", %"struct.glm::mat", %struct.Frustum, %"class.std::set", %"struct.glm::vec", %"struct.glm::vec", %"struct.glm::vec", %"struct.glm::vec", float, float, %"struct.glm::vec", %"struct.glm::vec", %"struct.glm::vec", %"struct.glm::vec", %"struct.glm::vec", float, float, float, float, float, i32, [4 x i8] }>
%"struct.glm::mat" = type { [4 x %"struct.glm::vec.3"] }
%"struct.glm::vec.3" = type { %union.anon.4 }
%union.anon.4 = type { %struct.anon.5 }
%struct.anon.5 = type { float, float, float, float }
%struct.Frustum = type { [6 x %struct.Plane], float, float, float, float, float, float }
%struct.Plane = type { %"struct.glm::vec", float }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<char, char, std::_Identity<char>, std::less<char>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<char, char, std::_Identity<char>, std::less<char>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.glm::vec" = type { %union.anon.0 }
%union.anon.0 = type { %struct.anon }
%struct.anon = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12InputManager12processInputERbj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 1 dereferenceable(1) %1, i32 noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %union.SDL_Event, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = call noundef nonnull align 8 dereferenceable(5432) ptr @_ZN5ImGui5GetIOEv()
  store ptr %11, ptr %8, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %39, %3
  %13 = call i32 @SDL_PollEvent(ptr noundef %7)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %40

15:                                               ; preds = %12
  %16 = load i32, ptr %7, align 8, !tbaa !11
  %17 = icmp eq i32 %16, 256
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 1, ptr %19, align 1, !tbaa !12
  store i32 1, ptr %9, align 4
  br label %41

20:                                               ; preds = %15
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ImGuiIO, ptr %21, i32 0, i32 43
  %23 = load i8, ptr %22, align 1, !tbaa !14, !range !18, !noundef !19
  %24 = trunc i8 %23 to i1
  br i1 %24, label %30, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ImGuiIO, ptr %26, i32 0, i32 42
  %28 = load i8, ptr %27, align 4, !tbaa !20, !range !18, !noundef !19
  %29 = trunc i8 %28 to i1
  br i1 %29, label %30, label %35

30:                                               ; preds = %25, %20
  %31 = getelementptr inbounds %class.InputManager, ptr %10, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  %33 = getelementptr inbounds %struct.Camera, ptr %32, i32 0, i32 3
  call void @_ZNSt3setIcSt4lessIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) %33) #4
  %34 = call noundef zeroext i1 @_Z27ImGui_ImplSDL2_ProcessEventP9SDL_Event(ptr noundef %7)
  br label %38

35:                                               ; preds = %25
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN12InputManager11handleEventEP9SDL_EventRbj(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef %7, ptr noundef nonnull align 1 dereferenceable(1) %36, i32 noundef %37)
  br label %38

38:                                               ; preds = %35, %30
  br label %39

39:                                               ; preds = %38
  br label %12, !llvm.loop !23

40:                                               ; preds = %12
  store i32 0, ptr %9, align 4
  br label %41

41:                                               ; preds = %40, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 56, ptr %7) #4
  %42 = load i32, ptr %9, align 4
  switch i32 %42, label %44 [
    i32 0, label %43
    i32 1, label %43
  ]

43:                                               ; preds = %41, %41
  ret void

44:                                               ; preds = %41
  unreachable
}

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

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

declare i32 @SDL_PollEvent(ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIcSt4lessIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

declare noundef zeroext i1 @_Z27ImGui_ImplSDL2_ProcessEventP9SDL_Event(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12InputManager11handleEventEP9SDL_EventRbj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #0 align 2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!15, !13, i64 917}
!15 = !{!"_ZTS7ImGuiIO", !10, i64 0, !10, i64 4, !16, i64 8, !17, i64 16, !17, i64 20, !6, i64 24, !6, i64 32, !17, i64 40, !17, i64 44, !17, i64 48, !7, i64 52, !17, i64 136, !17, i64 140, !6, i64 144, !6, i64 152, !17, i64 160, !13, i64 164, !6, i64 168, !16, i64 176, !16, i64 184, !16, i64 192, !13, i64 200, !13, i64 201, !13, i64 202, !13, i64 203, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !16, i64 256, !7, i64 264, !17, i64 272, !17, i64 276, !13, i64 280, !13, i64 281, !13, i64 282, !13, i64 283, !7, i64 284, !7, i64 796, !7, i64 832, !13, i64 916, !13, i64 917, !13, i64 918, !13, i64 919, !13, i64 920, !13, i64 921, !13, i64 922, !17, i64 924, !10, i64 928, !10, i64 932, !10, i64 936, !10, i64 940, !10, i64 944, !16, i64 948, !16, 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 1088, !7, i64 1108, !7, i64 1148, !7, i64 1168, !7, i64 3216, !7, i64 5264, !7, i64 5348}
!16 = !{!"_ZTS6ImVec2", !17, i64 0, !17, i64 4}
!17 = !{!"float", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!15, !13, i64 916}
!21 = !{!22, !6, i64 8}
!22 = !{!"_ZTS12InputManager", !6, i64 0, !6, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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

%union.SDL_Event = type { %struct.SDL_TouchFingerEvent, [8 x i8] }
%struct.SDL_TouchFingerEvent = type { i32, i32, i64, i64, float, float, float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12InputManager12processInputERbj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 1 dereferenceable(1) %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %union.SDL_Event, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %4) #4
  %5 = tail call noundef nonnull align 8 dereferenceable(5432) ptr @_ZN5ImGui5GetIOEv()
  %6 = call i32 @SDL_PollEvent(ptr noundef nonnull %4)
  %.not5 = icmp eq i32 %6, 0
  br i1 %.not5, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %5, i64 917
  %8 = getelementptr inbounds i8, ptr %5, i64 916
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  br label %10

10:                                               ; preds = %.lr.ph, %25
  %11 = load i32, ptr %4, align 8, !tbaa !5
  %12 = icmp eq i32 %11, 256
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  store i8 1, ptr %1, align 1, !tbaa !8
  br label %.loopexit

14:                                               ; preds = %10
  %15 = load i8, ptr %7, align 1, !tbaa !10, !range !16, !noundef !17
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %20, label %17

17:                                               ; preds = %14
  %18 = load i8, ptr %8, align 4, !tbaa !18, !range !16, !noundef !17
  %19 = trunc nuw i8 %18 to i1
  br i1 %19, label %20, label %24

20:                                               ; preds = %17, %14
  %21 = load ptr, ptr %9, align 8, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %21, i64 248
  call void @_ZNSt3setIcSt4lessIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) %22) #4
  %23 = call noundef zeroext i1 @_Z27ImGui_ImplSDL2_ProcessEventP9SDL_Event(ptr noundef nonnull %4)
  br label %25

24:                                               ; preds = %17
  call void @_ZN12InputManager11handleEventEP9SDL_EventRbj(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %4, ptr noundef nonnull align 1 dereferenceable(1) %1, i32 noundef %2)
  br label %25

25:                                               ; preds = %20, %24
  %26 = call i32 @SDL_PollEvent(ptr noundef nonnull %4)
  %.not = icmp eq i32 %26, 0
  br i1 %.not, label %.loopexit, label %10, !llvm.loop !21

.loopexit:                                        ; preds = %25, %3, %13
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #4
  ret void
}

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

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

declare i32 @SDL_PollEvent(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIcSt4lessIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #3 align 2

declare noundef zeroext i1 @_Z27ImGui_ImplSDL2_ProcessEventP9SDL_Event(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12InputManager11handleEventEP9SDL_EventRbj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #0 align 2

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"bool", !6, i64 0}
!10 = !{!11, !9, i64 917}
!11 = !{!"_ZTS7ImGuiIO", !12, i64 0, !12, i64 4, !13, i64 8, !14, i64 16, !14, i64 20, !15, i64 24, !15, i64 32, !14, i64 40, !14, i64 44, !14, i64 48, !6, i64 52, !14, i64 136, !14, i64 140, !15, i64 144, !15, i64 152, !14, i64 160, !9, i64 164, !15, i64 168, !13, i64 176, !13, i64 184, !13, i64 192, !9, i64 200, !9, i64 201, !9, i64 202, !9, i64 203, !15, i64 208, !15, i64 216, !15, i64 224, !15, i64 232, !15, i64 240, !15, i64 248, !13, i64 256, !6, i64 264, !14, i64 272, !14, i64 276, !9, i64 280, !9, i64 281, !9, i64 282, !9, i64 283, !6, i64 284, !6, i64 796, !6, i64 832, !9, i64 916, !9, i64 917, !9, i64 918, !9, i64 919, !9, i64 920, !9, i64 921, !9, i64 922, !14, i64 924, !12, i64 928, !12, i64 932, !12, i64 936, !12, i64 940, !12, i64 944, !13, i64 948, !13, i64 956, !6, i64 964, !6, i64 1008, !6, i64 1048, !6, i64 1053, !6, i64 1058, !6, i64 1063, !6, i64 1068, !6, i64 1088, !6, i64 1108, !6, i64 1148, !6, i64 1168, !6, i64 3216, !6, i64 5264, !6, i64 5348}
!12 = !{!"int", !6, i64 0}
!13 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !6, i64 0}
!15 = !{!"any pointer", !6, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!11, !9, i64 916}
!19 = !{!20, !15, i64 8}
!20 = !{!"_ZTS12InputManager", !15, i64 0, !15, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass