; LLVM IR from kimwalisch/primesieve :: src/iterator.ll (ZN10primesieve8iterator7jump_toEmm)

; 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.primesieve::iterator" = type { i64, i64, i64, i64, ptr, ptr }
%"struct.primesieve::IteratorData" = type { i64, i64, i8, ptr, %"class.primesieve::Vector", [1720 x i8] }
%"class.primesieve::Vector" = type { ptr, ptr, ptr }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10primesieve8iterator7jump_toEmm(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %1, i64 noundef %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 0
  store i64 0, ptr %9, align 8, !tbaa !11
  %10 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 1
  store i64 0, ptr %10, align 8, !tbaa !13
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 2
  store i64 %11, ptr %12, align 8, !tbaa !14
  %13 = load i64, ptr %6, align 8, !tbaa !9
  %14 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 3
  store i64 %13, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 4
  store ptr null, ptr %15, align 8, !tbaa !16
  %16 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 5
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %33

19:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %20 = getelementptr inbounds %"struct.primesieve::iterator", ptr %8, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  store ptr %21, ptr %7, align 8, !tbaa !5
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %23, i32 0, i32 0
  store i64 %22, ptr %24, align 8, !tbaa !18
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %25, i32 0, i32 1
  store i64 0, ptr %26, align 8, !tbaa !22
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %27, i32 0, i32 2
  store i8 1, ptr %28, align 8, !tbaa !23
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %29)
          to label %30 unwind label %34

30:                                               ; preds = %19
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN10primesieve12IteratorData12deletePrimesEv(ptr noundef nonnull align 8 dereferenceable(1776) %31)
          to label %32 unwind label %34

32:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %33

33:                                               ; preds = %32, %3
  ret void

34:                                               ; preds = %30, %19
  %35 = landingpad { ptr, i32 }
          catch ptr null
  %36 = extractvalue { ptr, i32 } %35, 0
  call void @__clang_call_terminate(ptr %36) #4
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10primesieve12IteratorData12deletePrimesEv(ptr noundef nonnull align 8 dereferenceable(1776)) #1 align 2

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

attributes #0 = { noinline noreturn nounwind uwtable "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 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }
attributes #4 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN10primesieve8iteratorE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !6, i64 40}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 40}
!18 = !{!19, !10, i64 0}
!19 = !{!"_ZTSN10primesieve12IteratorDataE", !10, i64 0, !10, i64 8, !20, i64 16, !6, i64 24, !21, i64 32, !7, i64 56}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTSN10primesieve6VectorImSaImEEE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!19, !10, i64 8}
!23 = !{!19, !20, i64 16}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10primesieve8iterator7jump_toEmm(ptr nocapture noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %0, i8 0, i64 16, i1 false)
  store i64 %1, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %2, ptr %5, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr null, ptr %6, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %12, label %9

9:                                                ; preds = %3
  store i64 %1, ptr %8, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 0, ptr %10, align 8, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %8, i64 16
  store i8 1, ptr %11, align 8, !tbaa !19
  tail call void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %8)
  tail call void @_ZN10primesieve12IteratorData12deletePrimesEv(ptr noundef nonnull align 8 dereferenceable(1776) %8)
  br label %12

12:                                               ; preds = %9, %3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10primesieve12IteratorData12deletePrimesEv(ptr noundef nonnull align 8 dereferenceable(1776)) local_unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress 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 nounwind willreturn memory(argmem: write) }

!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 16}
!6 = !{!"_ZTSN10primesieve8iteratorE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !10, i64 40}
!14 = !{!15, !7, i64 0}
!15 = !{!"_ZTSN10primesieve12IteratorDataE", !7, i64 0, !7, i64 8, !16, i64 16, !10, i64 24, !17, i64 32, !8, i64 56}
!16 = !{!"bool", !8, i64 0}
!17 = !{!"_ZTSN10primesieve6VectorImSaImEEE", !10, i64 0, !10, i64 8, !10, i64 16}
!18 = !{!15, !7, i64 8}
!19 = !{!15, !16, i64 16}


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