; LLVM IR from turi-code/SFrame :: oss_src/random/random.ll (ZN8graphlab6random10get_sourceEv)

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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [76 x i8], align 1
@__PRETTY_FUNCTION__._ZN8graphlab6random10get_sourceEv = external hidden unnamed_addr constant [42 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN8graphlab6randomL21get_random_source_keyEv() #2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(6328) ptr @_ZN8graphlab6random10get_sourceEv() #2 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  %4 = call noundef i32 @_ZN8graphlab6randomL21get_random_source_keyEv()
  %5 = call ptr @pthread_getspecific(i32 noundef %4) #6
  store ptr %5, ptr %1, align 8, !tbaa !5
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %26

8:                                                ; preds = %0
  %9 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 6328) #7
  invoke void @_ZN8graphlab6random9generatorC2Ev(ptr noundef nonnull align 8 dereferenceable(6328) %9)
          to label %10 unwind label %15

10:                                               ; preds = %8
  store ptr %9, ptr %1, align 8, !tbaa !5
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  br label %20

14:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.5, i32 noundef 276, ptr noundef @__PRETTY_FUNCTION__._ZN8graphlab6random10get_sourceEv) #8
  unreachable

15:                                               ; preds = %8
  %16 = landingpad { ptr, i32 }
          cleanup
  %17 = extractvalue { ptr, i32 } %16, 0
  store ptr %17, ptr %2, align 8
  %18 = extractvalue { ptr, i32 } %16, 1
  store i32 %18, ptr %3, align 4
  call void @_ZdlPvm(ptr noundef %9, i64 noundef 6328) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  br label %28

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19, %13
  %21 = call noundef nonnull align 8 dereferenceable(6416) ptr @_ZN8graphlab6random15source_registry6globalEv()
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  call void @_ZN8graphlab6random15source_registry18register_generatorEPNS0_9generatorE(ptr noundef nonnull align 8 dereferenceable(6416) %21, ptr noundef %22)
  %23 = call noundef i32 @_ZN8graphlab6randomL21get_random_source_keyEv()
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = call i32 @pthread_setspecific(i32 noundef %23, ptr noundef %24) #6
  br label %26

26:                                               ; preds = %20, %0
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret ptr %27

28:                                               ; preds = %15
  %29 = load ptr, ptr %2, align 8
  %30 = load i32, ptr %3, align 4
  %31 = insertvalue { ptr, i32 } poison, ptr %29, 0
  %32 = insertvalue { ptr, i32 } %31, i32 %30, 1
  resume { ptr, i32 } %32
}

; Function Attrs: nounwind
declare ptr @pthread_getspecific(i32 noundef) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8graphlab6random9generatorC2Ev(ptr noundef nonnull align 8 dereferenceable(6328)) unnamed_addr #2 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(6416) ptr @_ZN8graphlab6random15source_registry6globalEv() #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8graphlab6random15source_registry18register_generatorEPNS0_9generatorE(ptr noundef nonnull align 8 dereferenceable(6416), ptr noundef) #2 align 2

; Function Attrs: nounwind
declare i32 @pthread_setspecific(i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { noreturn nounwind }
attributes #9 = { builtin 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"}


; 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: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN8graphlab6randomL21get_random_source_keyEv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(6328) ptr @_ZN8graphlab6random10get_sourceEv() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = tail call noundef i32 @_ZN8graphlab6randomL21get_random_source_keyEv()
  %2 = tail call ptr @pthread_getspecific(i32 noundef %1) #4
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %12

4:                                                ; preds = %0
  %5 = tail call noalias noundef nonnull dereferenceable(6328) ptr @_Znwm(i64 noundef 6328) #5
  invoke void @_ZN8graphlab6random9generatorC2Ev(ptr noundef nonnull align 8 dereferenceable(6328) %5)
          to label %8 unwind label %6

6:                                                ; preds = %4
  %7 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 6328) #6
  resume { ptr, i32 } %7

8:                                                ; preds = %4
  %9 = tail call noundef nonnull align 8 dereferenceable(6416) ptr @_ZN8graphlab6random15source_registry6globalEv()
  tail call void @_ZN8graphlab6random15source_registry18register_generatorEPNS0_9generatorE(ptr noundef nonnull align 8 dereferenceable(6416) %9, ptr noundef nonnull %5)
  %10 = tail call noundef i32 @_ZN8graphlab6randomL21get_random_source_keyEv()
  %11 = tail call i32 @pthread_setspecific(i32 noundef %10, ptr noundef nonnull %5) #4
  br label %12

12:                                               ; preds = %8, %0
  %.0 = phi ptr [ %5, %8 ], [ %2, %0 ]
  ret ptr %.0
}

; Function Attrs: nounwind
declare ptr @pthread_getspecific(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8graphlab6random9generatorC2Ev(ptr noundef nonnull align 8 dereferenceable(6328)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8graphlab6random15source_registry18register_generatorEPNS0_9generatorE(ptr noundef nonnull align 8 dereferenceable(6416), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: nounwind
declare i32 @pthread_setspecific(i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #2 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { builtin 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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass