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

; 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
declare dso_local i64 @siphash24(ptr noundef, i64 noundef, ptr noundef) #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca [16 x i8], align 16
  %7 = alloca %struct.timespec, align 8
  %8 = alloca %struct.timespec, align 8
  %9 = alloca i64, align 8
  %10 = alloca [16 x i8], align 16
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #7
  %12 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 0
  store volatile i32 1, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 1
  store i32 2, ptr %13, align 4, !tbaa !11
  %14 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 2
  store i16 3, ptr %14, align 4, !tbaa !12
  %15 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 3
  store i16 4, ptr %15, align 2, !tbaa !13
  %16 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 4
  store i8 6, ptr %16, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 1000000000, ptr %3, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store volatile i64 0, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %17

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

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %30

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #7
  call void @llvm.memset.p0.i64(ptr align 16 %6, i8 0, i64 16, i1 false)
  %22 = getelementptr inbounds [16 x i8], ptr %6, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %22, ptr align 8 %5, i64 8, i1 false)
  %23 = getelementptr inbounds [16 x i8], ptr %6, i64 0, i64 0
  %24 = call i64 @siphash24(ptr noundef %2, i64 noundef 16, ptr noundef %23)
  %25 = load volatile i64, ptr %4, align 8, !tbaa !15
  %26 = xor i64 %25, %24
  store volatile i64 %26, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #7
  br label %27

27:                                               ; preds = %21
  %28 = load i64, ptr %5, align 8, !tbaa !15
  %29 = add i64 %28, 20
  store i64 %29, ptr %5, align 8, !tbaa !15
  br label %17, !llvm.loop !17

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #7
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #7
  call void @llvm.memset.p0.i64(ptr align 8 %8, i8 0, i64 16, i1 false)
  %31 = call i32 @clock_gettime(i32 noundef 1, ptr noundef %7) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !15
  br label %32

32:                                               ; preds = %45, %30
  %33 = load i64, ptr %9, align 8, !tbaa !15
  %34 = icmp ult i64 %33, 1000000000
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %48

36:                                               ; preds = %32
  %37 = load volatile i64, ptr %4, align 8, !tbaa !15
  %38 = trunc i64 %37 to i32
  %39 = getelementptr inbounds %struct.pkt_5tuple, ptr %2, i32 0, i32 0
  store volatile i32 %38, ptr %39, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #7
  call void @llvm.memset.p0.i64(ptr align 16 %10, i8 0, i64 16, i1 false)
  %40 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %40, ptr align 8 %9, i64 8, i1 false)
  %41 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %42 = call i64 @siphash24(ptr noundef %2, i64 noundef 16, ptr noundef %41)
  %43 = load volatile i64, ptr %4, align 8, !tbaa !15
  %44 = xor i64 %43, %42
  store volatile i64 %44, ptr %4, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #7
  br label %45

45:                                               ; preds = %36
  %46 = load i64, ptr %9, align 8, !tbaa !15
  %47 = add i64 %46, 1
  store i64 %47, ptr %9, align 8, !tbaa !15
  br label %32, !llvm.loop !19

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, 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) #6

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #7 = { 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 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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
declare dso_local i64 @siphash24(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

12:                                               ; preds = %14
  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)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  %13 = call i32 @clock_gettime(i32 noundef 1, ptr noundef nonnull %4) #6
  br label %22

14:                                               ; preds = %0, %14
  %.089 = phi i64 [ 0, %0 ], [ %17, %14 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  store i64 %.089, ptr %3, align 16
  %15 = call i64 @siphash24(ptr noundef nonnull %1, i64 noundef 16, ptr noundef nonnull %3)
  %.0..0..0..0. = load volatile i64, ptr %2, align 8, !tbaa !15
  %16 = xor i64 %.0..0..0..0., %15
  store volatile i64 %16, ptr %2, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  %17 = add nuw nsw i64 %.089, 20
  %18 = icmp ult i64 %.089, 999999980
  br i1 %18, label %14, label %12, !llvm.loop !17

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

22:                                               ; preds = %12, %22
  %.010 = phi i64 [ 0, %12 ], [ %26, %22 ]
  %.0..0..0..0.5 = load volatile i64, ptr %2, align 8, !tbaa !15
  %23 = trunc i64 %.0..0..0..0.5 to i32
  store volatile i32 %23, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  store i64 %.010, ptr %6, align 16
  %24 = call i64 @siphash24(ptr noundef nonnull %1, i64 noundef 16, ptr noundef nonnull %6)
  %.0..0..0..0.6 = load volatile i64, ptr %2, align 8, !tbaa !15
  %25 = xor i64 %.0..0..0..0.6, %24
  store volatile i64 %25, ptr %2, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  %26 = add nuw nsw i64 %.010, 1
  %exitcond.not = icmp eq i64 %26, 1000000000
  br i1 %exitcond.not, label %19, label %22, !llvm.loop !19
}

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

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

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 #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 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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