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

; 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._Kmer_Stream = type { i32, i32, i64, i64, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, ptr, ptr, ptr, 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: inlinehint nounwind uwtable
define dso_local void @Next_Kmer_Entry(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct._Kmer_Stream, ptr %6, i32 0, i32 10
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._Kmer_Stream, ptr %9, i32 0, i32 4
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = sext i32 %8 to i64
  %13 = getelementptr inbounds i8, ptr %11, i64 %12
  store ptr %13, ptr %10, align 8, !tbaa !13
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._Kmer_Stream, ptr %14, i32 0, i32 3
  %16 = load i64, ptr %15, align 8, !tbaa !14
  %17 = add nsw i64 %16, 1
  store i64 %17, ptr %15, align 8, !tbaa !14
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._Kmer_Stream, ptr %18, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._Kmer_Stream, ptr %21, i32 0, i32 21
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = icmp uge ptr %20, %23
  br i1 %24, label %25, label %49

25:                                               ; preds = %1
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._Kmer_Stream, ptr %26, i32 0, i32 3
  %28 = load i64, ptr %27, align 8, !tbaa !14
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct._Kmer_Stream, ptr %29, i32 0, i32 2
  %31 = load i64, ptr %30, align 8, !tbaa !16
  %32 = icmp sge i64 %28, %31
  br i1 %32, label %33, label %47

33:                                               ; preds = %25
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._Kmer_Stream, ptr %34, i32 0, i32 4
  store ptr null, ptr %35, align 8, !tbaa !13
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._Kmer_Stream, ptr %36, i32 0, i32 11
  %38 = load i32, ptr %37, align 8, !tbaa !17
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._Kmer_Stream, ptr %39, i32 0, i32 5
  store i32 %38, ptr %40, align 8, !tbaa !18
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._Kmer_Stream, ptr %41, i32 0, i32 18
  %43 = load i32, ptr %42, align 8, !tbaa !19
  %44 = add nsw i32 %43, 1
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._Kmer_Stream, ptr %45, i32 0, i32 17
  store i32 %44, ptr %46, align 4, !tbaa !20
  store i32 1, ptr %4, align 4
  br label %70

47:                                               ; preds = %25
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  call void @More_Kmer_Stream(ptr noundef %48)
  br label %49

49:                                               ; preds = %47, %1
  br label %50

50:                                               ; preds = %64, %49
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._Kmer_Stream, ptr %51, i32 0, i32 14
  %53 = load ptr, ptr %52, align 8, !tbaa !21
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._Kmer_Stream, ptr %54, i32 0, i32 5
  %56 = load i32, ptr %55, align 8, !tbaa !18
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i64, ptr %53, i64 %57
  %59 = load i64, ptr %58, align 8, !tbaa !22
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._Kmer_Stream, ptr %60, i32 0, i32 3
  %62 = load i64, ptr %61, align 8, !tbaa !14
  %63 = icmp sle i64 %59, %62
  br i1 %63, label %64, label %69

64:                                               ; preds = %50
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._Kmer_Stream, ptr %65, i32 0, i32 5
  %67 = load i32, ptr %66, align 8, !tbaa !18
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %66, align 8, !tbaa !18
  br label %50, !llvm.loop !23

69:                                               ; preds = %50
  store i32 0, ptr %4, align 4
  br label %70

70:                                               ; preds = %69, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %71 = load i32, ptr %4, align 4
  switch i32 %71, label %73 [
    i32 0, label %72
    i32 1, label %72
  ]

72:                                               ; preds = %70, %70
  ret void

73:                                               ; preds = %70
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden void @More_Kmer_Stream(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 = { 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, !11, i64 52}
!10 = !{!"", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !11, i64 128}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !12, i64 16}
!15 = !{!10, !6, i64 112}
!16 = !{!10, !12, i64 8}
!17 = !{!10, !11, i64 56}
!18 = !{!10, !11, i64 32}
!19 = !{!10, !11, i64 96}
!20 = !{!10, !11, i64 92}
!21 = !{!10, !6, i64 72}
!22 = !{!12, !12, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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: inlinehint nounwind uwtable
define dso_local void @Next_Kmer_Entry(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 52
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %6 = sext i32 %3 to i64
  %7 = getelementptr inbounds i8, ptr %5, i64 %6
  store ptr %7, ptr %4, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i64, ptr %8, align 8, !tbaa !13
  %10 = add nsw i64 %9, 1
  store i64 %10, ptr %8, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %.not = icmp ult ptr %7, %12
  br i1 %.not, label %25, label %13

13:                                               ; preds = %1
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !15
  %.not18 = icmp slt i64 %10, %15
  br i1 %.not18, label %24, label %16

16:                                               ; preds = %13
  store ptr null, ptr %4, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  %18 = load i32, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %18, ptr %19, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %0, i64 96
  %21 = load i32, ptr %20, align 8, !tbaa !18
  %22 = add nsw i32 %21, 1
  %23 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 %22, ptr %23, align 4, !tbaa !19
  br label %.loopexit

24:                                               ; preds = %13
  tail call void @More_Kmer_Stream(ptr noundef nonnull %0)
  %.pre = load i64, ptr %8, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %24, %1
  %26 = phi i64 [ %.pre, %24 ], [ %10, %1 ]
  %27 = getelementptr inbounds i8, ptr %0, i64 72
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %29 = getelementptr inbounds i8, ptr %0, i64 32
  %.promoted = load i32, ptr %29, align 8, !tbaa !17
  %30 = sext i32 %.promoted to i64
  %31 = getelementptr inbounds i64, ptr %28, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !21
  %.not1920 = icmp sgt i64 %32, %26
  br i1 %.not1920, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %25, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %30, %25 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %33 = getelementptr inbounds i64, ptr %28, i64 %indvars.iv.next
  %34 = load i64, ptr %33, align 8, !tbaa !21
  %.not19 = icmp sgt i64 %34, %26
  br i1 %.not19, label %..loopexit_crit_edge, label %.lr.ph, !llvm.loop !22

..loopexit_crit_edge:                             ; preds = %.lr.ph
  %35 = trunc nsw i64 %indvars.iv.next to i32
  store i32 %35, ptr %29, align 8, !tbaa !17
  br label %.loopexit

.loopexit:                                        ; preds = %25, %..loopexit_crit_edge, %16
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @More_Kmer_Stream(ptr noundef) local_unnamed_addr #1

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

!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 52}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !11, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !11, i64 64, !11, i64 72, !11, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !11, i64 104, !11, i64 112, !11, i64 120, !7, i64 128}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 24}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !11, i64 112}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !7, i64 56}
!17 = !{!6, !7, i64 32}
!18 = !{!6, !7, i64 96}
!19 = !{!6, !7, i64 92}
!20 = !{!6, !11, i64 72}
!21 = !{!10, !10, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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