; LLVM IR from QMUL-EECS-Networks-Systems/ebpf-sketches :: tests/micro-benchmarks/hashbench (bench_fasthash)

; 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.pkt_5tuple = type { i32, i32, i16, i16, i8 }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.pkt_5tuple, align 4
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca %struct.timespec, align 8
  %7 = alloca %struct.timespec, align 8
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #6
  %10 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 0
  store volatile i32 1, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 1
  store i32 2, ptr %11, align 4, !tbaa !11
  %12 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 2
  store i16 3, ptr %12, align 4, !tbaa !12
  %13 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 3
  store i16 4, ptr %13, align 2, !tbaa !13
  %14 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 4
  store i8 6, ptr %14, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 1000000000, ptr %3, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store volatile i32 0, ptr %4, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %25, %0
  %16 = load i64, ptr %5, align 8, !tbaa !15
  %17 = icmp ult i64 %16, 1000000000
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %28

19:                                               ; preds = %15
  %20 = load i64, ptr %5, align 8, !tbaa !15
  %21 = trunc i64 %20 to i32
  %22 = call i32 @fasthash32(ptr noundef %2, i64 noundef 16, i32 noundef %21)
  %23 = load volatile i32, ptr %4, align 4, !tbaa !17
  %24 = xor i32 %23, %22
  store volatile i32 %24, ptr %4, align 4, !tbaa !17
  br label %25

25:                                               ; preds = %19
  %26 = load i64, ptr %5, align 8, !tbaa !15
  %27 = add i64 %26, 20
  store i64 %27, ptr %5, align 8, !tbaa !15
  br label %15, !llvm.loop !18

28:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 16, i1 false)
  %29 = call i32 @clock_gettime(i32 noundef 1, ptr noundef %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !17
  br label %30

30:                                               ; preds = %44, %28
  %31 = load i32, ptr %8, align 4, !tbaa !17
  %32 = sext i32 %31 to i64
  %33 = icmp ult i64 %32, 1000000000
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load volatile i32, ptr %4, align 4, !tbaa !17
  %37 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 0
  store volatile i32 %36, ptr %37, align 4, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !17
  %39 = load i32, ptr %8, align 4, !tbaa !17
  %40 = mul nsw i32 %38, %39
  %41 = call i32 @fasthash32(ptr noundef %2, i64 noundef 16, i32 noundef %40)
  %42 = load volatile i32, ptr %4, align 4, !tbaa !17
  %43 = xor i32 %42, %41
  store volatile i32 %43, ptr %4, align 4, !tbaa !17
  br label %44

44:                                               ; preds = %35
  %45 = load i32, ptr %8, align 4, !tbaa !17
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !17
  br label %30, !llvm.loop !20

47:                                               ; preds = %34
  %48 = call i32 @clock_gettime(i32 noundef 1, ptr noundef %7) #6
  %49 = load volatile i32, ptr %4, align 4, !tbaa !17
  call void @print_results(ptr noundef %6, ptr noundef %7, i64 noundef 1000000000, i32 noundef %49)
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #6
  ret i32 0
}

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @fasthash32(ptr noundef, i64 noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nounwind
declare i32 @clock_gettime(i32 noundef, ptr noundef) #5

; Function Attrs: alwaysinline nounwind uwtable
declare void @print_results(ptr noundef, ptr noundef, i64 noundef, i32 noundef) #3

attributes #0 = { 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 #1 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { alwaysinline 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind "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 #6 = { 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, !7, i64 0}
!6 = !{!"pkt_5tuple", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 10, !8, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 10}
!14 = !{!6, !8, i64 12}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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.pkt_5tuple = type { i32, i32, i16, i16, i8 }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.pkt_5tuple, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.timespec, align 8
  %4 = alloca %struct.timespec, align 8
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #6
  store volatile i32 1, ptr %1, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 2, ptr %6, align 4, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  store i16 3, ptr %7, align 4, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %1, i64 10
  store i16 4, ptr %8, align 2, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 6, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2)
  store volatile i32 0, ptr %2, align 4, !tbaa !15
  br label %12

10:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  %11 = call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull %3) #6
  br label %20

12:                                               ; preds = %0, %12
  %.01011 = phi i64 [ 0, %0 ], [ %16, %12 ]
  %13 = trunc nuw nsw i64 %.01011 to i32
  %14 = call i32 @fasthash32(ptr noundef nonnull %1, i64 noundef 16, i32 noundef %13)
  %.0..0..0..0. = load volatile i32, ptr %2, align 4, !tbaa !15
  %15 = xor i32 %.0..0..0..0., %14
  store volatile i32 %15, ptr %2, align 4, !tbaa !15
  %16 = add nuw nsw i64 %.01011, 20
  %17 = icmp ult i64 %.01011, 999999980
  br i1 %17, label %12, label %10, !llvm.loop !16

18:                                               ; preds = %20
  %19 = call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull %4) #6
  %.0..0..0..0.9 = load volatile i32, ptr %2, align 4, !tbaa !15
  call void @print_results(ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef 1000000000, i32 noundef %.0..0..0..0.9)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #6
  ret i32 0

20:                                               ; preds = %10, %20
  %.012 = phi i32 [ 0, %10 ], [ %24, %20 ]
  %.0..0..0..0.7 = load volatile i32, ptr %2, align 4, !tbaa !15
  store volatile i32 %.0..0..0..0.7, ptr %1, align 4, !tbaa !5
  %21 = mul nuw nsw i32 %.012, %.012
  %22 = call i32 @fasthash32(ptr noundef nonnull %1, i64 noundef 16, i32 noundef %21)
  %.0..0..0..0.8 = load volatile i32, ptr %2, align 4, !tbaa !15
  %23 = xor i32 %.0..0..0..0.8, %22
  store volatile i32 %23, ptr %2, align 4, !tbaa !15
  %24 = add nuw nsw i32 %.012, 1
  %exitcond.not = icmp eq i32 %24, 1000000000
  br i1 %exitcond.not, label %18, label %20, !llvm.loop !18
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @fasthash32(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nounwind
declare i32 @clock_gettime(i32 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: alwaysinline nounwind uwtable
declare void @print_results(ptr noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { nofree nounwind "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { alwaysinline 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind "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 #6 = { 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, !7, i64 0}
!6 = !{!"pkt_5tuple", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 10, !8, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 10}
!14 = !{!6, !8, i64 12}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass