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

@.str.28 = external hidden unnamed_addr constant [3 x i8], align 1

; 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
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

declare i32 @open(ptr noundef, i32 noundef, ...) #2

declare i32 @close(i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
define dso_local void @First_Kmer_Entry(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %5, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct._Kmer_Stream, ptr %6, i32 0, i32 14
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct._Kmer_Stream, ptr %9, i32 0, i32 3
  %11 = load i64, ptr %10, align 8, !tbaa !13
  %12 = icmp ne i64 %11, 0
  br i1 %12, label %13, label %74

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._Kmer_Stream, ptr %14, i32 0, i32 17
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %17 = icmp ne i32 %16, 1
  br i1 %17, label %18, label %49

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._Kmer_Stream, ptr %19, i32 0, i32 17
  %21 = load i32, ptr %20, align 4, !tbaa !14
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._Kmer_Stream, ptr %22, i32 0, i32 18
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = icmp sle i32 %21, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %18
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._Kmer_Stream, ptr %27, i32 0, i32 16
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = call i32 @close(i32 noundef %29)
  br label %31

31:                                               ; preds = %26, %18
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._Kmer_Stream, ptr %32, i32 0, i32 20
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._Kmer_Stream, ptr %35, i32 0, i32 19
  %37 = load i32, ptr %36, align 4, !tbaa !18
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %34, i64 %38
  %40 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %39, ptr noundef @.str.28, i32 noundef 1) #5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._Kmer_Stream, ptr %41, i32 0, i32 20
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = call i32 (ptr, i32, ...) @open(ptr noundef %43, i32 noundef 0)
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._Kmer_Stream, ptr %45, i32 0, i32 16
  store i32 %44, ptr %46, align 8, !tbaa !16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._Kmer_Stream, ptr %47, i32 0, i32 17
  store i32 1, ptr %48, align 4, !tbaa !14
  br label %49

49:                                               ; preds = %31, %13
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._Kmer_Stream, ptr %50, i32 0, i32 16
  %52 = load i32, ptr %51, align 8, !tbaa !16
  %53 = call i64 @lseek(i32 noundef %52, i64 noundef 12, i32 noundef 0) #5
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  call void @More_Kmer_Stream(ptr noundef %54)
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._Kmer_Stream, ptr %55, i32 0, i32 3
  store i64 0, ptr %56, align 8, !tbaa !13
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._Kmer_Stream, ptr %57, i32 0, i32 5
  store i32 0, ptr %58, align 8, !tbaa !19
  br label %59

59:                                               ; preds = %68, %49
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._Kmer_Stream, ptr %61, i32 0, i32 5
  %63 = load i32, ptr %62, align 8, !tbaa !19
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i64, ptr %60, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !20
  %67 = icmp sle i64 %66, 0
  br i1 %67, label %68, label %73

68:                                               ; preds = %59
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._Kmer_Stream, ptr %69, i32 0, i32 5
  %71 = load i32, ptr %70, align 8, !tbaa !19
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %70, align 8, !tbaa !19
  br label %59, !llvm.loop !21

73:                                               ; preds = %59
  br label %74

74:                                               ; preds = %73, %1
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { "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 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 #4 = { 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 #5 = { 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, !6, i64 72}
!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, !12, i64 16}
!14 = !{!10, !11, i64 92}
!15 = !{!10, !11, i64 96}
!16 = !{!10, !11, i64 88}
!17 = !{!10, !6, i64 104}
!18 = !{!10, !11, i64 100}
!19 = !{!10, !11, i64 32}
!20 = !{!12, !12, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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"

@.str.28 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #1

declare i32 @close(i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
define dso_local void @First_Kmer_Entry(ptr noundef %0) local_unnamed_addr #3 {
  %2 = getelementptr inbounds i8, ptr %0, i64 72
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i64, ptr %4, align 8, !tbaa !12
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %36, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 92
  %8 = load i32, ptr %7, align 4, !tbaa !13
  %.not19 = icmp eq i32 %8, 1
  br i1 %.not19, label %._crit_edge, label %9

._crit_edge:                                      ; preds = %6
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 88
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !14
  br label %27

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %.not20 = icmp sgt i32 %8, %11
  br i1 %.not20, label %16, label %12

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  %14 = load i32, ptr %13, align 8, !tbaa !14
  %15 = tail call i32 @close(i32 noundef %14) #6
  br label %16

16:                                               ; preds = %12, %9
  %17 = getelementptr inbounds i8, ptr %0, i64 104
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %0, i64 100
  %20 = load i32, ptr %19, align 4, !tbaa !17
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %18, i64 %21
  %23 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %22, ptr noundef nonnull dereferenceable(1) @.str.28, i32 noundef 1) #6
  %24 = load ptr, ptr %17, align 8, !tbaa !16
  %25 = tail call i32 (ptr, i32, ...) @open(ptr noundef %24, i32 noundef 0) #6
  %26 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 %25, ptr %26, align 8, !tbaa !14
  store i32 1, ptr %7, align 4, !tbaa !13
  br label %27

27:                                               ; preds = %._crit_edge, %16
  %28 = phi i32 [ %.pre, %._crit_edge ], [ %25, %16 ]
  %29 = tail call i64 @lseek(i32 noundef %28, i64 noundef 12, i32 noundef 0) #6
  tail call void @More_Kmer_Stream(ptr noundef nonnull %0)
  store i64 0, ptr %4, align 8, !tbaa !12
  br label %30

30:                                               ; preds = %30, %27
  %indvars.iv = phi i64 [ %indvars.iv.next, %30 ], [ 0, %27 ]
  %31 = getelementptr inbounds i64, ptr %3, i64 %indvars.iv
  %32 = load i64, ptr %31, align 8, !tbaa !18
  %33 = icmp slt i64 %32, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br i1 %33, label %30, label %.loopexit, !llvm.loop !19

.loopexit:                                        ; preds = %30
  %34 = getelementptr inbounds i8, ptr %0, i64 32
  %35 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %35, ptr %34, align 8, !tbaa !21
  br label %36

36:                                               ; preds = %.loopexit, %1
  ret void
}

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #4

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

attributes #0 = { nofree nounwind "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 = { nofree "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 = { "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 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 #4 = { nounwind "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 #5 = { 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 #6 = { 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, !11, i64 72}
!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, !10, i64 16}
!13 = !{!6, !7, i64 92}
!14 = !{!6, !7, i64 88}
!15 = !{!6, !7, i64 96}
!16 = !{!6, !11, i64 104}
!17 = !{!6, !7, i64 100}
!18 = !{!10, !10, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !7, i64 32}


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