; LLVM IR from specinfo-ua/UAPKI :: library/common/pkix (http-helper)

; 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.HTTP_HELPER = type { i8, i8, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::mutex", %"class.std::map" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::mutex>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::mutex>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::mutex>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::mutex>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@_ZL11http_helper = external hidden global %struct.HTTP_HELPER, align 8

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

; 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
define dso_local noundef i32 @_ZN10HttpHelper3getERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %11 = load i8, ptr getelementptr inbounds (%struct.HTTP_HELPER, ptr @_ZL11http_helper, i32 0, i32 1), align 1, !tbaa !9, !range !25, !noundef !26
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  store i32 4120, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %47

14:                                               ; preds = %2
  %15 = call ptr @curl_easy_init()
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i32 4098, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %47

18:                                               ; preds = %14
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call noundef zeroext i1 @_ZL22curl_set_url_and_proxyPvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %19, ptr noundef nonnull align 8 dereferenceable(32) %20)
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 4098, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %47

23:                                               ; preds = %18
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %24, i32 noundef 20011, ptr noundef @_ZL12cb_curlwritePvmmS_)
  %26 = call ptr @ba_alloc()
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %26, ptr %27, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %28, i32 noundef 10001, ptr noundef %30)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call i32 @curl_easy_perform(ptr noundef %32)
  store i32 %33, ptr %7, align 4, !tbaa !27
  %34 = load i32, ptr %7, align 4, !tbaa !27
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %43

36:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !29
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef %37, i32 noundef 2097154, ptr noundef %10)
  store i32 %38, ptr %7, align 4, !tbaa !27
  %39 = load i64, ptr %10, align 8, !tbaa !29
  %40 = icmp eq i64 %39, 200
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, i32 0, i32 4133
  store i32 %42, ptr %8, align 4, !tbaa !30
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %44

43:                                               ; preds = %23
  store i32 4098, ptr %8, align 4, !tbaa !30
  br label %44

44:                                               ; preds = %43, %36
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  call void @curl_easy_cleanup(ptr noundef %45)
  %46 = load i32, ptr %8, align 4, !tbaa !30
  store i32 %46, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %47

47:                                               ; preds = %44, %22, %17, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %48 = load i32, ptr %3, align 4
  ret i32 %48
}

declare ptr @curl_easy_init() #2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL22curl_set_url_and_proxyPvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) #1

declare i32 @curl_easy_setopt(ptr noundef, i32 noundef, ...) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZL12cb_curlwritePvmmS_(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

declare ptr @ba_alloc() #2

declare i32 @curl_easy_perform(ptr noundef) #2

declare i32 @curl_easy_getinfo(ptr noundef, i32 noundef, ...) #2

declare void @curl_easy_cleanup(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !11, i64 1}
!10 = !{!"_ZTS11HTTP_HELPER", !11, i64 0, !11, i64 1, !12, i64 8, !12, i64 40, !15, i64 72, !17, i64 112}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !7, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSSt5mutex", !16, i64 0}
!16 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!17 = !{!"_ZTSSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5mutexSt4lessIS5_ESaISt4pairIKS5_S6_EEE", !18, i64 0}
!18 = !{!"_ZTSSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St5mutexESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE", !19, i64 0}
!19 = !{!"_ZTSNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St5mutexESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE13_Rb_tree_implISD_Lb1EEE", !20, i64 0, !22, i64 8}
!20 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE", !21, i64 0}
!21 = !{!"_ZTSSt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE"}
!22 = !{!"_ZTSSt15_Rb_tree_header", !23, i64 0, !14, i64 32}
!23 = !{!"_ZTSSt18_Rb_tree_node_base", !24, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!24 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!28, !28, i64 0}
!28 = !{!"_ZTS8CURLcode", !7, i64 0}
!29 = !{!14, !14, i64 0}
!30 = !{!31, !31, i64 0}
!31 = !{!"int", !7, 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"

%struct.HTTP_HELPER = type { i8, i8, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::mutex", %"class.std::map" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::mutex>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::mutex>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::mutex>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::mutex>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@_ZL11http_helper = external hidden local_unnamed_addr global %struct.HTTP_HELPER, align 8

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 4134) i32 @_ZN10HttpHelper3getERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPP12ByteArray_st(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 align 2 {
  %3 = alloca i64, align 8
  %4 = load i8, ptr getelementptr inbounds (i8, ptr @_ZL11http_helper, i64 1), align 1, !tbaa !5, !range !24, !noundef !25
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %23, label %6

6:                                                ; preds = %2
  %7 = tail call ptr @curl_easy_init()
  %8 = icmp eq ptr %7, null
  br i1 %8, label %23, label %9

9:                                                ; preds = %6
  %10 = tail call noundef zeroext i1 @_ZL22curl_set_url_and_proxyPvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull %7, ptr noundef nonnull align 8 dereferenceable(32) %0)
  br i1 %10, label %11, label %23

11:                                               ; preds = %9
  %12 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %7, i32 noundef 20011, ptr noundef nonnull @_ZL12cb_curlwritePvmmS_)
  %13 = tail call ptr @ba_alloc()
  store ptr %13, ptr %1, align 8, !tbaa !26
  %14 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %7, i32 noundef 10001, ptr noundef %13)
  %15 = tail call i32 @curl_easy_perform(ptr noundef nonnull %7)
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %22

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store i64 0, ptr %3, align 8, !tbaa !27
  %18 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef nonnull %7, i32 noundef 2097154, ptr noundef nonnull %3)
  %19 = load i64, ptr %3, align 8, !tbaa !27
  %20 = icmp eq i64 %19, 200
  %21 = select i1 %20, i32 0, i32 4133
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %22

22:                                               ; preds = %11, %17
  %.0 = phi i32 [ %21, %17 ], [ 4098, %11 ]
  call void @curl_easy_cleanup(ptr noundef nonnull %7)
  br label %23

23:                                               ; preds = %9, %6, %2, %22
  %.011 = phi i32 [ %.0, %22 ], [ 4120, %2 ], [ 4098, %6 ], [ 4098, %9 ]
  ret i32 %.011
}

declare ptr @curl_easy_init() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL22curl_set_url_and_proxyPvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

declare i32 @curl_easy_setopt(ptr noundef, i32 noundef, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZL12cb_curlwritePvmmS_(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

declare ptr @ba_alloc() local_unnamed_addr #2

declare i32 @curl_easy_perform(ptr noundef) local_unnamed_addr #2

declare i32 @curl_easy_getinfo(ptr noundef, i32 noundef, ...) local_unnamed_addr #2

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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 1}
!6 = !{!"_ZTS11HTTP_HELPER", !7, i64 0, !7, i64 1, !10, i64 8, !10, i64 40, !14, i64 72, !16, i64 112}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !11, i64 0, !13, i64 8, !8, i64 16}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTSSt5mutex", !15, i64 0}
!15 = !{!"_ZTSSt12__mutex_base", !8, i64 0}
!16 = !{!"_ZTSSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5mutexSt4lessIS5_ESaISt4pairIKS5_S6_EEE", !17, i64 0}
!17 = !{!"_ZTSSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St5mutexESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE", !18, i64 0}
!18 = !{!"_ZTSNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_St5mutexESt10_Select1stIS9_ESt4lessIS5_ESaIS9_EE13_Rb_tree_implISD_Lb1EEE", !19, i64 0, !21, i64 8}
!19 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE", !20, i64 0}
!20 = !{!"_ZTSSt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE"}
!21 = !{!"_ZTSSt15_Rb_tree_header", !22, i64 0, !13, i64 32}
!22 = !{!"_ZTSSt18_Rb_tree_node_base", !23, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!23 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = !{!12, !12, i64 0}
!27 = !{!13, !13, i64 0}


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