; 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
declare dso_local void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776), i64 noundef, i64 noundef) #4 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) #5

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

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) #7

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

; 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)) #8 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() #9

declare void @__cxa_end_catch()

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

; Function Attrs: mustprogress uwtable
define dso_local void @primesieve_generate_prev_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 %105

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 %105

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 %54

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
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = icmp ne ptr %39, null
  %41 = xor i1 %40, true
  %42 = xor i1 %41, true
  %43 = zext i1 %42 to i64
  %44 = call i64 @llvm.expect.i64(i64 %43, i64 0)
  %45 = icmp ne i64 %44, 0
  br i1 %45, label %46, label %62

46:                                               ; preds = %34
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10primesieve6VectorImSaImEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %47) #14
  %49 = load i64, ptr %48, align 8, !tbaa !18
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.primesieve_iterator, ptr %50, i32 0, i32 2
  store i64 %49, ptr %51, align 8, !tbaa !13
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %52)
          to label %53 unwind label %58

53:                                               ; preds = %46
  br label %62

54:                                               ; preds = %31
  %55 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %3, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %4, align 4
  br label %104

58:                                               ; preds = %85, %78, %70, %63, %46
  %59 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %60 = extractvalue { ptr, i32 } %59, 0
  store ptr %60, ptr %3, align 8
  %61 = extractvalue { ptr, i32 } %59, 1
  store i32 %61, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #14
  br label %104

62:                                               ; preds = %53, %34
  br label %63

63:                                               ; preds = %97, %62
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.primesieve_iterator, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.primesieve_iterator, ptr %66, i32 0, i32 3
  %68 = load i64, ptr %67, align 8, !tbaa !19
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN10primesieve14IteratorHelper10updatePrevERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8) %65, i64 noundef %68, ptr noundef nonnull align 8 dereferenceable(1776) %69)
          to label %70 unwind label %58

70:                                               ; preds = %63
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.primesieve_iterator, ptr %72, i32 0, i32 2
  %74 = load i64, ptr %73, align 8, !tbaa !13
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %75, i32 0, i32 0
  %77 = load i64, ptr %76, align 8, !tbaa !20
  invoke void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776) %71, i64 noundef %74, i64 noundef %77)
          to label %78 unwind label %58

78:                                               ; preds = %70
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %"struct.primesieve::IteratorData", ptr %79, i32 0, i32 3
  %81 = load ptr, ptr %80, align 8, !tbaa !14
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = load ptr, ptr %2, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.primesieve_iterator, ptr %83, i32 0, i32 1
  invoke void @_ZN10primesieve14PrimeGenerator14fillPrevPrimesERNS_6VectorImSaImEEEPm(ptr noundef nonnull align 8 dereferenceable(1720) %81, ptr noundef nonnull align 8 dereferenceable(24) %82, ptr noundef %84)
          to label %85 unwind label %58

85:                                               ; preds = %78
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %86)
          to label %87 unwind label %58

87:                                               ; preds = %85
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %88) #14
  %90 = load ptr, ptr %2, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.primesieve_iterator, ptr %90, i32 0, i32 4
  store ptr %89, ptr %91, align 8, !tbaa !21
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.primesieve_iterator, ptr %92, i32 0, i32 1
  %94 = load i64, ptr %93, align 8, !tbaa !22
  %95 = load ptr, ptr %2, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.primesieve_iterator, ptr %95, i32 0, i32 0
  store i64 %94, ptr %96, align 8, !tbaa !23
  br label %97

97:                                               ; preds = %87
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.primesieve_iterator, ptr %98, i32 0, i32 1
  %100 = load i64, ptr %99, align 8, !tbaa !22
  %101 = icmp ne i64 %100, 0
  %102 = xor i1 %101, true
  br i1 %102, label %63, label %103, !llvm.loop !24

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

104:                                              ; preds = %58, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #14
  br label %105

105:                                              ; preds = %104, %27, %23
  %106 = load i32, ptr %4, align 4
  %107 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #14
  %108 = icmp eq i32 %106, %107
  br i1 %108, label %109, label %162

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #14
  %110 = load ptr, ptr %3, align 8
  %111 = call ptr @__cxa_begin_catch(ptr %110) #14
  store ptr %111, ptr %7, align 8
  %112 = 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 %113 unwind label %147

113:                                              ; preds = %109
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = load ptr, ptr %114, align 8, !tbaa !26
  %116 = getelementptr inbounds ptr, ptr %115, i64 2
  %117 = load ptr, ptr %116, align 8
  %118 = call noundef ptr %117(ptr noundef nonnull align 8 dereferenceable(8) %114) #14
  %119 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %112, ptr noundef %118)
          to label %120 unwind label %147

120:                                              ; preds = %113
  %121 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %119, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %122 unwind label %147

122:                                              ; preds = %120
  %123 = load ptr, ptr %2, align 8, !tbaa !5
  invoke void @primesieve_clear(ptr noundef %123)
          to label %124 unwind label %147

124:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #14
  %125 = load ptr, ptr %2, align 8, !tbaa !5
  %126 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZN12_GLOBAL__N_19getPrimesEP19primesieve_iterator(ptr noundef %125)
          to label %127 unwind label %151

127:                                              ; preds = %124
  store ptr %126, ptr %8, align 8, !tbaa !5
  %128 = 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 !18
  invoke void @_ZN10primesieve6VectorImSaImEE9push_backEOm(ptr noundef nonnull align 8 dereferenceable(24) %128, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %129 unwind label %155

129:                                              ; preds = %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #14
  %130 = load ptr, ptr %8, align 8, !tbaa !5
  %131 = call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %130) #14
  %132 = load ptr, ptr %2, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.primesieve_iterator, ptr %132, i32 0, i32 4
  store ptr %131, ptr %133, align 8, !tbaa !21
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = call noundef i64 @_ZNK10primesieve6VectorImSaImEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %134) #14
  %136 = load ptr, ptr %2, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.primesieve_iterator, ptr %136, i32 0, i32 1
  store i64 %135, ptr %137, align 8, !tbaa !22
  %138 = load ptr, ptr %2, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.primesieve_iterator, ptr %138, i32 0, i32 1
  %140 = load i64, ptr %139, align 8, !tbaa !22
  %141 = load ptr, ptr %2, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.primesieve_iterator, ptr %141, i32 0, i32 0
  store i64 %140, ptr %142, align 8, !tbaa !23
  %143 = load ptr, ptr %2, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.primesieve_iterator, ptr %143, i32 0, i32 6
  store i32 1, ptr %144, align 8, !tbaa !28
  %145 = call ptr @__errno_location() #15
  store i32 33, ptr %145, 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 %146

146:                                              ; preds = %129, %103
  ret void

147:                                              ; preds = %122, %120, %113, %109
  %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
  br label %160

151:                                              ; preds = %124
  %152 = landingpad { ptr, i32 }
          cleanup
  %153 = extractvalue { ptr, i32 } %152, 0
  store ptr %153, ptr %3, align 8
  %154 = extractvalue { ptr, i32 } %152, 1
  store i32 %154, ptr %4, align 4
  br label %159

155:                                              ; preds = %127
  %156 = landingpad { ptr, i32 }
          cleanup
  %157 = extractvalue { ptr, i32 } %156, 0
  store ptr %157, ptr %3, align 8
  %158 = extractvalue { ptr, i32 } %156, 1
  store i32 %158, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #14
  br label %159

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

160:                                              ; preds = %159, %147
  invoke void @__cxa_end_catch()
          to label %161 unwind label %167

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

162:                                              ; preds = %161, %105
  %163 = load ptr, ptr %3, align 8
  %164 = load i32, ptr %4, align 4
  %165 = insertvalue { ptr, i32 } poison, ptr %163, 0
  %166 = insertvalue { ptr, i32 } %165, i32 %164, 1
  resume { ptr, i32 } %166

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

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

declare void @_ZN10primesieve14IteratorHelper10updatePrevERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef, ptr noundef nonnull align 8 dereferenceable(1776)) #11

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

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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { 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 = { 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 #9 = { 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 #10 = { 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 #11 = { "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 = !{!11, !11, i64 0}
!19 = !{!10, !11, i64 24}
!20 = !{!15, !11, i64 0}
!21 = !{!10, !6, i64 32}
!22 = !{!10, !11, i64 8}
!23 = !{!10, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !8, 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
declare dso_local void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776), i64 noundef, i64 noundef) local_unnamed_addr #3 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) #4

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 #5

; 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)) #5

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

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 #8

; Function Attrs: mustprogress uwtable
define dso_local void @primesieve_generate_prev_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 %38

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 = load ptr, ptr %15, align 8, !tbaa !13
  %.not41 = icmp eq ptr %16, null
  br i1 %.not41, label %23, label %17, !prof !17

17:                                               ; preds = %12
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10primesieve6VectorImSaImEE5frontEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #11
  %19 = load i64, ptr %18, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %19, ptr %20, align 8, !tbaa !12
  tail call void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %13)
  br label %23

21:                                               ; preds = %33, %30, %28
  %22 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  br label %38

23:                                               ; preds = %17, %12
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  br label %28

28:                                               ; preds = %35, %23
  %29 = load i64, ptr %25, align 8, !tbaa !19
  invoke void @_ZN10primesieve14IteratorHelper10updatePrevERmmRNS_12IteratorDataE(ptr noundef nonnull align 8 dereferenceable(8) %24, i64 noundef %29, ptr noundef nonnull align 8 dereferenceable(1776) %13)
          to label %30 unwind label %21

30:                                               ; preds = %28
  %31 = load i64, ptr %24, align 8, !tbaa !12
  %32 = load i64, ptr %13, align 8, !tbaa !20
  invoke void @_ZN10primesieve12IteratorData17newPrimeGeneratorEmm(ptr noundef nonnull align 8 dereferenceable(1776) %13, i64 noundef %31, i64 noundef %32)
          to label %33 unwind label %21

33:                                               ; preds = %30
  %34 = load ptr, ptr %15, align 8, !tbaa !13
  invoke void @_ZN10primesieve14PrimeGenerator14fillPrevPrimesERNS_6VectorImSaImEEEPm(ptr noundef nonnull align 8 dereferenceable(1720) %34, ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull %26)
          to label %35 unwind label %21

35:                                               ; preds = %33
  tail call void @_ZN10primesieve12IteratorData20deletePrimeGeneratorEv(ptr noundef nonnull align 8 dereferenceable(1776) %13)
  %36 = tail call noundef ptr @_ZN10primesieve6VectorImSaImEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #11
  store ptr %36, ptr %27, align 8, !tbaa !21
  %37 = load i64, ptr %26, align 8, !tbaa !22
  store i64 %37, ptr %0, align 8, !tbaa !23
  %.not45 = icmp eq i64 %37, 0
  br i1 %.not45, label %28, label %.loopexit, !llvm.loop !24

38:                                               ; preds = %21, %10
  %.pn = phi { ptr, i32 } [ %22, %21 ], [ %11, %10 ]
  %.038 = extractvalue { ptr, i32 } %.pn, 1
  %39 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #11
  %40 = icmp eq i32 %.038, %39
  br i1 %40, label %41, label %67

41:                                               ; preds = %38
  %.0 = extractvalue { ptr, i32 } %.pn, 0
  %42 = tail call ptr @__cxa_begin_catch(ptr %.0) #11
  %43 = 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 %44 unwind label %62

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

50:                                               ; preds = %44
  %51 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %49, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
          to label %52 unwind label %62

52:                                               ; preds = %50
  invoke void @primesieve_clear(ptr noundef nonnull %0)
          to label %53 unwind label %62

53:                                               ; preds = %52
  %54 = 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 !18
  invoke void @_ZN10primesieve6VectorImSaImEE9push_backEOm(ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef nonnull align 8 dereferenceable(8) %2)
          to label %55 unwind label %64

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

.loopexit:                                        ; preds = %35, %55
  ret void

62:                                               ; preds = %52, %50, %44, %41
  %63 = landingpad { ptr, i32 }
          cleanup
  br label %66

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

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

67:                                               ; preds = %66, %38
  %.merged = phi { ptr, i32 } [ %.pn, %38 ], [ %.pn43, %66 ]
  resume { ptr, i32 } %.merged

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

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

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

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

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 = { nofree nosync nounwind memory(none) }
attributes #5 = { 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 #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 = { 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 #8 = { 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 #9 = { "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 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!18 = !{!7, !7, i64 0}
!19 = !{!6, !7, i64 24}
!20 = !{!14, !7, i64 0}
!21 = !{!6, !10, i64 32}
!22 = !{!6, !7, i64 8}
!23 = !{!6, !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !9, i64 0}
!28 = !{!6, !11, i64 48}
!29 = !{!11, !11, i64 0}


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