; LLVM IR from p4lang/p4c :: backends/tofino/bf-utils/dynamic_hash (dynamic_hash)

; 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.hash_column_ = type { i64, i8 }

; 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 void @_Z21initialize_matrix_bitPA52_12hash_column_jjb(ptr noundef %0, i32 noundef %1, i32 noundef %2, i1 noundef zeroext %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = udiv i32 %14, 64
  store i32 %15, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %16 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %16, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = urem i32 %17, 64
  store i32 %18, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %19 = load i32, ptr %11, align 4, !tbaa !9
  %20 = udiv i32 %19, 8
  store i32 %20, ptr %12, align 4, !tbaa !9
  %21 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %22 = trunc i8 %21 to i1
  br i1 %22, label %23, label %37

23:                                               ; preds = %4
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = shl i64 1, %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [52 x %struct.hash_column_], ptr %27, i64 %29
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds [52 x %struct.hash_column_], ptr %30, i64 0, i64 %32
  %34 = getelementptr inbounds %struct.hash_column_, ptr %33, i32 0, i32 0
  %35 = load i64, ptr %34, align 8, !tbaa !15
  %36 = or i64 %35, %26
  store i64 %36, ptr %34, align 8, !tbaa !15
  br label %37

37:                                               ; preds = %23, %4
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = shl i64 1, %39
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds [52 x %struct.hash_column_], ptr %41, i64 %43
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds [52 x %struct.hash_column_], ptr %44, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.hash_column_, ptr %47, i32 0, i32 1
  %49 = load i8, ptr %48, align 8, !tbaa !18
  %50 = zext i8 %49 to i64
  %51 = or i64 %50, %40
  %52 = trunc i64 %51 to i8
  store i8 %52, ptr %48, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret void
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTS12hash_column_", !17, i64 0, !7, i64 8}
!17 = !{!"long", !7, i64 0}
!18 = !{!16, !7, i64 8}


; 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.hash_column_ = type { i64, i8 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_Z21initialize_matrix_bitPA52_12hash_column_jjb(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = lshr i32 %1, 6
  %6 = and i32 %1, 63
  br i1 %3, label %7, label %._crit_edge

._crit_edge:                                      ; preds = %4
  %.pre = zext nneg i32 %5 to i64
  %.pre12 = zext i32 %2 to i64
  br label %15

7:                                                ; preds = %4
  %8 = zext nneg i32 %6 to i64
  %9 = shl nuw i64 1, %8
  %10 = zext nneg i32 %5 to i64
  %11 = zext i32 %2 to i64
  %12 = getelementptr inbounds [52 x %struct.hash_column_], ptr %0, i64 %10, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = or i64 %13, %9
  store i64 %14, ptr %12, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %._crit_edge, %7
  %.pre-phi13 = phi i64 [ %.pre12, %._crit_edge ], [ %11, %7 ]
  %.pre-phi = phi i64 [ %.pre, %._crit_edge ], [ %10, %7 ]
  %16 = lshr i32 %6, 3
  %17 = trunc nuw nsw i32 %16 to i8
  %18 = shl nuw i8 1, %17
  %19 = getelementptr inbounds [52 x %struct.hash_column_], ptr %0, i64 %.pre-phi, i64 %.pre-phi13, i32 1
  %20 = load i8, ptr %19, align 8, !tbaa !10
  %21 = or i8 %20, %18
  store i8 %21, ptr %19, align 8, !tbaa !10
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = !{!"_ZTS12hash_column_", !7, i64 0, !8, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !8, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass