; 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.31 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @Malloc(i64 noundef, ptr noundef) #0

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

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Clone_Kmer_Cache(ptr noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %11 = call ptr @Malloc(i64 noundef 136, ptr noundef @.str.31)
  store ptr %11, ptr %9, align 8, !tbaa !5
  %12 = load ptr, ptr %9, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %4
  call void @exit(i32 noundef 1) #7
  unreachable

15:                                               ; preds = %4
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %17, i64 136, i1 false), !tbaa.struct !13
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct._Kmer_Stream, ptr %18, i32 0, i32 23
  store i32 1, ptr %19, align 8, !tbaa !14
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._Kmer_Stream, ptr %20, i32 0, i32 10
  %22 = load i32, ptr %21, align 4, !tbaa !16
  %23 = mul nsw i32 1024, %22
  %24 = sext i32 %23 to i64
  %25 = call ptr @Malloc(i64 noundef %24, ptr noundef @.str.34)
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._Kmer_Stream, ptr %26, i32 0, i32 13
  store ptr %25, ptr %27, align 8, !tbaa !17
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._Kmer_Stream, ptr %28, i32 0, i32 20
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = call i32 (ptr, i32, ...) @open(ptr noundef %30, i32 noundef 0)
  store i32 %31, ptr %10, align 4, !tbaa !11
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = load i64, ptr %7, align 8, !tbaa !9
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = sub nsw i64 %33, %34
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._Kmer_Stream, ptr %36, i32 0, i32 10
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = sext i32 %38 to i64
  %40 = mul nsw i64 %35, %39
  %41 = call i64 @lseek(i32 noundef %32, i64 noundef %40, i32 noundef 0) #6
  %42 = load i32, ptr %10, align 4, !tbaa !11
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._Kmer_Stream, ptr %43, i32 0, i32 16
  store i32 %42, ptr %44, align 8, !tbaa !19
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._Kmer_Stream, ptr %46, i32 0, i32 3
  store i64 %45, ptr %47, align 8, !tbaa !20
  %48 = load i32, ptr %8, align 4, !tbaa !11
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._Kmer_Stream, ptr %49, i32 0, i32 5
  store i32 %48, ptr %50, align 8, !tbaa !21
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  call void @More_Kmer_Stream(ptr noundef %51)
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret ptr %52
}

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 #3 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn 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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 8, !9, i64 16, i64 8, !9, i64 24, i64 8, !5, i64 32, i64 4, !11, i64 36, i64 4, !11, i64 40, i64 4, !11, i64 44, i64 4, !11, i64 48, i64 4, !11, i64 52, i64 4, !11, i64 56, i64 4, !11, i64 60, i64 4, !11, i64 64, i64 8, !5, i64 72, i64 8, !5, i64 80, i64 8, !5, i64 88, i64 4, !11, i64 92, i64 4, !11, i64 96, i64 4, !11, i64 100, i64 4, !11, i64 104, i64 8, !5, i64 112, i64 8, !5, i64 120, i64 8, !5, i64 128, i64 4, !11}
!14 = !{!15, !12, i64 128}
!15 = !{!"", !12, i64 0, !12, i64 4, !10, i64 8, !10, i64 16, !6, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !12, i64 128}
!16 = !{!15, !12, i64 52}
!17 = !{!15, !6, i64 64}
!18 = !{!15, !6, i64 104}
!19 = !{!15, !12, i64 88}
!20 = !{!15, !10, i64 16}
!21 = !{!15, !12, i64 32}


; 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.31 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [25 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @Malloc(i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 #0

; Function Attrs: nounwind uwtable
define dso_local ptr @Clone_Kmer_Cache(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call ptr @Malloc(i64 noundef 136, ptr noundef nonnull @.str.31)
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %4
  tail call void @exit(i32 noundef 1) #5
  unreachable

8:                                                ; preds = %4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %5, ptr noundef nonnull align 8 dereferenceable(136) %0, i64 136, i1 false), !tbaa.struct !5
  %9 = getelementptr inbounds i8, ptr %5, i64 128
  store i32 1, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %5, i64 52
  %11 = load i32, ptr %10, align 4, !tbaa !16
  %12 = shl nsw i32 %11, 10
  %13 = sext i32 %12 to i64
  %14 = tail call ptr @Malloc(i64 noundef %13, ptr noundef nonnull @.str.34)
  %15 = getelementptr inbounds i8, ptr %5, i64 64
  store ptr %14, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %5, i64 104
  %17 = load ptr, ptr %16, align 8, !tbaa !18
  %18 = tail call i32 (ptr, i32, ...) @open(ptr noundef %17, i32 noundef 0) #6
  %19 = sub nsw i64 %2, %1
  %20 = load i32, ptr %10, align 4, !tbaa !16
  %21 = sext i32 %20 to i64
  %22 = mul nsw i64 %19, %21
  %23 = tail call i64 @lseek(i32 noundef %18, i64 noundef %22, i32 noundef 0) #6
  %24 = getelementptr inbounds i8, ptr %5, i64 88
  store i32 %18, ptr %24, align 8, !tbaa !19
  %25 = getelementptr inbounds i8, ptr %5, i64 16
  store i64 %2, ptr %25, align 8, !tbaa !20
  %26 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 %3, ptr %26, align 8, !tbaa !21
  tail call void @More_Kmer_Stream(ptr noundef nonnull %5)
  ret ptr %5
}

attributes #0 = { 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 = { noreturn 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 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn nounwind }
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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 8, !10, i64 16, i64 8, !10, i64 24, i64 8, !12, i64 32, i64 4, !6, i64 36, i64 4, !6, i64 40, i64 4, !6, i64 44, i64 4, !6, i64 48, i64 4, !6, i64 52, i64 4, !6, i64 56, i64 4, !6, i64 60, i64 4, !6, i64 64, i64 8, !12, i64 72, i64 8, !12, i64 80, i64 8, !12, i64 88, i64 4, !6, i64 92, i64 4, !6, i64 96, i64 4, !6, i64 100, i64 4, !6, i64 104, i64 8, !12, i64 112, i64 8, !12, i64 120, i64 8, !12, i64 128, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!15, !7, i64 128}
!15 = !{!"", !7, i64 0, !7, i64 4, !11, i64 8, !11, i64 16, !13, 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, !13, i64 64, !13, i64 72, !13, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !7, i64 100, !13, i64 104, !13, i64 112, !13, i64 120, !7, i64 128}
!16 = !{!15, !7, i64 52}
!17 = !{!15, !13, i64 64}
!18 = !{!15, !13, i64 104}
!19 = !{!15, !7, i64 88}
!20 = !{!15, !11, i64 16}
!21 = !{!15, !7, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass