; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui/imgui.ll (Z10ImHashDataPKvmj)

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

@_ZL17GCrc32LookupTable = external hidden constant [256 x i32], align 16

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z10ImHashDataPKvmj(ptr noundef %0, i64 noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %10 = load i32, ptr %6, align 4, !tbaa !11
  %11 = xor i32 %10, -1
  store i32 %11, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %12, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store ptr @_ZL17GCrc32LookupTable, ptr %9, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %17, %3
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = add i64 %14, -1
  store i64 %15, ptr %5, align 8, !tbaa !9
  %16 = icmp ne i64 %14, 0
  br i1 %16, label %17, label %32

17:                                               ; preds = %13
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = lshr i32 %18, 8
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !11
  %22 = and i32 %21, 255
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i32 1
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = load i8, ptr %23, align 1, !tbaa !13
  %26 = zext i8 %25 to i32
  %27 = xor i32 %22, %26
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %20, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = xor i32 %19, %30
  store i32 %31, ptr %7, align 4, !tbaa !11
  br label %13, !llvm.loop !14

32:                                               ; preds = %13
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = xor i32 %33, -1
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  ret i32 %34
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@_ZL17GCrc32LookupTable = external hidden local_unnamed_addr constant [256 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i32 @_Z10ImHashDataPKvmj(ptr nocapture noundef readonly %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not9 = icmp eq i64 %1, 0
  br i1 %.not9, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %4 = xor i32 %2, -1
  %xtraiter = and i64 %1, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %5 = add nsw i64 %1, -1
  %6 = lshr i32 %4, 8
  %7 = and i32 %4, 255
  %8 = getelementptr inbounds i8, ptr %0, i64 1
  %9 = load i8, ptr %0, align 1, !tbaa !5
  %10 = zext i8 %9 to i32
  %11 = xor i32 %7, %10
  %12 = zext nneg i32 %11 to i64
  %13 = getelementptr inbounds i32, ptr @_ZL17GCrc32LookupTable, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !8
  %15 = xor i32 %14, %6
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.lcssa.unr = phi i32 [ poison, %.lr.ph.preheader ], [ %15, %.lr.ph.prol ]
  %.012.unr = phi i64 [ %1, %.lr.ph.preheader ], [ %5, %.lr.ph.prol ]
  %.0711.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %8, %.lr.ph.prol ]
  %.0810.unr = phi i32 [ %4, %.lr.ph.preheader ], [ %15, %.lr.ph.prol ]
  %16 = icmp eq i64 %1, 1
  br i1 %16, label %._crit_edge.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.012 = phi i64 [ %27, %.lr.ph ], [ %.012.unr, %.lr.ph.prol.loopexit ]
  %.0711 = phi ptr [ %30, %.lr.ph ], [ %.0711.unr, %.lr.ph.prol.loopexit ]
  %.0810 = phi i32 [ %37, %.lr.ph ], [ %.0810.unr, %.lr.ph.prol.loopexit ]
  %17 = lshr i32 %.0810, 8
  %18 = and i32 %.0810, 255
  %19 = getelementptr inbounds i8, ptr %.0711, i64 1
  %20 = load i8, ptr %.0711, align 1, !tbaa !5
  %21 = zext i8 %20 to i32
  %22 = xor i32 %18, %21
  %23 = zext nneg i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr @_ZL17GCrc32LookupTable, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !8
  %26 = xor i32 %25, %17
  %27 = add i64 %.012, -2
  %28 = lshr i32 %26, 8
  %29 = and i32 %26, 255
  %30 = getelementptr inbounds i8, ptr %.0711, i64 2
  %31 = load i8, ptr %19, align 1, !tbaa !5
  %32 = zext i8 %31 to i32
  %33 = xor i32 %29, %32
  %34 = zext nneg i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr @_ZL17GCrc32LookupTable, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !8
  %37 = xor i32 %36, %28
  %.not.1 = icmp eq i64 %27, 0
  br i1 %.not.1, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !10

._crit_edge.loopexit:                             ; preds = %.lr.ph, %.lr.ph.prol.loopexit
  %.lcssa = phi i32 [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %37, %.lr.ph ]
  %38 = xor i32 %.lcssa, -1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.08.lcssa = phi i32 [ %2, %3 ], [ %38, %._crit_edge.loopexit ]
  ret i32 %.08.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass