; LLVM IR from KamilSJaron/smudgeplot :: src_ploidyplot (gene_core)

; 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
define dso_local void @Uncompress_Read(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %13 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %13, ptr %8, align 8, !tbaa !9
  %14 = load ptr, ptr %8, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %14, i64 1
  store ptr %15, ptr %9, align 8, !tbaa !9
  %16 = load ptr, ptr %9, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 1
  store ptr %17, ptr %10, align 8, !tbaa !9
  %18 = load ptr, ptr %10, align 8, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %18, i64 1
  store ptr %19, ptr %11, align 8, !tbaa !9
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sub nsw i32 %20, 1
  %22 = sdiv i32 %21, 4
  store i32 %22, ptr %6, align 4, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  store ptr %26, ptr %12, align 8, !tbaa !9
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = mul nsw i32 %27, 4
  store i32 %28, ptr %5, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %68, %2
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = icmp sge i32 %30, 0
  br i1 %31, label %32, label %71

32:                                               ; preds = %29
  %33 = load ptr, ptr %12, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %33, i32 -1
  store ptr %34, ptr %12, align 8, !tbaa !9
  %35 = load i8, ptr %33, align 1, !tbaa !11
  %36 = sext i8 %35 to i32
  store i32 %36, ptr %7, align 4, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = ashr i32 %37, 6
  %39 = and i32 %38, 3
  %40 = trunc i32 %39 to i8
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  store i8 %40, ptr %44, align 1, !tbaa !11
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = ashr i32 %45, 4
  %47 = and i32 %46, 3
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %49, i64 %51
  store i8 %48, ptr %52, align 1, !tbaa !11
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = ashr i32 %53, 2
  %55 = and i32 %54, 3
  %56 = trunc i32 %55 to i8
  %57 = load ptr, ptr %10, align 8, !tbaa !9
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %57, i64 %59
  store i8 %56, ptr %60, align 1, !tbaa !11
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = and i32 %61, 3
  %63 = trunc i32 %62 to i8
  %64 = load ptr, ptr %11, align 8, !tbaa !9
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %64, i64 %66
  store i8 %63, ptr %67, align 1, !tbaa !11
  br label %68

68:                                               ; preds = %32
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sub nsw i32 %69, 4
  store i32 %70, ptr %5, align 4, !tbaa !5
  br label %29, !llvm.loop !12

71:                                               ; preds = %29
  %72 = load ptr, ptr %4, align 8, !tbaa !9
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %72, i64 %74
  store i8 4, ptr %75, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @Uncompress_Read(i32 noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 1
  %4 = getelementptr inbounds i8, ptr %1, i64 2
  %5 = getelementptr inbounds i8, ptr %1, i64 3
  %6 = icmp sgt i32 %0, -3
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %7 = add nsw i32 %0, -1
  %8 = sdiv i32 %7, 4
  %9 = shl nuw nsw i32 %8, 2
  %10 = zext nneg i32 %8 to i64
  %11 = getelementptr inbounds i8, ptr %1, i64 %10
  %12 = zext nneg i32 %9 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %12, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.026 = phi ptr [ %11, %.lr.ph.preheader ], [ %13, %.lr.ph ]
  %13 = getelementptr inbounds i8, ptr %.026, i64 -1
  %14 = load i8, ptr %.026, align 1, !tbaa !5
  %15 = lshr i8 %14, 6
  %16 = getelementptr inbounds i8, ptr %1, i64 %indvars.iv
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = lshr i8 %14, 4
  %18 = and i8 %17, 3
  %19 = getelementptr inbounds i8, ptr %3, i64 %indvars.iv
  store i8 %18, ptr %19, align 1, !tbaa !5
  %20 = lshr i8 %14, 2
  %21 = and i8 %20, 3
  %22 = getelementptr inbounds i8, ptr %4, i64 %indvars.iv
  store i8 %21, ptr %22, align 1, !tbaa !5
  %23 = and i8 %14, 3
  %24 = getelementptr inbounds i8, ptr %5, i64 %indvars.iv
  store i8 %23, ptr %24, align 1, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, -4
  %25 = trunc nuw i64 %indvars.iv to i32
  %26 = icmp sgt i32 %25, 3
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %2
  %27 = sext i32 %0 to i64
  %28 = getelementptr inbounds i8, ptr %1, i64 %27
  store i8 4, ptr %28, align 1, !tbaa !5
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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