; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/lzma/C/7zip/Compress/LZ (LZInWindow)

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

%class.CLZInWindow = type { ptr, ptr, ptr, i32, i8, ptr, ptr, i32, i32, i32, i32, i32, i32 }

; 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: mustprogress uwtable
define dso_local void @_ZN11CLZInWindow9MoveBlockEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds ptr, ptr %6, i64 0
  %8 = load ptr, ptr %7, align 8
  call void %8(ptr noundef nonnull align 8 dereferenceable(72) %5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %9 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 6
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 1
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = ptrtoint ptr %10 to i64
  %14 = ptrtoint ptr %12 to i64
  %15 = sub i64 %13, %14
  %16 = trunc i64 %15 to i32
  %17 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 8
  %18 = load i32, ptr %17, align 4, !tbaa !16
  %19 = add i32 %16, %18
  %20 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 9
  %21 = load i32, ptr %20, align 8, !tbaa !17
  %22 = sub i32 %19, %21
  store i32 %22, ptr %3, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %23 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 6
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %25 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %27 = ptrtoint ptr %24 to i64
  %28 = ptrtoint ptr %26 to i64
  %29 = sub i64 %27, %28
  %30 = trunc i64 %29 to i32
  %31 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 12
  %32 = load i32, ptr %31, align 4, !tbaa !19
  %33 = add i32 %30, %32
  %34 = load i32, ptr %3, align 4, !tbaa !18
  %35 = sub i32 %33, %34
  store i32 %35, ptr %4, align 4, !tbaa !18
  %36 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i32, ptr %3, align 4, !tbaa !18
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  %43 = load i32, ptr %4, align 4, !tbaa !18
  %44 = zext i32 %43 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %37, ptr align 1 %42, i64 %44, i1 false)
  %45 = load i32, ptr %3, align 4, !tbaa !18
  %46 = getelementptr inbounds %class.CLZInWindow, ptr %5, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = zext i32 %45 to i64
  %49 = sub i64 0, %48
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  store ptr %50, ptr %46, align 8, !tbaa !11
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = getelementptr inbounds ptr, ptr %51, i64 1
  %53 = load ptr, ptr %52, align 8
  call void %53(ptr noundef nonnull align 8 dereferenceable(72) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 40}
!12 = !{!"_ZTS11CLZInWindow", !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 28, !6, i64 32, !6, i64 40, !13, i64 48, !13, i64 52, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68}
!13 = !{!"int", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !13, i64 52}
!17 = !{!12, !13, i64 56}
!18 = !{!13, !13, i64 0}
!19 = !{!12, !13, i64 68}


; 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 uwtable
define dso_local void @_ZN11CLZInWindow9MoveBlockEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  tail call void %3(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = ptrtoint ptr %5 to i64
  %9 = ptrtoint ptr %7 to i64
  %10 = sub i64 %8, %9
  %11 = trunc i64 %10 to i32
  %12 = getelementptr inbounds i8, ptr %0, i64 52
  %13 = load i32, ptr %12, align 4, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 56
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = sub i32 %13, %15
  %17 = add i32 %16, %11
  %18 = getelementptr inbounds i8, ptr %0, i64 68
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = sub i32 %19, %16
  %21 = zext i32 %17 to i64
  %22 = getelementptr inbounds i8, ptr %7, i64 %21
  %23 = zext i32 %20 to i64
  tail call void @llvm.memmove.p0.p0.i64(ptr align 1 %7, ptr align 1 %22, i64 %23, i1 false)
  %24 = load ptr, ptr %4, align 8, !tbaa !8
  %25 = sub nsw i64 0, %21
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  store ptr %26, ptr %4, align 8, !tbaa !8
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load ptr, ptr %28, align 8
  tail call void %29(ptr noundef nonnull align 8 dereferenceable(72) %0)
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

attributes #0 = { mustprogress 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 nounwind willreturn memory(argmem: readwrite) }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 40}
!9 = !{!"_ZTS11CLZInWindow", !10, i64 8, !10, i64 16, !12, i64 24, !13, i64 28, !10, i64 32, !10, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"bool", !11, i64 0}
!14 = !{!9, !10, i64 8}
!15 = !{!9, !12, i64 52}
!16 = !{!9, !12, i64 56}
!17 = !{!9, !12, i64 68}


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