; LLVM IR from artagnon/phoenixfs :: xdiff (xutils)

; 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: nounwind uwtable
define dso_local i64 @xdl_hash_record(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 5381, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %12, ptr %9, align 8, !tbaa !5
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = and i64 %13, 28
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = call i64 @xdl_hash_record_with_whitespace(ptr noundef %17, ptr noundef %18, i64 noundef %19)
  store i64 %20, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %59

21:                                               ; preds = %3
  br label %22

22:                                               ; preds = %43, %21
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp ult ptr %23, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !11
  %29 = sext i8 %28 to i32
  %30 = icmp ne i32 %29, 10
  br label %31

31:                                               ; preds = %26, %22
  %32 = phi i1 [ false, %22 ], [ %30, %26 ]
  br i1 %32, label %33, label %46

33:                                               ; preds = %31
  %34 = load i64, ptr %8, align 8, !tbaa !9
  %35 = shl i64 %34, 5
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = add i64 %36, %35
  store i64 %37, ptr %8, align 8, !tbaa !9
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = sext i8 %39 to i64
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = xor i64 %41, %40
  store i64 %42, ptr %8, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %33
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %9, align 8, !tbaa !5
  br label %22, !llvm.loop !12

46:                                               ; preds = %31
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = icmp ult ptr %47, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %46
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %51, i64 1
  br label %55

53:                                               ; preds = %46
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %53, %50
  %56 = phi ptr [ %52, %50 ], [ %54, %53 ]
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %56, ptr %57, align 8, !tbaa !5
  %58 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %58, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %59

59:                                               ; preds = %55, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %60 = load i64, ptr %4, align 8
  ret i64 %60
}

; Function Attrs: nounwind uwtable
declare hidden i64 @xdl_hash_record_with_whitespace(ptr noundef, ptr noundef, i64 noundef) #1

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


; 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: nounwind uwtable
define dso_local i64 @xdl_hash_record(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = ptrtoint ptr %1 to i64
  %5 = and i64 %2, 28
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %.preheader, label %11

.preheader:                                       ; preds = %3
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = icmp ult ptr %6, %1
  br i1 %7, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.preheader
  %8 = ptrtoint ptr %6 to i64
  %9 = sub i64 %4, %8
  %scevgep = getelementptr i8, ptr %6, i64 %9
  %10 = load i8, ptr %6, align 1, !tbaa !9
  %.not2130 = icmp eq i8 %10, 10
  br i1 %.not2130, label %.critedge, label %.lr.ph33

11:                                               ; preds = %3
  %12 = tail call i64 @xdl_hash_record_with_whitespace(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2)
  br label %22

.lr.ph:                                           ; preds = %.lr.ph33
  %13 = load i8, ptr %18, align 1, !tbaa !9
  %.not21 = icmp eq i8 %13, 10
  br i1 %.not21, label %.critedge.loopexit.loopexit, label %.lr.ph33, !llvm.loop !10

.lr.ph33:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %14 = phi i8 [ %13, %.lr.ph ], [ %10, %.lr.ph.preheader ]
  %.0192232 = phi i64 [ %17, %.lr.ph ], [ 5381, %.lr.ph.preheader ]
  %.02331 = phi ptr [ %18, %.lr.ph ], [ %6, %.lr.ph.preheader ]
  %15 = mul i64 %.0192232, 33
  %16 = sext i8 %14 to i64
  %17 = xor i64 %15, %16
  %18 = getelementptr inbounds i8, ptr %.02331, i64 1
  %exitcond.not = icmp eq ptr %18, %1
  br i1 %exitcond.not, label %.critedge.loopexit.loopexit, label %.lr.ph, !llvm.loop !10

.critedge.loopexit.loopexit:                      ; preds = %.lr.ph33, %.lr.ph
  %.0.lcssa.ph.ph = phi ptr [ %18, %.lr.ph ], [ %scevgep, %.lr.ph33 ]
  %19 = icmp ult ptr %18, %1
  %20 = zext i1 %19 to i64
  br label %.critedge

.critedge:                                        ; preds = %.lr.ph.preheader, %.critedge.loopexit.loopexit, %.preheader
  %.019.lcssa = phi i64 [ 5381, %.preheader ], [ 5381, %.lr.ph.preheader ], [ %17, %.critedge.loopexit.loopexit ]
  %.0.lcssa = phi ptr [ %6, %.preheader ], [ %6, %.lr.ph.preheader ], [ %.0.lcssa.ph.ph, %.critedge.loopexit.loopexit ]
  %.lcssa = phi i64 [ 0, %.preheader ], [ 1, %.lr.ph.preheader ], [ %20, %.critedge.loopexit.loopexit ]
  %21 = getelementptr inbounds i8, ptr %.0.lcssa, i64 %.lcssa
  store ptr %21, ptr %0, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %.critedge, %11
  %.020 = phi i64 [ %12, %11 ], [ %.019.lcssa, %.critedge ]
  ret i64 %.020
}

; Function Attrs: nounwind uwtable
declare hidden i64 @xdl_hash_record_with_whitespace(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

!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}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass