; LLVM IR from erwincoumans/tiny-differentiable-simulator :: third_party/zeromq/src/options.ll (ZN3zmq9options_t13set_curve_keyEPhPKvm)

; 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.zmq::options_t" = type <{ i32, i32, i64, i8, [256 x i8], [3 x i8], i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8], %"struct.zmq::atomic_value_t", i32, i32, i32, i32, i32, [4 x i8], i64, i32, i32, i8, [3 x i8], i32, i8, i8, i8, i8, i8, [3 x i8], %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i32, i32, i32, %"class.std::vector", i32, i32, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", [32 x i8], [32 x i8], [32 x i8], %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i32, i8, [3 x i8], i32, i8, [3 x i8], i32, i8, i8, i16, i32, i32, i32, %"class.std::__cxx11::basic_string", i8, i8, i8, i8, i32, i32, i8, [3 x i8], i32, [4 x i8], %"class.std::map", i32, [4 x i8] }>
%"struct.zmq::atomic_value_t" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<zmq::tcp_address_mask_t, std::allocator<zmq::tcp_address_mask_t>>::_Vector_impl" }
%"struct.std::_Vector_base<zmq::tcp_address_mask_t, std::allocator<zmq::tcp_address_mask_t>>::_Vector_impl" = type { %"struct.std::_Vector_base<zmq::tcp_address_mask_t, std::allocator<zmq::tcp_address_mask_t>>::_Vector_impl_data" }
%"struct.std::_Vector_base<zmq::tcp_address_mask_t, std::allocator<zmq::tcp_address_mask_t>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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::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::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>>, 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::__cxx11::basic_string<char>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>>>, 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 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3zmq9options_t13set_curve_keyEPhPKvm(ptr noundef nonnull align 8 dereferenceable(916) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #1 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca [41 x i8], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %6, align 8
  %12 = load i64, ptr %9, align 8, !tbaa !9
  switch i64 %12, label %38 [
    i64 32, label %13
    i64 41, label %18
    i64 40, label %26
  ]

13:                                               ; preds = %4
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %14, ptr align 1 %15, i64 %16, i1 false)
  %17 = getelementptr inbounds %"struct.zmq::options_t", ptr %11, i32 0, i32 42
  store i32 2, ptr %17, align 8, !tbaa !11
  store i32 0, ptr %5, align 4
  br label %40

18:                                               ; preds = %4
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call ptr @zmq_z85_decode(ptr noundef %19, ptr noundef %20)
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %25

23:                                               ; preds = %18
  %24 = getelementptr inbounds %"struct.zmq::options_t", ptr %11, i32 0, i32 42
  store i32 2, ptr %24, align 8, !tbaa !11
  store i32 0, ptr %5, align 4
  br label %40

25:                                               ; preds = %18
  br label %39

26:                                               ; preds = %4
  %27 = getelementptr inbounds [41 x i8], ptr %10, i64 0, i64 0
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i64, ptr %9, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %27, ptr align 1 %28, i64 %29, i1 false)
  %30 = getelementptr inbounds [41 x i8], ptr %10, i64 0, i64 40
  store i8 0, ptr %30, align 8, !tbaa !33
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds [41 x i8], ptr %10, i64 0, i64 0
  %33 = call ptr @zmq_z85_decode(ptr noundef %31, ptr noundef %32)
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %37

35:                                               ; preds = %26
  %36 = getelementptr inbounds %"struct.zmq::options_t", ptr %11, i32 0, i32 42
  store i32 2, ptr %36, align 8, !tbaa !11
  store i32 0, ptr %5, align 4
  br label %40

37:                                               ; preds = %26
  br label %39

38:                                               ; preds = %4
  br label %39

39:                                               ; preds = %38, %37, %25
  store i32 -1, ptr %5, align 4
  br label %40

40:                                               ; preds = %39, %35, %23, %13
  %41 = load i32, ptr %5, align 4
  ret i32 %41
}

declare ptr @zmq_z85_decode(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree 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" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 504}
!12 = !{!"_ZTSN3zmq9options_tE", !13, i64 0, !13, i64 4, !10, i64 8, !7, i64 16, !7, i64 17, !13, i64 276, !13, i64 280, !13, i64 284, !13, i64 288, !13, i64 292, !13, i64 296, !13, i64 300, !7, i64 304, !14, i64 308, !13, i64 312, !13, i64 316, !13, i64 320, !13, i64 324, !13, i64 328, !10, i64 336, !13, i64 344, !13, i64 348, !17, i64 352, !13, i64 356, !17, i64 360, !17, i64 361, !17, i64 362, !17, i64 363, !17, i64 364, !18, i64 368, !18, i64 400, !18, i64 432, !13, i64 464, !13, i64 468, !13, i64 472, !13, i64 476, !20, i64 480, !13, i64 504, !13, i64 508, !18, i64 512, !18, i64 544, !18, i64 576, !7, i64 608, !7, i64 640, !7, i64 672, !18, i64 704, !18, i64 736, !13, i64 768, !13, i64 772, !17, i64 776, !13, i64 780, !17, i64 784, !13, i64 788, !17, i64 792, !24, i64 794, !13, i64 796, !13, i64 800, !13, i64 804, !18, i64 808, !17, i64 840, !17, i64 841, !17, i64 842, !13, i64 844, !13, i64 848, !17, i64 852, !13, i64 856, !25, i64 864, !13, i64 912}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3zmq14atomic_value_tE", !15, i64 0}
!15 = !{!"_ZTSSt6atomicIiE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIiE", !13, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !19, i64 0, !10, i64 8, !7, i64 16}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!20 = !{!"_ZTSSt6vectorIN3zmq18tcp_address_mask_tESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN3zmq18tcp_address_mask_tESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN3zmq18tcp_address_mask_tESaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN3zmq18tcp_address_mask_tESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"short", !7, i64 0}
!25 = !{!"_ZTSSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St4lessIS5_ESaISt4pairIKS5_S5_EEE", !26, i64 0}
!26 = !{!"_ZTSSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE", !27, i64 0}
!27 = !{!"_ZTSNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE13_Rb_tree_implISC_Lb1EEE", !28, i64 0, !30, i64 8}
!28 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE", !29, i64 0}
!29 = !{!"_ZTSSt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE"}
!30 = !{!"_ZTSSt15_Rb_tree_header", !31, i64 0, !10, i64 32}
!31 = !{!"_ZTSSt18_Rb_tree_node_base", !32, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!32 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!33 = !{!7, !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"

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, 1) i32 @_ZN3zmq9options_t13set_curve_keyEPhPKvm(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(916) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca [41 x i8], align 16
  switch i64 %3, label %13 [
    i64 32, label %6
    i64 41, label %7
    i64 40, label %9
  ]

6:                                                ; preds = %4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) %1, ptr noundef nonnull align 1 dereferenceable(32) %2, i64 32, i1 false)
  br label %.sink.split

7:                                                ; preds = %4
  %8 = tail call ptr @zmq_z85_decode(ptr noundef %1, ptr noundef %2)
  %.not11 = icmp eq ptr %8, null
  br i1 %.not11, label %13, label %.sink.split

9:                                                ; preds = %4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(40) %5, ptr noundef nonnull align 1 dereferenceable(40) %2, i64 40, i1 false)
  %10 = getelementptr inbounds i8, ptr %5, i64 40
  store i8 0, ptr %10, align 8, !tbaa !5
  %11 = call ptr @zmq_z85_decode(ptr noundef %1, ptr noundef nonnull %5)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %13, label %.sink.split

.sink.split:                                      ; preds = %9, %7, %6
  %12 = getelementptr inbounds i8, ptr %0, i64 504
  store i32 2, ptr %12, align 8, !tbaa !8
  br label %13

13:                                               ; preds = %.sink.split, %7, %9, %4
  %.0 = phi i32 [ -1, %4 ], [ -1, %9 ], [ -1, %7 ], [ 0, %.sink.split ]
  ret i32 %.0
}

declare ptr @zmq_z85_decode(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree 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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 504}
!9 = !{!"_ZTSN3zmq9options_tE", !10, i64 0, !10, i64 4, !11, i64 8, !6, i64 16, !6, i64 17, !10, i64 276, !10, i64 280, !10, i64 284, !10, i64 288, !10, i64 292, !10, i64 296, !10, i64 300, !6, i64 304, !12, i64 308, !10, i64 312, !10, i64 316, !10, i64 320, !10, i64 324, !10, i64 328, !11, i64 336, !10, i64 344, !10, i64 348, !15, i64 352, !10, i64 356, !15, i64 360, !15, i64 361, !15, i64 362, !15, i64 363, !15, i64 364, !16, i64 368, !16, i64 400, !16, i64 432, !10, i64 464, !10, i64 468, !10, i64 472, !10, i64 476, !19, i64 480, !10, i64 504, !10, i64 508, !16, i64 512, !16, i64 544, !16, i64 576, !6, i64 608, !6, i64 640, !6, i64 672, !16, i64 704, !16, i64 736, !10, i64 768, !10, i64 772, !15, i64 776, !10, i64 780, !15, i64 784, !10, i64 788, !15, i64 792, !23, i64 794, !10, i64 796, !10, i64 800, !10, i64 804, !16, i64 808, !15, i64 840, !15, i64 841, !15, i64 842, !10, i64 844, !10, i64 848, !15, i64 852, !10, i64 856, !24, i64 864, !10, i64 912}
!10 = !{!"int", !6, i64 0}
!11 = !{!"long", !6, i64 0}
!12 = !{!"_ZTSN3zmq14atomic_value_tE", !13, i64 0}
!13 = !{!"_ZTSSt6atomicIiE", !14, i64 0}
!14 = !{!"_ZTSSt13__atomic_baseIiE", !10, i64 0}
!15 = !{!"bool", !6, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !11, i64 8, !6, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !18, i64 0}
!18 = !{!"any pointer", !6, i64 0}
!19 = !{!"_ZTSSt6vectorIN3zmq18tcp_address_mask_tESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN3zmq18tcp_address_mask_tESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN3zmq18tcp_address_mask_tESaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN3zmq18tcp_address_mask_tESaIS1_EE17_Vector_impl_dataE", !18, i64 0, !18, i64 8, !18, i64 16}
!23 = !{!"short", !6, i64 0}
!24 = !{!"_ZTSSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES5_St4lessIS5_ESaISt4pairIKS5_S5_EEE", !25, i64 0}
!25 = !{!"_ZTSSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE", !26, i64 0}
!26 = !{!"_ZTSNSt8_Rb_treeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4pairIKS5_S5_ESt10_Select1stIS8_ESt4lessIS5_ESaIS8_EE13_Rb_tree_implISC_Lb1EEE", !27, i64 0, !29, i64 8}
!27 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE", !28, i64 0}
!28 = !{!"_ZTSSt4lessINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE"}
!29 = !{!"_ZTSSt15_Rb_tree_header", !30, i64 0, !11, i64 32}
!30 = !{!"_ZTSSt18_Rb_tree_node_base", !31, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}
!31 = !{!"_ZTSSt14_Rb_tree_color", !6, i64 0}


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