; LLVM IR from kimwalisch/primesieve :: src (iterator-c)

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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.primesieve_iterator = type { i64, i64, i64, i64, ptr, ptr, i32 }
%"struct.primesieve::IteratorData" = type { i64, i64, i8, ptr, %"class.primesieve::Vector", [1720 x i8] }
%"class.primesieve::Vector" = type { ptr, ptr, ptr }

@_ZTISt9exception = external constant ptr
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [22 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: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(1776) ptr @_ZN12_GLOBAL__N_111getIterDataEP19primesieve_iterator(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(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) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @primesieve_clear(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @primesieve_generate_next_primes(ptr noundef %0) #4 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.primesieve_iterator, ptr %10, i32 0, i32 5
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %31, label %14

14:                                               ; preds = %1
  %15 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 1776) #12
          to label %16 unwind label %23

16:                                               ; preds = %14
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.primesieve_iterator, ptr %17, i32 0, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !13
  invoke void @_ZN10primesieve12IteratorDataC2Em(ptr noundef nonnull align 8 dereferenceable(1776) %15, i64 noundef %19)
          to label %20 unwind label %27

20:                                               ; preds = %16
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.primesieve_iterator, ptr %21, i32 0, i32 5
  store ptr %15, ptr %22, align 8, !tbaa !9
  br label %31

23:                                               ; preds = %14
  %24 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %3, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %4, align 4
  br label %96

27:                                               ; preds = %16
  %28 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %3, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %4, align 4
  call void @_ZdlPvm(ptr noundef %15, i64 noundef 1776) #13
  br label %96

31:                                               ; preds = %20, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #14
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = invoke noundef nonnull align 8 dereferenceable(1776) ptr @_ZN12_GLOBAL__N_111getIterDataEP19primesieve_iterator(ptr noundef %32)
          to label %34 unwind label %59

34:                                               ; preds = %31
  store ptr %33, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #14
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %35, i32 0, i32 4
  store ptr %36, ptr %6, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %94, %34
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = icmp ne ptr %41, null
  br i1 %42, label %67, label %43

43:                                               ; preds = %38
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.primesieve_iterator, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.primesieve_iterator, ptr %46, i32 0, i32 3
  %48 = load i64, ptr %47, align 8, !tbaa !18
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN10primesieve14IteratorHelper10updateNextERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8) %45, i64 noundef %48, ptr noundef nonnull align 8 dereferenceable(1776) %49)
          to label %50 unwind label %63

50:                                               ; preds = %43
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.primesieve_iterator, ptr %52, i32 0, i32 2
  %54 = load i64, ptr %53, align 8, !tbaa !13
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %55, i32 0, i32 0
  %57 = load i64, ptr %56, align 8, !tbaa !19
  invoke void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776) %51, i64 noundef %54, i64 noundef %57)
          to label %58 unwind label %63

58:                                               ; preds = %50
  br label %67

59:                                               ; preds = %31
  %60 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %61 = extractvalue { ptr, i32 } %60, 0
  store ptr %61, ptr %3, align 8
  %62 = extractvalue { ptr, i32 } %60, 1
  store i32 %62, ptr %4, align 4
  br label %95

63:                                               ; preds = %90, %67, %50, %43
  %64 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %3, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #14
  br label %95

67:                                               ; preds = %58, %38
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !14
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.primesieve_iterator, ptr %72, i32 0, i32 1
  invoke void @_ZN10primesieve14PrimeGenerator14fillNextPrimesERNS_6VectorImSaImEEEPm(ptr noundef nonnull align 8 dereferenceable(1720) %70, ptr noundef nonnull align 8 dereferenceable(24) %71, ptr noundef %73)
          to label %74 unwind label %63

74:                                               ; preds = %67
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %75) #14
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.primesieve_iterator, ptr %77, i32 0, i32 4
  store ptr %76, ptr %78, align 8, !tbaa !20
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.primesieve_iterator, ptr %79, i32 0, i32 0
  store i64 0, ptr %80, align 8, !tbaa !21
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.primesieve_iterator, ptr %81, i32 0, i32 1
  %83 = load i64, ptr %82, align 8, !tbaa !22
  %84 = icmp eq i64 %83, 0
  %85 = xor i1 %84, true
  %86 = xor i1 %85, true
  %87 = zext i1 %86 to i64
  %88 = call i64 @llvm.expect.i64(i64 %87, i64 0)
  %89 = icmp ne i64 %88, 0
  br i1 %89, label %90, label %93

90:                                               ; preds = %74
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %91)
          to label %92 unwind label %63

92:                                               ; preds = %90
  br label %94

93:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #14
  br label %138

94:                                               ; preds = %92
  br label %37, !llvm.loop !23

95:                                               ; preds = %63, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #14
  br label %96

96:                                               ; preds = %95, %27, %23
  %97 = load i32, ptr %4, align 4
  %98 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #14
  %99 = icmp eq i32 %97, %98
  br i1 %99, label %100, label %154

100:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #14
  %101 = load ptr, ptr %3, align 8
  %102 = call ptr @__cxa_begin_catch(ptr %101) #14
  store ptr %102, ptr %7, align 8
  %103 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef @.str)
          to label %104 unwind label %139

104:                                              ; preds = %100
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = load ptr, ptr %105, align 8, !tbaa !25
  %107 = getelementptr inbounds ptr, ptr %106, i64 2
  %108 = load ptr, ptr %107, align 8
  %109 = call noundef ptr %108(ptr noundef nonnull align 8 dereferenceable(8) %105) #14
  %110 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %103, ptr noundef %109)
          to label %111 unwind label %139

111:                                              ; preds = %104
  %112 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %110, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %113 unwind label %139

113:                                              ; preds = %111
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  invoke void @primesieve_clear(ptr noundef %114)
          to label %115 unwind label %139

115:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #14
  %116 = load ptr, ptr %2, align 8, !tbaa !5
  %117 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN12_GLOBAL__N_19getPrimesEP19primesieve_iterator(ptr noundef %116)
          to label %118 unwind label %143

118:                                              ; preds = %115
  store ptr %117, ptr %8, align 8, !tbaa !5
  %119 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #14
  store i64 -1, ptr %9, align 8, !tbaa !27
  invoke void @_ZN10primesieve6VectorImSaImEE9push_backEOm(ptr noundef nonnull align 8 dereferenceable(24) %119, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %120 unwind label %147

120:                                              ; preds = %118
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #14
  %121 = load ptr, ptr %2, align 8, !tbaa !5
  %122 = invoke noundef nonnull align 8 dereferenceable(1776) ptr @_ZN12_GLOBAL__N_111getIterDataEP19primesieve_iterator(ptr noundef %121)
          to label %123 unwind label %143

123:                                              ; preds = %120
  %124 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %122, i32 0, i32 0
  store i64 -1, ptr %124, align 8, !tbaa !19
  %125 = load ptr, ptr %8, align 8, !tbaa !5
  %126 = call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %125) #14
  %127 = load ptr, ptr %2, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.primesieve_iterator, ptr %127, i32 0, i32 4
  store ptr %126, ptr %128, align 8, !tbaa !20
  %129 = load ptr, ptr %8, align 8, !tbaa !5
  %130 = call noundef i64 @_ZNK10primesieve6VectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %129) #14
  %131 = load ptr, ptr %2, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.primesieve_iterator, ptr %131, i32 0, i32 1
  store i64 %130, ptr %132, align 8, !tbaa !22
  %133 = load ptr, ptr %2, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.primesieve_iterator, ptr %133, i32 0, i32 0
  store i64 0, ptr %134, align 8, !tbaa !21
  %135 = load ptr, ptr %2, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.primesieve_iterator, ptr %135, i32 0, i32 6
  store i32 1, ptr %136, align 8, !tbaa !28
  %137 = call ptr @__errno_location() #15
  store i32 33, ptr %137, align 4, !tbaa !29
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #14
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #14
  br label %138

138:                                              ; preds = %123, %93
  ret void

139:                                              ; preds = %113, %111, %104, %100
  %140 = landingpad { ptr, i32 }
          cleanup
  %141 = extractvalue { ptr, i32 } %140, 0
  store ptr %141, ptr %3, align 8
  %142 = extractvalue { ptr, i32 } %140, 1
  store i32 %142, ptr %4, align 4
  br label %152

143:                                              ; preds = %120, %115
  %144 = landingpad { ptr, i32 }
          cleanup
  %145 = extractvalue { ptr, i32 } %144, 0
  store ptr %145, ptr %3, align 8
  %146 = extractvalue { ptr, i32 } %144, 1
  store i32 %146, ptr %4, align 4
  br label %151

147:                                              ; preds = %118
  %148 = landingpad { ptr, i32 }
          cleanup
  %149 = extractvalue { ptr, i32 } %148, 0
  store ptr %149, ptr %3, align 8
  %150 = extractvalue { ptr, i32 } %148, 1
  store i32 %150, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #14
  br label %151

151:                                              ; preds = %147, %143
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #14
  br label %152

152:                                              ; preds = %151, %139
  invoke void @__cxa_end_catch()
          to label %153 unwind label %159

153:                                              ; preds = %152
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #14
  br label %154

154:                                              ; preds = %153, %96
  %155 = load ptr, ptr %3, align 8
  %156 = load i32, ptr %4, align 4
  %157 = insertvalue { ptr, i32 } poison, ptr %155, 0
  %158 = insertvalue { ptr, i32 } %157, i32 %156, 1
  resume { ptr, i32 } %158

159:                                              ; preds = %152
  %160 = landingpad { ptr, i32 }
          catch ptr null
  %161 = extractvalue { ptr, i32 } %160, 0
  call void @__clang_call_terminate(ptr %161) #16
  unreachable
}

declare void @_ZN10primesieve14IteratorHelper10updateNextERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, ptr noundef nonnull align 8 dereferenceable(1776)) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776), i64 noundef, i64 noundef) #4 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN10primesieve14PrimeGenerator14fillNextPrimesERNS_6VectorImSaImEEEPm(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #6 align 2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #7

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #8

declare ptr @__cxa_begin_catch(ptr)

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #9

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #9

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(24) ptr @_ZN12_GLOBAL__N_19getPrimesEP19primesieve_iterator(ptr noundef) #1

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN10primesieve6VectorImSaImEE9push_backEOm(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #6 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK10primesieve6VectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #10

declare void @__cxa_end_catch()

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin allocsize(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 = { nobuiltin 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 #4 = { mustprogress 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 = { "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 = { alwaysinline mustprogress 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 #7 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #8 = { nounwind memory(none) }
attributes #9 = { inlinehint mustprogress 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 #10 = { nounwind willreturn memory(none) "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 #11 = { 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 #12 = { builtin allocsize(0) }
attributes #13 = { builtin nounwind }
attributes #14 = { nounwind }
attributes #15 = { nounwind willreturn memory(none) }
attributes #16 = { 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, !6, i64 40}
!10 = !{!"_ZTS19primesieve_iterator", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !12, i64 48}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!15, !6, i64 24}
!15 = !{!"_ZTSN10primesieve12IteratorDataE", !11, i64 0, !11, i64 8, !16, i64 16, !6, i64 24, !17, i64 32, !7, i64 56}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSN10primesieve6VectorImSaImEEE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!10, !11, i64 24}
!19 = !{!15, !11, i64 0}
!20 = !{!10, !6, i64 32}
!21 = !{!10, !11, i64 0}
!22 = !{!10, !11, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !8, i64 0}
!27 = !{!11, !11, i64 0}
!28 = !{!10, !12, i64 48}
!29 = !{!12, !12, i64 0}


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

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZTISt9exception = external constant ptr
@_ZSt4cerr = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(1776) ptr @_ZN12_GLOBAL__N_111getIterDataEP19primesieve_iterator(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @primesieve_clear(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @primesieve_generate_next_primes(ptr noundef %0) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %2 = alloca i64, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %12

5:                                                ; preds = %1
  %6 = invoke noalias noundef nonnull dereferenceable(1776) ptr @_Znwm(i64 noundef 1776) #10
          to label %7 unwind label %10

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i64, ptr %8, align 8, !tbaa !12
  tail call void @_ZN10primesieve12IteratorDataC2Em(ptr noundef nonnull align 8 dereferenceable(1776) %6, i64 noundef %9)
  store ptr %6, ptr %3, align 8, !tbaa !5
  br label %12

10:                                               ; preds = %5
  %11 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
  br label %36

12:                                               ; preds = %7, %1
  %13 = tail call noundef nonnull align 8 dereferenceable(1776) ptr @_ZN12_GLOBAL__N_111getIterDataEP19primesieve_iterator(ptr noundef nonnull %0)
  %14 = getelementptr inbounds i8, ptr %13, i64 32
  %15 = getelementptr inbounds i8, ptr %13, i64 24
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  br label %20

20:                                               ; preds = %35, %12
  %21 = load ptr, ptr %15, align 8, !tbaa !13
  %.not37 = icmp eq ptr %21, null
  br i1 %.not37, label %22, label %29

22:                                               ; preds = %20
  %23 = load i64, ptr %17, align 8, !tbaa !17
  invoke void @_ZN10primesieve14IteratorHelper10updateNextERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8) %16, i64 noundef %23, ptr noundef nonnull align 8 dereferenceable(1776) %13)
          to label %24 unwind label %27

24:                                               ; preds = %22
  %25 = load i64, ptr %16, align 8, !tbaa !12
  %26 = load i64, ptr %13, align 8, !tbaa !18
  invoke void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776) %13, i64 noundef %25, i64 noundef %26)
          to label %._crit_edge unwind label %27

._crit_edge:                                      ; preds = %24
  %.pre = load ptr, ptr %15, align 8, !tbaa !13
  br label %29

27:                                               ; preds = %29, %24, %22
  %28 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  br label %36

29:                                               ; preds = %._crit_edge, %20
  %30 = phi ptr [ %.pre, %._crit_edge ], [ %21, %20 ]
  invoke void @_ZN10primesieve14PrimeGenerator14fillNextPrimesERNS_6VectorImSaImEEEPm(ptr noundef nonnull align 8 dereferenceable(1720) %30, ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull %18)
          to label %31 unwind label %27

31:                                               ; preds = %29
  %32 = tail call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #11
  store ptr %32, ptr %19, align 8, !tbaa !19
  store i64 0, ptr %0, align 8, !tbaa !20
  %33 = load i64, ptr %18, align 8, !tbaa !21
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %.loopexit, !prof !22

35:                                               ; preds = %31
  tail call void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %13)
  br label %20, !llvm.loop !23

36:                                               ; preds = %27, %10
  %.pn = phi { ptr, i32 } [ %28, %27 ], [ %11, %10 ]
  %.034 = extractvalue { ptr, i32 } %.pn, 1
  %37 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #11
  %38 = icmp eq i32 %.034, %37
  br i1 %38, label %39, label %66

39:                                               ; preds = %36
  %.0 = extractvalue { ptr, i32 } %.pn, 0
  %40 = tail call ptr @__cxa_begin_catch(ptr %.0) #11
  %41 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cerr, ptr noundef nonnull @.str)
          to label %42 unwind label %61

42:                                               ; preds = %39
  %43 = load ptr, ptr %40, align 8, !tbaa !25
  %44 = getelementptr inbounds i8, ptr %43, i64 16
  %45 = load ptr, ptr %44, align 8
  %46 = tail call noundef ptr %45(ptr noundef nonnull align 8 dereferenceable(8) %40) #11
  %47 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef %46)
          to label %48 unwind label %61

48:                                               ; preds = %42
  %49 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %47, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %50 unwind label %61

50:                                               ; preds = %48
  invoke void @primesieve_clear(ptr noundef nonnull %0)
          to label %51 unwind label %61

51:                                               ; preds = %50
  %52 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN12_GLOBAL__N_19getPrimesEP19primesieve_iterator(ptr noundef nonnull %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #11
  store i64 -1, ptr %2, align 8, !tbaa !27
  invoke void @_ZN10primesieve6VectorImSaImEE9push_backEOm(ptr noundef nonnull align 8 dereferenceable(24) %52, ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %53 unwind label %63

53:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #11
  %54 = call noundef nonnull align 8 dereferenceable(1776) ptr @_ZN12_GLOBAL__N_111getIterDataEP19primesieve_iterator(ptr noundef nonnull %0)
  store i64 -1, ptr %54, align 8, !tbaa !18
  %55 = call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %52) #11
  %56 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %55, ptr %56, align 8, !tbaa !19
  %57 = call noundef i64 @_ZNK10primesieve6VectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %52) #11
  %58 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %57, ptr %58, align 8, !tbaa !21
  store i64 0, ptr %0, align 8, !tbaa !20
  %59 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 1, ptr %59, align 8, !tbaa !28
  %60 = tail call ptr @__errno_location() #12
  store i32 33, ptr %60, align 4, !tbaa !29
  call void @__cxa_end_catch()
  br label %.loopexit

.loopexit:                                        ; preds = %31, %53
  ret void

61:                                               ; preds = %50, %48, %42, %39
  %62 = landingpad { ptr, i32 }
          cleanup
  br label %65

63:                                               ; preds = %51
  %64 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #11
  br label %65

65:                                               ; preds = %63, %61
  %.pn39 = phi { ptr, i32 } [ %64, %63 ], [ %62, %61 ]
  invoke void @__cxa_end_catch()
          to label %66 unwind label %67

66:                                               ; preds = %65, %36
  %.merged = phi { ptr, i32 } [ %.pn, %36 ], [ %.pn39, %65 ]
  resume { ptr, i32 } %.merged

67:                                               ; preds = %65
  %68 = landingpad { ptr, i32 }
          catch ptr null
  %69 = extractvalue { ptr, i32 } %68, 0
  call void @__clang_call_terminate(ptr %69) #13
  unreachable
}

declare void @_ZN10primesieve14IteratorHelper10updateNextERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, ptr noundef nonnull align 8 dereferenceable(1776)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776), i64 noundef, i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN10primesieve14PrimeGenerator14fillNextPrimesERNS_6VectorImSaImEEEPm(ptr noundef nonnull align 8 dereferenceable(1720), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #6

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #7

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #7

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef nonnull align 8 dereferenceable(24) ptr @_ZN12_GLOBAL__N_19getPrimesEP19primesieve_iterator(ptr noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN10primesieve6VectorImSaImEE9push_backEOm(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK10primesieve6VectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #8

declare void @__cxa_end_catch() local_unnamed_addr

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nobuiltin allocsize(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 = { mustprogress 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 = { "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 = { alwaysinline mustprogress 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 = { nofree nosync nounwind memory(none) }
attributes #7 = { inlinehint mustprogress 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 #8 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #9 = { 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 #10 = { builtin allocsize(0) }
attributes #11 = { nounwind }
attributes #12 = { nounwind willreturn memory(none) }
attributes #13 = { 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, !10, i64 40}
!6 = !{!"_ZTS19primesieve_iterator", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !11, i64 48}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 16}
!13 = !{!14, !10, i64 24}
!14 = !{!"_ZTSN10primesieve12IteratorDataE", !7, i64 0, !7, i64 8, !15, i64 16, !10, i64 24, !16, i64 32, !8, i64 56}
!15 = !{!"bool", !8, i64 0}
!16 = !{!"_ZTSN10primesieve6VectorImSaImEEE", !10, i64 0, !10, i64 8, !10, i64 16}
!17 = !{!6, !7, i64 24}
!18 = !{!14, !7, i64 0}
!19 = !{!6, !10, i64 32}
!20 = !{!6, !7, i64 0}
!21 = !{!6, !7, i64 8}
!22 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !9, i64 0}
!27 = !{!7, !7, i64 0}
!28 = !{!6, !11, i64 48}
!29 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass,TailCallElimPass