; LLVM IR from aap/librw :: skeleton/imgui/imgui.ll (ZN7ImGuiIO14ClearInputKeysEv)

; 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, ptr, ptr, float, i8, [3 x i8], ptr, %struct.ImVec2, i8, i8, i8, i8, i8, i8, i8, i8, i8, [3 x i8], float, float, float, float, float, float, i8, i8, i8, i8, i8, [7 x i8], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i16, i8, i8, i8, i8, i8, i8, i8, [3 x i8], float, i32, i32, i32, i32, %struct.ImVec2, ptr, %struct.ImVec2, [5 x i8], [3 x i8], float, float, i32, i8, i8, i8, i8, i32, [666 x %struct.ImGuiKeyData], i8, [3 x 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], i8, i8, i8, [5 x float], [5 x float], [5 x float], float, i8, i8, i8, i8, i16, [2 x i8], %struct.ImVector, [666 x i32], [666 x i8], [2 x i8], [16 x float], [4 x i8] }>
%struct.ImGuiKeyData = type { i8, float, float, float }
%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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO14ClearInputKeysEv(ptr noundef nonnull align 8 dereferenceable(14580) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 102
  %6 = getelementptr inbounds [666 x i8], ptr %5, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 666, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %32, %1
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 666
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %35

11:                                               ; preds = %7
  %12 = load i32, ptr %3, align 4, !tbaa !9
  %13 = add nsw i32 %12, 0
  %14 = call noundef zeroext i1 @_ZN5ImGui10IsMouseKeyE8ImGuiKey(i32 noundef %13)
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  br label %32

16:                                               ; preds = %11
  %17 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 74
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [666 x %struct.ImGuiKeyData], ptr %17, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.ImGuiKeyData, ptr %20, i32 0, i32 0
  store i8 0, ptr %21, align 4, !tbaa !11
  %22 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 74
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [666 x %struct.ImGuiKeyData], ptr %22, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.ImGuiKeyData, ptr %25, i32 0, i32 1
  store float -1.000000e+00, ptr %26, align 4, !tbaa !15
  %27 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 74
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [666 x %struct.ImGuiKeyData], ptr %27, i64 0, i64 %29
  %31 = getelementptr inbounds %struct.ImGuiKeyData, ptr %30, i32 0, i32 2
  store float -1.000000e+00, ptr %31, align 4, !tbaa !16
  br label %32

32:                                               ; preds = %16, %15
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !17

35:                                               ; preds = %10
  %36 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 72
  store i8 0, ptr %36, align 1, !tbaa !19
  %37 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 71
  store i8 0, ptr %37, align 2, !tbaa !25
  %38 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 70
  store i8 0, ptr %38, align 1, !tbaa !26
  %39 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 69
  store i8 0, ptr %39, align 4, !tbaa !27
  %40 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 73
  store i32 0, ptr %40, align 8, !tbaa !28
  %41 = getelementptr inbounds %struct.ImGuiIO, ptr %4, i32 0, i32 100
  call void @_ZN8ImVectorItE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16) %41, i32 noundef 0)
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5ImGui10IsMouseKeyE8ImGuiKey(i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorItE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 = { inlinehint 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 #5 = { 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, !13, i64 0}
!12 = !{!"_ZTS12ImGuiKeyData", !13, i64 0, !14, i64 4, !14, i64 8, !14, i64 12}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !14, i64 4}
!16 = !{!12, !14, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !13, i64 295}
!20 = !{!"_ZTS7ImGuiIO", !10, i64 0, !10, i64 4, !21, i64 8, !14, i64 16, !14, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 56, !13, i64 60, !6, i64 64, !21, i64 72, !13, i64 80, !13, i64 81, !13, i64 82, !13, i64 83, !13, i64 84, !13, i64 85, !13, i64 86, !13, i64 87, !13, i64 88, !14, i64 92, !14, i64 96, !14, i64 100, !14, i64 104, !14, i64 108, !14, i64 112, !13, i64 116, !13, i64 117, !13, i64 118, !13, i64 119, !13, 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, !6, i64 200, !6, i64 208, !22, i64 216, !13, i64 218, !13, i64 219, !13, i64 220, !13, i64 221, !13, i64 222, !13, i64 223, !13, i64 224, !14, i64 228, !10, i64 232, !10, i64 236, !10, i64 240, !10, i64 244, !21, i64 248, !6, i64 256, !21, i64 264, !7, i64 272, !14, i64 280, !14, i64 284, !23, i64 288, !13, i64 292, !13, i64 293, !13, i64 294, !13, i64 295, !10, i64 296, !7, i64 300, !13, i64 10956, !21, i64 10960, !7, i64 10968, !7, i64 11008, !7, i64 11048, !7, i64 11053, !7, i64 11058, !7, i64 11068, !7, i64 11078, !7, i64 11083, !7, i64 11088, !13, i64 11093, !13, i64 11094, !7, i64 11096, !7, i64 11116, !7, i64 11136, !14, i64 11156, !13, i64 11160, !13, i64 11161, !7, i64 11162, !13, i64 11163, !22, i64 11164, !24, i64 11168, !7, i64 11184, !7, i64 13848, !7, i64 14516}
!21 = !{!"_ZTS6ImVec2", !14, i64 0, !14, i64 4}
!22 = !{!"short", !7, i64 0}
!23 = !{!"_ZTS16ImGuiMouseSource", !7, i64 0}
!24 = !{!"_ZTS8ImVectorItE", !10, i64 0, !10, i64 4, !6, i64 8}
!25 = !{!20, !13, i64 294}
!26 = !{!20, !13, i64 293}
!27 = !{!20, !13, i64 292}
!28 = !{!20, !10, i64 296}


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

%struct.ImGuiKeyData = type { i8, float, float, float }

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7ImGuiIO14ClearInputKeysEv(ptr noundef nonnull align 8 dereferenceable(14580) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 13848
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(666) %2, i8 0, i64 666, i1 false)
  %3 = getelementptr inbounds i8, ptr %0, i64 300
  br label %7

4:                                                ; preds = %13
  %5 = getelementptr inbounds i8, ptr %0, i64 292
  %6 = getelementptr inbounds i8, ptr %0, i64 11168
  store i64 0, ptr %5, align 4
  tail call void @_ZN8ImVectorItE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef 0)
  ret void

7:                                                ; preds = %1, %13
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %13 ]
  %8 = trunc nuw nsw i64 %indvars.iv to i32
  %9 = tail call noundef zeroext i1 @_ZN5ImGui10IsMouseKeyE8ImGuiKey(i32 noundef %8)
  br i1 %9, label %13, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds [666 x %struct.ImGuiKeyData], ptr %3, i64 0, i64 %indvars.iv
  store i8 0, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 4
  store <2 x float> <float -1.000000e+00, float -1.000000e+00>, ptr %12, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %7, %10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 666
  br i1 %exitcond.not, label %4, label %7, !llvm.loop !12
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5ImGui10IsMouseKeyE8ImGuiKey(i32 noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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 = { inlinehint 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, !7, i64 0}
!6 = !{!"_ZTS12ImGuiKeyData", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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