; LLVM IR from libxsmm/libxsmm :: src (libxsmm_memory)

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

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1
@__PRETTY_FUNCTION__.libxsmm_hash_string = external hidden unnamed_addr constant [53 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

declare void @libxsmm_init() #2

declare i32 @libxsmm_crc32(i32 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @libxsmm_hash_string(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %15

12:                                               ; preds = %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = call i64 @strlen(ptr noundef %13) #6
  br label %16

15:                                               ; preds = %1
  br label %16

16:                                               ; preds = %15, %12
  %17 = phi i64 [ %14, %12 ], [ 0, %15 ]
  store i64 %17, ptr %4, align 8, !tbaa !11
  %18 = load i64, ptr %4, align 8, !tbaa !11
  %19 = icmp ult i64 8, %18
  br i1 %19, label %20, label %53

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %21 = load i64, ptr %4, align 8, !tbaa !11
  %22 = udiv i64 %21, 2
  %23 = icmp ult i64 %22, 8
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  br label %28

25:                                               ; preds = %20
  %26 = load i64, ptr %4, align 8, !tbaa !11
  %27 = udiv i64 %26, 2
  br label %28

28:                                               ; preds = %25, %24
  %29 = phi i64 [ 8, %24 ], [ %27, %25 ]
  store i64 %29, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !13
  %30 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !13
  %31 = icmp ugt i32 2, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %28
  call void @libxsmm_init()
  br label %33

33:                                               ; preds = %32, %28
  %34 = load i32, ptr %7, align 4, !tbaa !13
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load i64, ptr %5, align 8, !tbaa !11
  %37 = call i32 @libxsmm_crc32(i32 noundef %34, ptr noundef %35, i64 noundef %36)
  store i32 %37, ptr %7, align 4, !tbaa !13
  %38 = load i32, ptr %7, align 4, !tbaa !13
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = load i64, ptr %5, align 8, !tbaa !11
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  %42 = load i64, ptr %4, align 8, !tbaa !11
  %43 = load i64, ptr %5, align 8, !tbaa !11
  %44 = sub i64 %42, %43
  %45 = call i32 @libxsmm_crc32(i32 noundef %38, ptr noundef %41, i64 noundef %44)
  store i32 %45, ptr %6, align 4, !tbaa !13
  %46 = load i32, ptr %6, align 4, !tbaa !13
  %47 = zext i32 %46 to i64
  store i64 %47, ptr %3, align 8, !tbaa !9
  %48 = load i64, ptr %3, align 8, !tbaa !9
  %49 = shl i64 %48, 32
  %50 = load i32, ptr %7, align 4, !tbaa !13
  %51 = zext i32 %50 to i64
  %52 = or i64 %49, %51
  store i64 %52, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %100

53:                                               ; preds = %16
  %54 = load i64, ptr %4, align 8, !tbaa !11
  %55 = icmp ne i64 8, %54
  br i1 %55, label %56, label %91

56:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  store i8 0, ptr %9, align 1, !tbaa !15
  br label %57

57:                                               ; preds = %74, %56
  %58 = load i8, ptr %9, align 1, !tbaa !15
  %59 = sext i8 %58 to i32
  %60 = load i64, ptr %4, align 8, !tbaa !11
  %61 = trunc i64 %60 to i8
  %62 = sext i8 %61 to i32
  %63 = icmp slt i32 %59, %62
  br i1 %63, label %64, label %77

64:                                               ; preds = %57
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load i8, ptr %9, align 1, !tbaa !15
  %67 = sext i8 %66 to i64
  %68 = getelementptr inbounds i8, ptr %65, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !15
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i8, ptr %9, align 1, !tbaa !15
  %72 = sext i8 %71 to i64
  %73 = getelementptr inbounds i8, ptr %70, i64 %72
  store i8 %69, ptr %73, align 1, !tbaa !15
  br label %74

74:                                               ; preds = %64
  %75 = load i8, ptr %9, align 1, !tbaa !15
  %76 = add i8 %75, 1
  store i8 %76, ptr %9, align 1, !tbaa !15
  br label %57, !llvm.loop !16

77:                                               ; preds = %57
  br label %78

78:                                               ; preds = %87, %77
  %79 = load i8, ptr %9, align 1, !tbaa !15
  %80 = sext i8 %79 to i32
  %81 = icmp slt i32 %80, 8
  br i1 %81, label %82, label %90

82:                                               ; preds = %78
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = load i8, ptr %9, align 1, !tbaa !15
  %85 = sext i8 %84 to i64
  %86 = getelementptr inbounds i8, ptr %83, i64 %85
  store i8 0, ptr %86, align 1, !tbaa !15
  br label %87

87:                                               ; preds = %82
  %88 = load i8, ptr %9, align 1, !tbaa !15
  %89 = add i8 %88, 1
  store i8 %89, ptr %9, align 1, !tbaa !15
  br label %78, !llvm.loop !18

90:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %99

91:                                               ; preds = %53
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = icmp ne ptr null, %92
  br i1 %93, label %94, label %95

94:                                               ; preds = %91
  br label %96

95:                                               ; preds = %91
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 543, ptr noundef @__PRETTY_FUNCTION__.libxsmm_hash_string) #7
  unreachable

96:                                               ; preds = %94
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = load i64, ptr %97, align 8, !tbaa !9
  store i64 %98, ptr %3, align 8, !tbaa !9
  br label %99

99:                                               ; preds = %96, %90
  br label %100

100:                                              ; preds = %99, %33
  %101 = load i64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret i64 %101
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { "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 = { 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 = { nounwind willreturn memory(read) "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 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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

@libxsmm_ninit = external local_unnamed_addr global i32, align 4

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

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

declare void @libxsmm_init() local_unnamed_addr #1

declare i32 @libxsmm_crc32(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @libxsmm_hash_string(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  store i64 0, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.lr.ph38.preheader, label %3

3:                                                ; preds = %1
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %5 = icmp ugt i64 %4, 8
  br i1 %5, label %6, label %.thread33

6:                                                ; preds = %3
  %7 = lshr i64 %4, 1
  %8 = tail call i64 @llvm.umax.i64(i64 %7, i64 8)
  %9 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !9
  %10 = icmp ult i32 %9, 2
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  tail call void @libxsmm_init() #6
  br label %12

12:                                               ; preds = %11, %6
  %13 = tail call i32 @libxsmm_crc32(i32 noundef 0, ptr noundef nonnull %0, i64 noundef %8) #6
  %14 = getelementptr inbounds i8, ptr %0, i64 %8
  %15 = sub i64 %4, %8
  %16 = tail call i32 @libxsmm_crc32(i32 noundef %13, ptr noundef nonnull %14, i64 noundef %15) #6
  %17 = zext i32 %16 to i64
  %18 = shl nuw i64 %17, 32
  %19 = zext i32 %13 to i64
  %20 = or disjoint i64 %18, %19
  store i64 %20, ptr %2, align 8, !tbaa !5
  br label %.loopexit

.thread33:                                        ; preds = %3
  %.not3234 = icmp eq i64 %4, 8
  br i1 %.not3234, label %.thread35, label %.thread.preheader

.thread.preheader:                                ; preds = %.thread33
  %21 = trunc nuw i64 %4 to i32
  %.not44 = icmp eq i64 %4, 0
  br i1 %.not44, label %.lr.ph38.preheader, label %.thread

.preheader:                                       ; preds = %.thread
  %22 = icmp slt i8 %31, 8
  br i1 %22, label %.lr.ph38.preheader, label %.loopexit

.lr.ph38.preheader:                               ; preds = %1, %.thread.preheader, %.preheader
  %.0.lcssa43 = phi i8 [ %31, %.preheader ], [ 0, %.thread.preheader ], [ 0, %1 ]
  %23 = sext i8 %.0.lcssa43 to i64
  %scevgep = getelementptr i8, ptr %2, i64 %23
  %24 = sub i8 7, %.0.lcssa43
  %25 = zext i8 %24 to i64
  %26 = add nuw nsw i64 %25, 1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %scevgep, i8 0, i64 %26, i1 false), !tbaa !11
  br label %.loopexit

.thread:                                          ; preds = %.thread.preheader, %.thread
  %.036 = phi i8 [ %31, %.thread ], [ 0, %.thread.preheader ]
  %27 = sext i8 %.036 to i64
  %28 = getelementptr inbounds i8, ptr %0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %2, i64 %27
  store i8 %29, ptr %30, align 1, !tbaa !11
  %31 = add i8 %.036, 1
  %32 = sext i8 %31 to i32
  %33 = icmp slt i32 %32, %21
  br i1 %33, label %.thread, label %.preheader, !llvm.loop !12

.thread35:                                        ; preds = %.thread33
  %34 = load i64, ptr %0, align 8, !tbaa !5
  store i64 %34, ptr %2, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph38.preheader, %.preheader, %.thread35, %12
  %35 = load i64, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  ret i64 %35
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #4

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.isvectorized", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass