; LLVM IR from rdguez-mariano/fast_imas_IPOL :: io_png/libs/png (pngrtran)

; 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.png_row_info_struct = type { i64, i64, i8, i8, i8, i8 }

; 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 void @png_do_chop(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.png_row_info_struct, ptr %9, i32 0, i32 3
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = icmp eq i32 %12, 16
  br i1 %13, label %14, label %61

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %15, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.png_row_info_struct, ptr %17, i32 0, i32 0
  %19 = load i64, ptr %18, align 8, !tbaa !12
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.png_row_info_struct, ptr %20, i32 0, i32 4
  %22 = load i8, ptr %21, align 2, !tbaa !13
  %23 = zext i8 %22 to i64
  %24 = mul i64 %19, %23
  store i64 %24, ptr %8, align 8, !tbaa !14
  store i64 0, ptr %7, align 8, !tbaa !14
  br label %25

25:                                               ; preds = %33, %14
  %26 = load i64, ptr %7, align 8, !tbaa !14
  %27 = load i64, ptr %8, align 8, !tbaa !14
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %29, label %40

29:                                               ; preds = %25
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !15
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 %31, ptr %32, align 1, !tbaa !15
  br label %33

33:                                               ; preds = %29
  %34 = load i64, ptr %7, align 8, !tbaa !14
  %35 = add i64 %34, 1
  store i64 %35, ptr %7, align 8, !tbaa !14
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 2
  store ptr %37, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i32 1
  store ptr %39, ptr %6, align 8, !tbaa !5
  br label %25, !llvm.loop !16

40:                                               ; preds = %25
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.png_row_info_struct, ptr %41, i32 0, i32 3
  store i8 8, ptr %42, align 1, !tbaa !9
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.png_row_info_struct, ptr %43, i32 0, i32 4
  %45 = load i8, ptr %44, align 2, !tbaa !13
  %46 = zext i8 %45 to i32
  %47 = mul nsw i32 8, %46
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.png_row_info_struct, ptr %49, i32 0, i32 5
  store i8 %48, ptr %50, align 1, !tbaa !18
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.png_row_info_struct, ptr %51, i32 0, i32 0
  %53 = load i64, ptr %52, align 8, !tbaa !12
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.png_row_info_struct, ptr %54, i32 0, i32 4
  %56 = load i8, ptr %55, align 2, !tbaa !13
  %57 = zext i8 %56 to i64
  %58 = mul i64 %53, %57
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.png_row_info_struct, ptr %59, i32 0, i32 1
  store i64 %58, ptr %60, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %61

61:                                               ; preds = %40, %2
  ret void
}

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, !7, i64 17}
!10 = !{!"png_row_info_struct", !11, i64 0, !11, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !7, i64 18}
!14 = !{!11, !11, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !7, i64 19}
!19 = !{!10, !11, i64 8}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @png_do_chop(ptr nocapture noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 17
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %5 = icmp eq i8 %4, 16
  br i1 %5, label %6, label %44

6:                                                ; preds = %2
  %7 = load i64, ptr %0, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %0, i64 18
  %9 = load i8, ptr %8, align 2, !tbaa !11
  %10 = zext i8 %9 to i64
  %11 = mul i64 %7, %10
  %.not = icmp eq i64 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %xtraiter = and i64 %11, 7
  %12 = icmp ult i64 %11, 8
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %11, -8
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.021 = phi ptr [ %1, %.lr.ph.preheader.new ], [ %35, %.lr.ph ]
  %.01819 = phi ptr [ %1, %.lr.ph.preheader.new ], [ %36, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %13 = load i8, ptr %.021, align 1, !tbaa !12
  store i8 %13, ptr %.01819, align 1, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %.021, i64 2
  %15 = getelementptr inbounds i8, ptr %.01819, i64 1
  %16 = load i8, ptr %14, align 1, !tbaa !12
  store i8 %16, ptr %15, align 1, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %.021, i64 4
  %18 = getelementptr inbounds i8, ptr %.01819, i64 2
  %19 = load i8, ptr %17, align 1, !tbaa !12
  store i8 %19, ptr %18, align 1, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %.021, i64 6
  %21 = getelementptr inbounds i8, ptr %.01819, i64 3
  %22 = load i8, ptr %20, align 1, !tbaa !12
  store i8 %22, ptr %21, align 1, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %.021, i64 8
  %24 = getelementptr inbounds i8, ptr %.01819, i64 4
  %25 = load i8, ptr %23, align 1, !tbaa !12
  store i8 %25, ptr %24, align 1, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %.021, i64 10
  %27 = getelementptr inbounds i8, ptr %.01819, i64 5
  %28 = load i8, ptr %26, align 1, !tbaa !12
  store i8 %28, ptr %27, align 1, !tbaa !12
  %29 = getelementptr inbounds i8, ptr %.021, i64 12
  %30 = getelementptr inbounds i8, ptr %.01819, i64 6
  %31 = load i8, ptr %29, align 1, !tbaa !12
  store i8 %31, ptr %30, align 1, !tbaa !12
  %32 = getelementptr inbounds i8, ptr %.021, i64 14
  %33 = getelementptr inbounds i8, ptr %.01819, i64 7
  %34 = load i8, ptr %32, align 1, !tbaa !12
  store i8 %34, ptr %33, align 1, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %.021, i64 16
  %36 = getelementptr inbounds i8, ptr %.01819, i64 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !13

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.021.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %35, %.lr.ph ]
  %.01819.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %36, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %.021.epil = phi ptr [ %38, %.lr.ph.epil ], [ %.021.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01819.epil = phi ptr [ %39, %.lr.ph.epil ], [ %.01819.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %37 = load i8, ptr %.021.epil, align 1, !tbaa !12
  store i8 %37, ptr %.01819.epil, align 1, !tbaa !12
  %38 = getelementptr inbounds i8, ptr %.021.epil, i64 2
  %39 = getelementptr inbounds i8, ptr %.01819.epil, i64 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.loopexit, label %.lr.ph.epil, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa
  %.pre = load i8, ptr %8, align 2, !tbaa !11
  %.pre22 = load i64, ptr %0, align 8, !tbaa !10
  %.pre23 = zext i8 %.pre to i64
  %.pre24 = mul i64 %.pre22, %.pre23
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %6
  %.pre-phi25 = phi i64 [ %.pre24, %._crit_edge.loopexit ], [ 0, %6 ]
  %40 = phi i8 [ %.pre, %._crit_edge.loopexit ], [ %9, %6 ]
  store i8 8, ptr %3, align 1, !tbaa !5
  %41 = shl i8 %40, 3
  %42 = getelementptr inbounds i8, ptr %0, i64 19
  store i8 %41, ptr %42, align 1, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %.pre-phi25, ptr %43, align 8, !tbaa !18
  br label %44

44:                                               ; preds = %._crit_edge, %2
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !8, i64 17}
!6 = !{!"png_row_info_struct", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!6, !8, i64 18}
!12 = !{!8, !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = !{!6, !8, i64 19}
!18 = !{!6, !7, i64 8}


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