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

; 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: alwaysinline nounwind uwtable
declare hidden <2 x i64> @_mm_set1_epi32(i32 noundef) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x i64> @_mm_loadu_si128(ptr noundef) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @_mm_movemask_epi8(<2 x i64> noundef) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef, <2 x i64> noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @libxsmm_diff_64(ptr noundef %0, ptr noundef %1, ...) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca <2 x i64>, align 16
  %6 = alloca <2 x i64>, align 16
  %7 = alloca <2 x i64>, align 16
  %8 = alloca <2 x i64>, align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #3
  %9 = call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  store <2 x i64> %9, ptr %5, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  %10 = call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  store <2 x i64> %10, ptr %6, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  %11 = call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  store <2 x i64> %11, ptr %7, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #3
  %12 = call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  store <2 x i64> %12, ptr %8, align 16, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call <2 x i64> @_mm_loadu_si128(ptr noundef %13)
  store <2 x i64> %14, ptr %5, align 16, !tbaa !9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds i64, ptr %15, i64 2
  %17 = call <2 x i64> @_mm_loadu_si128(ptr noundef %16)
  store <2 x i64> %17, ptr %6, align 16, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds i64, ptr %18, i64 4
  %20 = call <2 x i64> @_mm_loadu_si128(ptr noundef %19)
  store <2 x i64> %20, ptr %7, align 16, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds i64, ptr %21, i64 4
  %23 = getelementptr inbounds i64, ptr %22, i64 2
  %24 = call <2 x i64> @_mm_loadu_si128(ptr noundef %23)
  store <2 x i64> %24, ptr %8, align 16, !tbaa !9
  %25 = load <2 x i64>, ptr %5, align 16, !tbaa !9
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call <2 x i64> @_mm_loadu_si128(ptr noundef %26)
  %28 = call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %25, <2 x i64> noundef %27)
  %29 = call i32 @_mm_movemask_epi8(<2 x i64> noundef %28)
  %30 = icmp ne i32 65535, %29
  %31 = zext i1 %30 to i32
  %32 = trunc i32 %31 to i8
  %33 = zext i8 %32 to i32
  %34 = icmp ne i32 0, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %2
  br label %47

36:                                               ; preds = %2
  %37 = load <2 x i64>, ptr %6, align 16, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds i64, ptr %38, i64 2
  %40 = call <2 x i64> @_mm_loadu_si128(ptr noundef %39)
  %41 = call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %37, <2 x i64> noundef %40)
  %42 = call i32 @_mm_movemask_epi8(<2 x i64> noundef %41)
  %43 = icmp ne i32 65535, %42
  %44 = zext i1 %43 to i32
  %45 = trunc i32 %44 to i8
  %46 = zext i8 %45 to i32
  br label %47

47:                                               ; preds = %36, %35
  %48 = phi i32 [ 1, %35 ], [ %46, %36 ]
  %49 = trunc i32 %48 to i8
  %50 = zext i8 %49 to i32
  %51 = icmp ne i32 0, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  br label %82

53:                                               ; preds = %47
  %54 = load <2 x i64>, ptr %7, align 16, !tbaa !9
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds i64, ptr %55, i64 4
  %57 = call <2 x i64> @_mm_loadu_si128(ptr noundef %56)
  %58 = call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %54, <2 x i64> noundef %57)
  %59 = call i32 @_mm_movemask_epi8(<2 x i64> noundef %58)
  %60 = icmp ne i32 65535, %59
  %61 = zext i1 %60 to i32
  %62 = trunc i32 %61 to i8
  %63 = zext i8 %62 to i32
  %64 = icmp ne i32 0, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %53
  br label %78

66:                                               ; preds = %53
  %67 = load <2 x i64>, ptr %8, align 16, !tbaa !9
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds i64, ptr %68, i64 4
  %70 = getelementptr inbounds i64, ptr %69, i64 2
  %71 = call <2 x i64> @_mm_loadu_si128(ptr noundef %70)
  %72 = call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %67, <2 x i64> noundef %71)
  %73 = call i32 @_mm_movemask_epi8(<2 x i64> noundef %72)
  %74 = icmp ne i32 65535, %73
  %75 = zext i1 %74 to i32
  %76 = trunc i32 %75 to i8
  %77 = zext i8 %76 to i32
  br label %78

78:                                               ; preds = %66, %65
  %79 = phi i32 [ 1, %65 ], [ %77, %66 ]
  %80 = trunc i32 %79 to i8
  %81 = zext i8 %80 to i32
  br label %82

82:                                               ; preds = %78, %52
  %83 = phi i32 [ 1, %52 ], [ %81, %78 ]
  %84 = trunc i32 %83 to i8
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #3
  ret i8 %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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"="128" "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 }

!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 = !{!7, !7, i64 0}


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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x i64> @_mm_set1_epi32(i32 noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x i64> @_mm_loadu_si128(ptr noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @_mm_movemask_epi8(<2 x i64> noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef, <2 x i64> noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @libxsmm_diff_64(ptr noundef %0, ptr noundef %1, ...) local_unnamed_addr #1 {
  %3 = tail call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  %4 = tail call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  %5 = tail call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  %6 = tail call <2 x i64> @_mm_set1_epi32(i32 noundef 0)
  %7 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef %0)
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef nonnull %8)
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef nonnull %10)
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  %13 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef nonnull %12)
  %14 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef %1)
  %15 = tail call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %7, <2 x i64> noundef %14)
  %16 = tail call i32 @_mm_movemask_epi8(<2 x i64> noundef %15)
  %.not = icmp eq i32 %16, 65535
  br i1 %.not, label %17, label %.critedge

17:                                               ; preds = %2
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  %19 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef nonnull %18)
  %20 = tail call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %9, <2 x i64> noundef %19)
  %21 = tail call i32 @_mm_movemask_epi8(<2 x i64> noundef %20)
  %.not12 = icmp eq i32 %21, 65535
  br i1 %.not12, label %22, label %.critedge

22:                                               ; preds = %17
  %23 = getelementptr inbounds i8, ptr %1, i64 32
  %24 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef nonnull %23)
  %25 = tail call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %11, <2 x i64> noundef %24)
  %26 = tail call i32 @_mm_movemask_epi8(<2 x i64> noundef %25)
  %.not13 = icmp eq i32 %26, 65535
  br i1 %.not13, label %27, label %.critedge

27:                                               ; preds = %22
  %28 = getelementptr inbounds i8, ptr %1, i64 48
  %29 = tail call <2 x i64> @_mm_loadu_si128(ptr noundef nonnull %28)
  %30 = tail call <2 x i64> @_mm_cmpeq_epi8(<2 x i64> noundef %13, <2 x i64> noundef %29)
  %31 = tail call i32 @_mm_movemask_epi8(<2 x i64> noundef %30)
  %32 = icmp ne i32 %31, 65535
  %33 = zext i1 %32 to i8
  br label %.critedge

.critedge:                                        ; preds = %2, %27, %22, %17
  %34 = phi i8 [ 1, %17 ], [ %33, %27 ], [ 1, %22 ], [ 1, %2 ]
  ret i8 %34
}

attributes #0 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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 = { nounwind uwtable "min-legal-vector-width"="128" "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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass