; LLVM IR from Angold-4/chainsaw :: src/debug/editor.ll (ZN6Editor10rowDelCharEP7editRowi)

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

%struct.editRow = type { i32, i32, i32, ptr, ptr }
%class.Editor = type { i8, ptr, ptr, %struct.buffer, ptr, ptr, %struct.editorConfig, %struct.editorConfig }
%struct.buffer = type { ptr, i64, i8, i32 }
%struct.editorConfig = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, ptr, [80 x i8], %"class.std::__cxx11::basic_string", i8, i64 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; 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) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Editor9UpdateRowEP7editRow(ptr noundef nonnull align 8 dereferenceable(448), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Editor10rowDelCharEP7editRowi(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.editRow, ptr %8, i32 0, i32 1
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %43

14:                                               ; preds = %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.editRow, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.editRow, ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  %27 = getelementptr inbounds i8, ptr %26, i64 1
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.editRow, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = sub nsw i32 %30, %31
  %33 = sext i32 %32 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %20, ptr align 1 %27, i64 %33, i1 false)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN6Editor9UpdateRowEP7editRow(ptr noundef nonnull align 8 dereferenceable(448) %7, ptr noundef %34)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.editRow, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !11
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr %36, align 4, !tbaa !11
  %39 = getelementptr inbounds %class.Editor, ptr %7, i32 0, i32 6
  %40 = getelementptr inbounds %struct.editorConfig, ptr %39, i32 0, i32 11
  %41 = load i32, ptr %40, align 8, !tbaa !14
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 8, !tbaa !14
  br label %43

43:                                               ; preds = %14, %13
  ret void
}

attributes #0 = { nocallback nofree 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" }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTS7editRow", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 16}
!14 = !{!15, !10, i64 112}
!15 = !{!"_ZTS6Editor", !16, i64 0, !6, i64 8, !6, i64 16, !17, i64 24, !6, i64 48, !6, i64 56, !19, i64 64, !19, i64 256}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS6buffer", !6, i64 0, !18, i64 8, !16, i64 16, !10, i64 20}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTS12editorConfig", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !6, i64 56, !7, i64 64, !20, i64 144, !16, i64 176, !18, i64 184}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !21, i64 0, !18, i64 8, !7, i64 16}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Editor9UpdateRowEP7editRow(ptr noundef nonnull align 8 dereferenceable(448), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Editor10rowDelCharEP7editRowi(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp sgt i32 %5, %2
  br i1 %.not, label %6, label %19

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = sext i32 %2 to i64
  %10 = getelementptr inbounds i8, ptr %8, i64 %9
  %11 = getelementptr inbounds i8, ptr %10, i64 1
  %12 = sub nsw i32 %5, %2
  %13 = sext i32 %12 to i64
  tail call void @llvm.memmove.p0.p0.i64(ptr align 1 %10, ptr nonnull align 1 %11, i64 %13, i1 false)
  tail call void @_ZN6Editor9UpdateRowEP7editRow(ptr noundef nonnull align 8 dereferenceable(448) %0, ptr noundef nonnull %1)
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %4, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 112
  %17 = load i32, ptr %16, align 8, !tbaa !12
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %16, align 8, !tbaa !12
  br label %19

19:                                               ; preds = %3, %6
  ret void
}

attributes #0 = { mustprogress nocallback nofree 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" }

!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, !7, i64 4}
!6 = !{!"_ZTS7editRow", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!13, !7, i64 112}
!13 = !{!"_ZTS6Editor", !14, i64 0, !10, i64 8, !10, i64 16, !15, i64 24, !10, i64 48, !10, i64 56, !17, i64 64, !17, i64 256}
!14 = !{!"bool", !8, i64 0}
!15 = !{!"_ZTS6buffer", !10, i64 0, !16, i64 8, !14, i64 16, !7, i64 20}
!16 = !{!"long", !8, i64 0}
!17 = !{!"_ZTS12editorConfig", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !7, i64 48, !10, i64 56, !8, i64 64, !18, i64 144, !14, i64 176, !16, i64 184}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !19, i64 0, !16, i64 8, !8, i64 16}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}


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