; LLVM IR from erwincoumans/tiny-differentiable-simulator :: third_party/zeromq/src (msg)

; 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.zmq::msg_t" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { ptr, [34 x i8], i8, i8, [16 x i8], i32 }
%struct.anon.2 = type { ptr, ptr, [26 x i8], i8, i8, [16 x i8], i32 }
%"struct.zmq::msg_t::content_t" = type { ptr, i64, ptr, ptr, %"class.zmq::atomic_counter_t" }
%"class.zmq::atomic_counter_t" = type { %"struct.std::atomic", [4 x i8] }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3zmq5msg_t21init_external_storageEPNS0_9content_tEPvmPFvS3_S3_ES3_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5) #0 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %13 = load ptr, ptr %7, align 8
  br label %14

14:                                               ; preds = %6
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = icmp ne ptr null, %15
  %17 = xor i1 %16, true
  %18 = zext i1 %17 to i64
  %19 = call i64 @llvm.expect.i64(i64 %18, i64 0)
  %20 = icmp ne i64 %19, 0
  br i1 %20, label %21, label %26

21:                                               ; preds = %14
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 126) #5
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call i32 @fflush(ptr noundef %24)
  call void @_ZN3zmq9zmq_abortEPKc(ptr noundef @.str.1)
  br label %26

26:                                               ; preds = %21, %14
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = icmp ne ptr null, %29
  %31 = xor i1 %30, true
  %32 = zext i1 %31 to i64
  %33 = call i64 @llvm.expect.i64(i64 %32, i64 0)
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %35, label %40

35:                                               ; preds = %28
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str, ptr noundef @.str.3, ptr noundef @.str.2, i32 noundef 127) #5
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = call i32 @fflush(ptr noundef %38)
  call void @_ZN3zmq9zmq_abortEPKc(ptr noundef @.str.3)
  br label %40

40:                                               ; preds = %35, %28
  br label %41

41:                                               ; preds = %40
  %42 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %43 = getelementptr inbounds %struct.anon.2, ptr %42, i32 0, i32 0
  store ptr null, ptr %43, align 8, !tbaa !11
  %44 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %45 = getelementptr inbounds %struct.anon.2, ptr %44, i32 0, i32 3
  store i8 105, ptr %45, align 2, !tbaa !11
  %46 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %47 = getelementptr inbounds %struct.anon.2, ptr %46, i32 0, i32 4
  store i8 0, ptr %47, align 1, !tbaa !11
  %48 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %49 = getelementptr inbounds %struct.anon.2, ptr %48, i32 0, i32 5
  %50 = getelementptr inbounds [16 x i8], ptr %49, i64 0, i64 0
  store i8 0, ptr %50, align 4, !tbaa !11
  %51 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon.2, ptr %51, i32 0, i32 6
  store i32 0, ptr %52, align 4, !tbaa !11
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon.2, ptr %54, i32 0, i32 1
  store ptr %53, ptr %55, align 8, !tbaa !11
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %58 = getelementptr inbounds %struct.anon.2, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  %60 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %59, i32 0, i32 0
  store ptr %56, ptr %60, align 8, !tbaa !12
  %61 = load i64, ptr %10, align 8, !tbaa !9
  %62 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %63 = getelementptr inbounds %struct.anon.2, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %64, i32 0, i32 1
  store i64 %61, ptr %65, align 8, !tbaa !18
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %68 = getelementptr inbounds %struct.anon.2, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %69, i32 0, i32 2
  store ptr %66, ptr %70, align 8, !tbaa !19
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %73 = getelementptr inbounds %struct.anon.2, ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !11
  %75 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %74, i32 0, i32 3
  store ptr %71, ptr %75, align 8, !tbaa !20
  %76 = getelementptr inbounds %"class.zmq::msg_t", ptr %13, i32 0, i32 0
  %77 = getelementptr inbounds %struct.anon.2, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  %79 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %78, i32 0, i32 4
  call void @_ZN3zmq16atomic_counter_tC2Ej(ptr noundef nonnull align 8 dereferenceable(4) %79, i32 noundef 0)
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3zmq16atomic_counter_tC2Ej(ptr noundef nonnull align 8 dereferenceable(4), i32 noundef) unnamed_addr #2 align 2

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

declare i32 @fflush(ptr noundef) #4

declare void @_ZN3zmq9zmq_abortEPKc(ptr noundef) #4

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { inlinehint 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 #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 = { "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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSN3zmq5msg_t9content_tE", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !14, i64 32}
!14 = !{!"_ZTSN3zmq16atomic_counter_tE", !15, i64 0}
!15 = !{!"_ZTSSt6atomicIjE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIjE", !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!13, !10, i64 8}
!19 = !{!13, !6, i64 16}
!20 = !{!13, !6, i64 24}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN3zmq5msg_t21init_external_storageEPNS0_9content_tEPvmPFvS3_S3_ES3_(ptr nocapture noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #0 align 2 {
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %7, label %12, !prof !5

7:                                                ; preds = %6
  %8 = load ptr, ptr @stderr, align 8, !tbaa !6
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 126) #4
  %10 = load ptr, ptr @stderr, align 8, !tbaa !6
  %11 = tail call i32 @fflush(ptr noundef %10)
  tail call void @_ZN3zmq9zmq_abortEPKc(ptr noundef nonnull @.str.1)
  br label %12

12:                                               ; preds = %7, %6
  %.not7 = icmp eq ptr %1, null
  br i1 %.not7, label %13, label %18, !prof !5

13:                                               ; preds = %12
  %14 = load ptr, ptr @stderr, align 8, !tbaa !6
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.2, i32 noundef 127) #4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !6
  %17 = tail call i32 @fflush(ptr noundef %16)
  tail call void @_ZN3zmq9zmq_abortEPKc(ptr noundef nonnull @.str.3)
  br label %18

18:                                               ; preds = %12, %13
  store ptr null, ptr %0, align 8, !tbaa !10
  %19 = getelementptr inbounds i8, ptr %0, i64 42
  store i8 105, ptr %19, align 2, !tbaa !10
  %20 = getelementptr inbounds i8, ptr %0, i64 43
  store i8 0, ptr %20, align 1, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %0, i64 44
  store i8 0, ptr %21, align 4, !tbaa !10
  %22 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 0, ptr %22, align 4, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %23, align 8, !tbaa !10
  store ptr %2, ptr %1, align 8, !tbaa !11
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  store i64 %3, ptr %25, align 8, !tbaa !18
  %26 = load ptr, ptr %23, align 8, !tbaa !10
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  store ptr %4, ptr %27, align 8, !tbaa !19
  %28 = load ptr, ptr %23, align 8, !tbaa !10
  %29 = getelementptr inbounds i8, ptr %28, i64 24
  store ptr %5, ptr %29, align 8, !tbaa !20
  %30 = load ptr, ptr %23, align 8, !tbaa !10
  %31 = getelementptr inbounds i8, ptr %30, i64 32
  tail call void @_ZN3zmq16atomic_counter_tC2Ej(ptr noundef nonnull align 8 dereferenceable(4) %31, i32 noundef 0)
  ret i32 0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3zmq16atomic_counter_tC2Ej(ptr noundef nonnull align 8 dereferenceable(4), i32 noundef) unnamed_addr #1 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #2

declare void @_ZN3zmq9zmq_abortEPKc(ptr noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { inlinehint 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 = { nofree 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 = { "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 = { cold 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"_ZTSN3zmq5msg_t9content_tE", !7, i64 0, !13, i64 8, !7, i64 16, !7, i64 24, !14, i64 32}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTSN3zmq16atomic_counter_tE", !15, i64 0}
!15 = !{!"_ZTSSt6atomicIjE", !16, i64 0}
!16 = !{!"_ZTSSt13__atomic_baseIjE", !17, i64 0}
!17 = !{!"int", !8, i64 0}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !7, i64 16}
!20 = !{!12, !7, i64 24}


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