; LLVM IR from BrunoLevy/learn-fpga :: LiteX/software/Libs/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, 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, i8, i32, i32, %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 %struct.ImVec2], [5 x float], [512 x float], [512 x float], [20 x float], [20 x float], float, i8, 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: 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 nounwind uwtable
define dso_local void @_ZN7ImGuiIO14ClearInputKeysEv(ptr noundef nonnull align 8 dereferenceable(5480) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 44
  %7 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %7, i8 0, i64 512, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

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

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

12:                                               ; preds = %8
  %13 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 78
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [512 x float], ptr %13, i64 0, i64 %15
  store float -1.000000e+00, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 77
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [512 x float], ptr %17, i64 0, i64 %19
  store float -1.000000e+00, ptr %20, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %12
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !9
  br label %8, !llvm.loop !13

24:                                               ; preds = %11
  %25 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 43
  store i8 0, ptr %25, align 1, !tbaa !15
  %26 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 42
  store i8 0, ptr %26, align 2, !tbaa !21
  %27 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 41
  store i8 0, ptr %27, align 1, !tbaa !22
  %28 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 40
  store i8 0, ptr %28, align 8, !tbaa !23
  %29 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 62
  store i32 0, ptr %29, align 4, !tbaa !24
  %30 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 61
  store i32 0, ptr %30, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %44, %24
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 20
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %47

35:                                               ; preds = %31
  %36 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 80
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [20 x float], ptr %36, i64 0, i64 %38
  store float -1.000000e+00, ptr %39, align 4, !tbaa !11
  %40 = getelementptr inbounds %struct.ImGuiIO, ptr %5, i32 0, i32 79
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [20 x float], ptr %40, i64 0, i64 %42
  store float -1.000000e+00, ptr %43, align 4, !tbaa !11
  br label %44

44:                                               ; preds = %35
  %45 = load i32, ptr %4, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %4, align 4, !tbaa !9
  br label %31, !llvm.loop !26

47:                                               ; preds = %34
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 = { 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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !18, i64 315}
!16 = !{!"_ZTS7ImGuiIO", !10, i64 0, !10, i64 4, !17, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !7, i64 52, !12, i64 140, !12, i64 144, !6, i64 152, !6, i64 160, !12, i64 168, !18, i64 172, !6, i64 176, !17, i64 184, !18, i64 192, !18, i64 193, !18, i64 194, !18, i64 195, !18, i64 196, !18, i64 197, !12, 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, !17, i64 288, !7, i64 296, !12, i64 304, !12, i64 308, !18, i64 312, !18, i64 313, !18, i64 314, !18, i64 315, !7, i64 316, !7, i64 828, !18, i64 908, !18, i64 909, !18, i64 910, !18, i64 911, !18, i64 912, !18, i64 913, !18, i64 914, !12, i64 916, !10, i64 920, !10, i64 924, !10, i64 928, !10, i64 932, !10, i64 936, !17, i64 940, !18, i64 948, !10, i64 952, !10, i64 956, !17, i64 960, !7, i64 968, !7, i64 1008, !7, i64 1048, !7, i64 1053, !7, i64 1058, !7, i64 1068, !7, i64 1078, !7, i64 1083, !7, i64 1088, !7, i64 1096, !7, i64 1116, !7, i64 1136, !7, i64 1176, !7, i64 1196, !7, i64 3244, !7, i64 5292, !7, i64 5372, !12, i64 5452, !18, i64 5456, !19, i64 5458, !20, i64 5464}
!17 = !{!"_ZTS6ImVec2", !12, i64 0, !12, i64 4}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = !{!"_ZTS8ImVectorItE", !10, i64 0, !10, i64 4, !6, i64 8}
!21 = !{!16, !18, i64 314}
!22 = !{!16, !18, i64 313}
!23 = !{!16, !18, i64 312}
!24 = !{!16, !10, i64 956}
!25 = !{!16, !10, i64 952}
!26 = distinct !{!26, !14}


; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @_ZN7ImGuiIO14ClearInputKeysEv(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(5480) %0) local_unnamed_addr #1 align 2 {
vector.ph:
  %1 = getelementptr inbounds i8, ptr %0, i64 316
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(512) %1, i8 0, i64 512, i1 false)
  %2 = getelementptr inbounds i8, ptr %0, i64 3244
  %3 = getelementptr inbounds i8, ptr %0, i64 1196
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.1, %vector.body ]
  %4 = getelementptr inbounds [512 x float], ptr %2, i64 0, i64 %index
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %4, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds [512 x float], ptr %3, i64 0, i64 %index
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %6, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %7, align 4, !tbaa !5
  %index.next = or disjoint i64 %index, 8
  %8 = getelementptr inbounds [512 x float], ptr %2, i64 0, i64 %index.next
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %8, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds [512 x float], ptr %3, i64 0, i64 %index.next
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %10, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %11, align 4, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 16
  %12 = icmp eq i64 %index.next.1, 512
  br i1 %12, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %13 = getelementptr inbounds i8, ptr %0, i64 312
  %14 = getelementptr inbounds i8, ptr %0, i64 956
  store i32 0, ptr %14, align 4, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %0, i64 952
  store i32 0, ptr %15, align 8, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %0, i64 5372
  %17 = getelementptr inbounds i8, ptr %0, i64 5292
  store i32 0, ptr %13, align 8
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %16, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 5388
  %19 = getelementptr inbounds i8, ptr %0, i64 5308
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %18, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %19, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 5404
  %21 = getelementptr inbounds i8, ptr %0, i64 5324
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %20, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %21, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 5420
  %23 = getelementptr inbounds i8, ptr %0, i64 5340
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %22, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 5436
  %25 = getelementptr inbounds i8, ptr %0, i64 5356
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %24, align 4, !tbaa !5
  store <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, ptr %25, align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind memory(argmem: write) 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = !{!14, !15, i64 956}
!14 = !{!"_ZTS7ImGuiIO", !15, i64 0, !15, i64 4, !16, i64 8, !6, i64 16, !6, i64 20, !17, i64 24, !17, i64 32, !6, i64 40, !6, i64 44, !6, i64 48, !7, i64 52, !6, i64 140, !6, i64 144, !17, i64 152, !17, i64 160, !6, i64 168, !18, i64 172, !17, i64 176, !16, i64 184, !18, i64 192, !18, i64 193, !18, i64 194, !18, i64 195, !18, i64 196, !18, i64 197, !6, i64 200, !17, i64 208, !17, i64 216, !17, i64 224, !17, i64 232, !17, i64 240, !17, i64 248, !17, i64 256, !17, i64 264, !17, i64 272, !17, i64 280, !16, i64 288, !7, i64 296, !6, i64 304, !6, i64 308, !18, i64 312, !18, i64 313, !18, i64 314, !18, i64 315, !7, i64 316, !7, i64 828, !18, i64 908, !18, i64 909, !18, i64 910, !18, i64 911, !18, i64 912, !18, i64 913, !18, i64 914, !6, i64 916, !15, i64 920, !15, i64 924, !15, i64 928, !15, i64 932, !15, i64 936, !16, i64 940, !18, i64 948, !15, i64 952, !15, i64 956, !16, i64 960, !7, i64 968, !7, i64 1008, !7, i64 1048, !7, i64 1053, !7, i64 1058, !7, i64 1068, !7, i64 1078, !7, i64 1083, !7, i64 1088, !7, i64 1096, !7, i64 1116, !7, i64 1136, !7, i64 1176, !7, i64 1196, !7, i64 3244, !7, i64 5292, !7, i64 5372, !6, i64 5452, !18, i64 5456, !19, i64 5458, !20, i64 5464}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS6ImVec2", !6, i64 0, !6, i64 4}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = !{!"_ZTS8ImVectorItE", !15, i64 0, !15, i64 4, !17, i64 8}
!21 = !{!14, !15, i64 952}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass