; 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
declare dso_local ptr @xdl_mmfile_first(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @xdl_mmfile_next(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @xdl_mmfile_size(ptr noundef) #1

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

12:                                               ; preds = %1
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i64, ptr %4, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  store ptr %15, ptr %8, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %55, %12
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = icmp slt i64 %17, 256
  br i1 %18, label %19, label %56

19:                                               ; preds = %16
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = icmp uge ptr %20, %21
  br i1 %22, label %23, label %39

23:                                               ; preds = %19
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = ptrtoint ptr %24 to i64
  %27 = ptrtoint ptr %25 to i64
  %28 = sub i64 %26, %27
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = add nsw i64 %29, %28
  store i64 %30, ptr %5, align 8, !tbaa !9
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = call ptr @xdl_mmfile_next(ptr noundef %31, ptr noundef %4)
  store ptr %32, ptr %6, align 8, !tbaa !5
  store ptr %32, ptr %7, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %35, label %34

34:                                               ; preds = %23
  br label %56

35:                                               ; preds = %23
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i64, ptr %4, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  store ptr %38, ptr %8, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %35, %19
  %40 = load i64, ptr %3, align 8, !tbaa !9
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %3, align 8, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = ptrtoint ptr %43 to i64
  %46 = ptrtoint ptr %44 to i64
  %47 = sub i64 %45, %46
  %48 = call ptr @memchr(ptr noundef %42, i32 noundef 10, i64 noundef %47) #4
  store ptr %48, ptr %7, align 8, !tbaa !5
  %49 = icmp ne ptr %48, null
  br i1 %49, label %52, label %50

50:                                               ; preds = %39
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %51, ptr %7, align 8, !tbaa !5
  br label %55

52:                                               ; preds = %39
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %53, i32 1
  store ptr %54, ptr %7, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %52, %50
  br label %16, !llvm.loop !11

56:                                               ; preds = %34, %16
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = ptrtoint ptr %57 to i64
  %60 = ptrtoint ptr %58 to i64
  %61 = sub i64 %59, %60
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = add nsw i64 %62, %61
  store i64 %63, ptr %5, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %56, %1
  %65 = load i64, ptr %3, align 8, !tbaa !9
  %66 = icmp ne i64 %65, 0
  br i1 %66, label %67, label %77

67:                                               ; preds = %64
  %68 = load i64, ptr %5, align 8, !tbaa !9
  %69 = icmp ne i64 %68, 0
  br i1 %69, label %70, label %77

70:                                               ; preds = %67
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = call i64 @xdl_mmfile_size(ptr noundef %71)
  %73 = load i64, ptr %5, align 8, !tbaa !9
  %74 = load i64, ptr %3, align 8, !tbaa !9
  %75 = sdiv i64 %73, %74
  %76 = sdiv i64 %72, %75
  store i64 %76, ptr %3, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %70, %67, %64
  %78 = load i64, ptr %3, align 8, !tbaa !9
  %79 = add nsw i64 %78, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i64 %79
}

; Function Attrs: nounwind willreturn memory(read)
declare ptr @memchr(ptr noundef, i32 noundef, i64 noundef) #2

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 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 #3 = { nounwind }
attributes #4 = { 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"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: 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

; Function Attrs: nounwind uwtable
declare dso_local ptr @xdl_mmfile_first(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @xdl_mmfile_next(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @xdl_mmfile_size(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775807, -9223372036854775808) i64 @xdl_guess_lines(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %3 = call ptr @xdl_mmfile_first(ptr noundef %0, ptr noundef nonnull %2)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %.thread, label %4

4:                                                ; preds = %1
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 %5
  br label %7

7:                                                ; preds = %4, %17
  %.051 = phi ptr [ %6, %4 ], [ %.1, %17 ]
  %.02550 = phi ptr [ %3, %4 ], [ %.2, %17 ]
  %.02749 = phi ptr [ %3, %4 ], [ %.128, %17 ]
  %.03048 = phi i64 [ 0, %4 ], [ %.131, %17 ]
  %.03447 = phi i64 [ 0, %4 ], [ %18, %17 ]
  %.not41 = icmp ult ptr %.02550, %.051
  br i1 %.not41, label %17, label %8

8:                                                ; preds = %7
  %9 = ptrtoint ptr %.02550 to i64
  %10 = ptrtoint ptr %.02749 to i64
  %11 = sub i64 %9, %10
  %12 = add nsw i64 %11, %.03048
  %13 = call ptr @xdl_mmfile_next(ptr noundef %0, ptr noundef nonnull %2)
  %.not42 = icmp eq ptr %13, null
  br i1 %.not42, label %24, label %14

14:                                               ; preds = %8
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %13, i64 %15
  br label %17

17:                                               ; preds = %14, %7
  %.131 = phi i64 [ %12, %14 ], [ %.03048, %7 ]
  %.128 = phi ptr [ %13, %14 ], [ %.02749, %7 ]
  %.126 = phi ptr [ %13, %14 ], [ %.02550, %7 ]
  %.1 = phi ptr [ %16, %14 ], [ %.051, %7 ]
  %18 = add nuw nsw i64 %.03447, 1
  %19 = ptrtoint ptr %.1 to i64
  %20 = ptrtoint ptr %.126 to i64
  %21 = sub i64 %19, %20
  %22 = call ptr @memchr(ptr noundef %.126, i32 noundef 10, i64 noundef %21) #4
  %.not43 = icmp eq ptr %22, null
  %23 = getelementptr inbounds i8, ptr %22, i64 1
  %.2 = select i1 %.not43, ptr %.1, ptr %23
  %exitcond.not = icmp eq i64 %18, 256
  br i1 %exitcond.not, label %24, label %7, !llvm.loop !9

24:                                               ; preds = %17, %8
  %.034.lcssa = phi i64 [ 256, %17 ], [ %.03447, %8 ]
  %.232 = phi i64 [ %.131, %17 ], [ %12, %8 ]
  %.229 = phi ptr [ %.128, %17 ], [ null, %8 ]
  %.3 = phi ptr [ %.2, %17 ], [ null, %8 ]
  %25 = ptrtoint ptr %.3 to i64
  %26 = ptrtoint ptr %.229 to i64
  %27 = sub i64 %25, %26
  %28 = add nsw i64 %27, %.232
  %29 = icmp ne i64 %.034.lcssa, 0
  %30 = icmp ne i64 %28, 0
  %or.cond = select i1 %29, i1 %30, i1 false
  br i1 %or.cond, label %31, label %.thread

31:                                               ; preds = %24
  %32 = call i64 @xdl_mmfile_size(ptr noundef %0)
  %33 = sdiv i64 %28, %.034.lcssa
  %34 = sdiv i64 %32, %33
  br label %.thread

.thread:                                          ; preds = %1, %31, %24
  %.236 = phi i64 [ %34, %31 ], [ %.034.lcssa, %24 ], [ 0, %1 ]
  %35 = add nsw i64 %.236, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret i64 %35
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @memchr(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { 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 #3 = { nounwind }
attributes #4 = { 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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass