; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/GDCM/src/gdcm/Utilities/gdcmrle (rle)

; 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.rle::rle_decoder" = type { ptr }
%"struct.rle::rle_decoder::internal" = type { %"class.rle::image_info", %"struct.rle::header", ptr, i32, %"class.std::vector", [16 x [128 x i8]], [16 x i32] }
%"class.rle::image_info" = type { i32, i32, %"class.rle::pixel_info", i8, i8 }
%"class.rle::pixel_info" = type { i8, i8 }
%"struct.rle::header" = type { i32, [15 x i32] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl" = type { %"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<char, std::allocator<char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3rle10image_info9get_widthEv(ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; 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 noundef zeroext i1 @_ZN3rle11rle_decoder8skip_rowEv(ptr noundef nonnull align 8 dereferenceable(8) %0) #2 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %40, %1
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = getelementptr inbounds %"class.rle::rle_decoder", ptr %8, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %"struct.rle::rle_decoder::internal", ptr %12, i32 0, i32 3
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = icmp slt i32 %10, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %9
  store i32 2, ptr %5, align 4
  br label %43

17:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %18 = getelementptr inbounds %"class.rle::rle_decoder", ptr %8, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %"struct.rle::rle_decoder::internal", ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !23
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds ptr, ptr %21, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  store ptr %25, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.rle::rle_decoder", ptr %8, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %"struct.rle::rle_decoder::internal", ptr %28, i32 0, i32 0
  %30 = call noundef i32 @_ZNK3rle10image_info9get_widthEv(ptr noundef nonnull align 4 dereferenceable(12) %29)
  %31 = call noundef zeroext i1 @_ZN3rleL17skip_row_internalERNS_6sourceEi(ptr noundef nonnull align 8 dereferenceable(8) %26, i32 noundef %30)
  %32 = zext i1 %31 to i8
  store i8 %32, ptr %7, align 1, !tbaa !24
  %33 = load i8, ptr %7, align 1, !tbaa !24, !range !25, !noundef !26
  %34 = trunc i8 %33 to i1
  br i1 %34, label %36, label %35

35:                                               ; preds = %17
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %37

36:                                               ; preds = %17
  store i32 0, ptr %5, align 4
  br label %37

37:                                               ; preds = %36, %35
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %38 = load i32, ptr %5, align 4
  switch i32 %38, label %43 [
    i32 0, label %39
  ]

39:                                               ; preds = %37
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !27

43:                                               ; preds = %37, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %44 = load i32, ptr %5, align 4
  switch i32 %44, label %48 [
    i32 2, label %45
    i32 1, label %46
  ]

45:                                               ; preds = %43
  store i1 true, ptr %2, align 1
  br label %46

46:                                               ; preds = %45, %43
  %47 = load i1, ptr %2, align 1
  ret i1 %47

48:                                               ; preds = %43
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN3rleL17skip_row_internalERNS_6sourceEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 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 #3 = { inlinehint 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 #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN3rle11rle_decoderE", !6, i64 0}
!13 = !{!14, !10, i64 88}
!14 = !{!"_ZTSN3rle11rle_decoder8internalE", !15, i64 0, !18, i64 12, !6, i64 80, !10, i64 88, !19, i64 96, !7, i64 120, !7, i64 2168}
!15 = !{!"_ZTSN3rle10image_infoE", !10, i64 0, !10, i64 4, !16, i64 8, !17, i64 10, !17, i64 11}
!16 = !{!"_ZTSN3rle10pixel_infoE", !7, i64 0, !7, i64 1}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN3rle6headerE", !10, i64 0, !7, i64 4}
!19 = !{!"_ZTSSt6vectorIcSaIcEE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIcSaIcEE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!14, !6, i64 80}
!24 = !{!17, !17, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = distinct !{!27, !28}
!28 = !{!"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 nounwind uwtable
declare dso_local noundef i32 @_ZNK3rle10image_info9get_widthEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3rle11rle_decoder8skip_rowEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0) local_unnamed_addr #1 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 88
  %4 = load i32, ptr %3, align 8, !tbaa !10
  %5 = icmp slt i32 %4, 1
  br i1 %5, label %._crit_edge, label %.lr.ph

6:                                                ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 88
  %9 = load i32, ptr %8, align 8, !tbaa !10
  %10 = sext i32 %9 to i64
  %.not = icmp slt i64 %indvars.iv.next, %10
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !21

.lr.ph:                                           ; preds = %1, %6
  %indvars.iv = phi i64 [ %indvars.iv.next, %6 ], [ 0, %1 ]
  %11 = phi ptr [ %7, %6 ], [ %2, %1 ]
  %12 = getelementptr inbounds i8, ptr %11, i64 80
  %13 = load ptr, ptr %12, align 8, !tbaa !23
  %14 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv
  %15 = load ptr, ptr %14, align 8, !tbaa !24
  %16 = tail call noundef i32 @_ZNK3rle10image_info9get_widthEv(ptr noundef nonnull align 4 dereferenceable(12) %11)
  %17 = tail call noundef zeroext i1 @_ZN3rleL17skip_row_internalERNS_6sourceEi(ptr noundef nonnull align 8 dereferenceable(8) %15, i32 noundef %16)
  br i1 %17, label %6, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %6, %1
  %.lcssa = phi i1 [ true, %1 ], [ %17, %6 ], [ %17, %.lr.ph ]
  ret i1 %.lcssa
}

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef zeroext i1 @_ZN3rleL17skip_row_internalERNS_6sourceEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 #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 = { inlinehint 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 0}
!6 = !{!"_ZTSN3rle11rle_decoderE", !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !13, i64 88}
!11 = !{!"_ZTSN3rle11rle_decoder8internalE", !12, i64 0, !16, i64 12, !7, i64 80, !13, i64 88, !17, i64 96, !8, i64 120, !8, i64 2168}
!12 = !{!"_ZTSN3rle10image_infoE", !13, i64 0, !13, i64 4, !14, i64 8, !15, i64 10, !15, i64 11}
!13 = !{!"int", !8, i64 0}
!14 = !{!"_ZTSN3rle10pixel_infoE", !8, i64 0, !8, i64 1}
!15 = !{!"bool", !8, i64 0}
!16 = !{!"_ZTSN3rle6headerE", !13, i64 0, !8, i64 4}
!17 = !{!"_ZTSSt6vectorIcSaIcEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIcSaIcEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIcSaIcEE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!11, !7, i64 80}
!24 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass