; 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.bfn_hash_algorithm_ = type { i32, i8, i8, i32, i32, i8, i64, i64, i64, ptr }
%struct.ixbar_input_ = type { i32, i32, i32, %struct.hash_symmetric_info_, %union.anon }
%struct.hash_symmetric_info_ = type { i8, i32, i32 }
%union.anon = type { i64 }

; 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
declare dso_local void @_Z15set_into_bitvecPmjmjj(ptr noundef, i32 noundef, i64 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z28initialize_input_data_streamPK19bfn_hash_algorithm_PmjPK12ixbar_input_j(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.bfn_hash_algorithm_, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %31

25:                                               ; preds = %5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.bfn_hash_algorithm_, ptr %26, i32 0, i32 4
  %28 = load i32, ptr %27, align 4, !tbaa !17
  %29 = load i32, ptr %11, align 4, !tbaa !9
  %30 = add nsw i32 %29, %28
  store i32 %30, ptr %11, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %25, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %115, %31
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %118

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds %struct.ixbar_input_, ptr %38, i64 %40
  store ptr %41, ptr %14, align 8, !tbaa !5
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ixbar_input_, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !18
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %109

46:                                               ; preds = %37
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.bfn_hash_algorithm_, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = icmp eq i32 %49, 1
  br i1 %50, label %51, label %95

51:                                               ; preds = %46
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.bfn_hash_algorithm_, ptr %52, i32 0, i32 5
  %54 = load i8, ptr %53, align 8, !tbaa !22, !range !23, !noundef !24
  %55 = trunc i8 %54 to i1
  br i1 %55, label %56, label %95

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %91, %56
  %58 = load i32, ptr %15, align 4, !tbaa !9
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ixbar_input_, ptr %59, i32 0, i32 2
  %61 = load i32, ptr %60, align 8, !tbaa !25
  %62 = icmp ult i32 %58, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %57
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %94

64:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = add i32 %65, %66
  store i32 %67, ptr %16, align 4, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.bfn_hash_algorithm_, ptr %68, i32 0, i32 4
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = load i32, ptr %16, align 4, !tbaa !9
  %72 = sub i32 %71, %70
  store i32 %72, ptr %16, align 4, !tbaa !9
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = xor i32 %73, 7
  store i32 %74, ptr %16, align 4, !tbaa !9
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.bfn_hash_algorithm_, ptr %75, i32 0, i32 4
  %77 = load i32, ptr %76, align 4, !tbaa !17
  %78 = load i32, ptr %16, align 4, !tbaa !9
  %79 = add i32 %78, %77
  store i32 %79, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ixbar_input_, ptr %80, i32 0, i32 4
  %82 = load i64, ptr %81, align 8, !tbaa !26
  %83 = load i32, ptr %15, align 4, !tbaa !9
  %84 = zext i32 %83 to i64
  %85 = lshr i64 %82, %84
  %86 = and i64 %85, 1
  store i64 %86, ptr %17, align 8, !tbaa !27
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = load i64, ptr %17, align 8, !tbaa !27
  %90 = load i32, ptr %16, align 4, !tbaa !9
  call void @_Z15set_into_bitvecPmjmjj(ptr noundef %87, i32 noundef %88, i64 noundef %89, i32 noundef %90, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  br label %91

91:                                               ; preds = %64
  %92 = load i32, ptr %15, align 4, !tbaa !9
  %93 = add i32 %92, 1
  store i32 %93, ptr %15, align 4, !tbaa !9
  br label %57, !llvm.loop !28

94:                                               ; preds = %63
  br label %108

95:                                               ; preds = %51, %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %96 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %96, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.ixbar_input_, ptr %97, i32 0, i32 2
  %99 = load i32, ptr %98, align 8, !tbaa !25
  store i32 %99, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #2
  %100 = load ptr, ptr %14, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.ixbar_input_, ptr %100, i32 0, i32 4
  %102 = load i64, ptr %101, align 8, !tbaa !26
  store i64 %102, ptr %20, align 8, !tbaa !27
  %103 = load ptr, ptr %7, align 8, !tbaa !5
  %104 = load i32, ptr %8, align 4, !tbaa !9
  %105 = load i64, ptr %20, align 8, !tbaa !27
  %106 = load i32, ptr %18, align 4, !tbaa !9
  %107 = load i32, ptr %19, align 4, !tbaa !9
  call void @_Z15set_into_bitvecPmjmjj(ptr noundef %103, i32 noundef %104, i64 noundef %105, i32 noundef %106, i32 noundef %107)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  br label %108

108:                                              ; preds = %95, %94
  br label %109

109:                                              ; preds = %108, %37
  %110 = load ptr, ptr %14, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.ixbar_input_, ptr %110, i32 0, i32 2
  %112 = load i32, ptr %111, align 8, !tbaa !25
  %113 = load i32, ptr %11, align 4, !tbaa !9
  %114 = add i32 %113, %112
  store i32 %114, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %115

115:                                              ; preds = %109
  %116 = load i32, ptr %12, align 4, !tbaa !9
  %117 = add i32 %116, 1
  store i32 %117, ptr %12, align 4, !tbaa !9
  br label %32, !llvm.loop !30

118:                                              ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #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, !13, i64 0}
!12 = !{!"_ZTS19bfn_hash_algorithm_", !13, i64 0, !14, i64 4, !14, i64 5, !15, i64 8, !10, i64 12, !14, i64 16, !16, i64 24, !16, i64 32, !16, i64 40, !6, i64 48}
!13 = !{!"_ZTS19bfn_hash_alg_type_t", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTS13bfn_crc_alg_t", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!12, !10, i64 12}
!18 = !{!19, !20, i64 0}
!19 = !{!"_ZTS12ixbar_input_", !20, i64 0, !10, i64 4, !10, i64 8, !21, i64 12, !7, i64 24}
!20 = !{!"_ZTS16ixbar_input_type", !7, i64 0}
!21 = !{!"_ZTS20hash_symmetric_info_", !14, i64 0, !10, i64 4, !10, i64 8}
!22 = !{!12, !14, i64 16}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!19, !10, i64 8}
!26 = !{!7, !7, i64 0}
!27 = !{!16, !16, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


; 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.ixbar_input_ = type { i32, i32, i32, %struct.hash_symmetric_info_, %union.anon }
%struct.hash_symmetric_info_ = type { i8, i32, i32 }
%union.anon = type { i64 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z15set_into_bitvecPmjmjj(ptr noundef, i32 noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z28initialize_input_data_streamPK19bfn_hash_algorithm_PmjPK12ixbar_input_j(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %11

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load i32, ptr %9, align 4, !tbaa !15
  br label %11

11:                                               ; preds = %8, %5
  %.0 = phi i32 [ %10, %8 ], [ 0, %5 ]
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph41

.lr.ph41:                                         ; preds = %11
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %wide.trip.count = zext i32 %4 to i64
  br label %14

._crit_edge:                                      ; preds = %.loopexit, %11
  ret void

14:                                               ; preds = %.lr.ph41, %.loopexit
  %indvars.iv44 = phi i64 [ 0, %.lr.ph41 ], [ %indvars.iv.next45, %.loopexit ]
  %.140 = phi i32 [ %.0, %.lr.ph41 ], [ %47, %.loopexit ]
  %15 = getelementptr inbounds %struct.ixbar_input_, ptr %3, i64 %indvars.iv44
  %16 = load i32, ptr %15, align 8, !tbaa !16
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %.loopexit

18:                                               ; preds = %14
  %19 = load i32, ptr %0, align 8, !tbaa !5
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %40

21:                                               ; preds = %18
  %22 = load i8, ptr %12, align 8, !tbaa !20, !range !21, !noundef !22
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %.preheader, label %40

.preheader:                                       ; preds = %21
  %24 = getelementptr inbounds i8, ptr %15, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !23
  %.not42 = icmp eq i32 %25, 0
  br i1 %.not42, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %26 = getelementptr inbounds i8, ptr %15, i64 24
  br label %27

27:                                               ; preds = %.lr.ph, %27
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %27 ]
  %28 = trunc nuw i64 %indvars.iv to i32
  %29 = add i32 %.140, %28
  %30 = load i32, ptr %13, align 4, !tbaa !15
  %31 = sub i32 %29, %30
  %32 = xor i32 %31, 7
  %33 = add i32 %32, %30
  %34 = load i64, ptr %26, align 8, !tbaa !24
  %35 = lshr i64 %34, %indvars.iv
  %36 = and i64 %35, 1
  tail call void @_Z15set_into_bitvecPmjmjj(ptr noundef %1, i32 noundef %2, i64 noundef %36, i32 noundef %33, i32 noundef 1)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %37 = load i32, ptr %24, align 8, !tbaa !23
  %38 = zext i32 %37 to i64
  %39 = icmp ult i64 %indvars.iv.next, %38
  br i1 %39, label %27, label %.loopexit, !llvm.loop !25

40:                                               ; preds = %21, %18
  %41 = getelementptr inbounds i8, ptr %15, i64 8
  %42 = load i32, ptr %41, align 8, !tbaa !23
  %43 = getelementptr inbounds i8, ptr %15, i64 24
  %44 = load i64, ptr %43, align 8, !tbaa !24
  tail call void @_Z15set_into_bitvecPmjmjj(ptr noundef %1, i32 noundef %2, i64 noundef %44, i32 noundef %.140, i32 noundef %42)
  br label %.loopexit

.loopexit:                                        ; preds = %27, %.preheader, %40, %14
  %45 = getelementptr inbounds i8, ptr %15, i64 8
  %46 = load i32, ptr %45, align 8, !tbaa !23
  %47 = add i32 %46, %.140
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %14, !llvm.loop !27
}

attributes #0 = { 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" }

!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 = !{!"_ZTS19bfn_hash_algorithm_", !7, i64 0, !10, i64 4, !10, i64 5, !11, i64 8, !12, i64 12, !10, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !14, i64 48}
!7 = !{!"_ZTS19bfn_hash_alg_type_t", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS13bfn_crc_alg_t", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !12, i64 12}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTS12ixbar_input_", !18, i64 0, !12, i64 4, !12, i64 8, !19, i64 12, !8, i64 24}
!18 = !{!"_ZTS16ixbar_input_type", !8, i64 0}
!19 = !{!"_ZTS20hash_symmetric_info_", !10, i64 0, !12, i64 4, !12, i64 8}
!20 = !{!6, !10, i64 16}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!17, !12, i64 8}
!24 = !{!8, !8, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass