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

; 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.3 = type { ptr, ptr, i64, [18 x i8], i8, i8, [16 x i8], i32 }
%struct.anon.1 = 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.2 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

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

13:                                               ; preds = %5
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %19, label %16

16:                                               ; preds = %13
  %17 = load i64, ptr %9, align 8, !tbaa !9
  %18 = icmp eq i64 %17, 0
  br label %19

19:                                               ; preds = %16, %13
  %20 = phi i1 [ true, %13 ], [ %18, %16 ]
  %21 = xor i1 %20, true
  %22 = zext i1 %21 to i64
  %23 = call i64 @llvm.expect.i64(i64 %22, i64 0)
  %24 = icmp ne i64 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %19
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str, ptr noundef @.str.4, ptr noundef @.str.2, i32 noundef 152) #7
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 @fflush(ptr noundef %28)
  call void @_ZN3zmq9zmq_abortEPKc(ptr noundef @.str.4)
  br label %30

30:                                               ; preds = %25, %19
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %52

34:                                               ; preds = %31
  %35 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %36 = getelementptr inbounds %struct.anon.3, ptr %35, i32 0, i32 0
  store ptr null, ptr %36, align 8, !tbaa !11
  %37 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %38 = getelementptr inbounds %struct.anon.3, ptr %37, i32 0, i32 4
  store i8 104, ptr %38, align 2, !tbaa !11
  %39 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %40 = getelementptr inbounds %struct.anon.3, ptr %39, i32 0, i32 5
  store i8 0, ptr %40, align 1, !tbaa !11
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %43 = getelementptr inbounds %struct.anon.3, ptr %42, i32 0, i32 1
  store ptr %41, ptr %43, align 8, !tbaa !11
  %44 = load i64, ptr %9, align 8, !tbaa !9
  %45 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %46 = getelementptr inbounds %struct.anon.3, ptr %45, i32 0, i32 2
  store i64 %44, ptr %46, align 8, !tbaa !11
  %47 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %48 = getelementptr inbounds %struct.anon.3, ptr %47, i32 0, i32 6
  %49 = getelementptr inbounds [16 x i8], ptr %48, i64 0, i64 0
  store i8 0, ptr %49, align 4, !tbaa !11
  %50 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %51 = getelementptr inbounds %struct.anon.3, ptr %50, i32 0, i32 7
  store i32 0, ptr %51, align 4, !tbaa !11
  br label %98

52:                                               ; preds = %31
  %53 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %54 = getelementptr inbounds %struct.anon.1, ptr %53, i32 0, i32 0
  store ptr null, ptr %54, align 8, !tbaa !11
  %55 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %56 = getelementptr inbounds %struct.anon.1, ptr %55, i32 0, i32 3
  store i8 102, ptr %56, align 2, !tbaa !11
  %57 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %58 = getelementptr inbounds %struct.anon.1, ptr %57, i32 0, i32 4
  store i8 0, ptr %58, align 1, !tbaa !11
  %59 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %60 = getelementptr inbounds %struct.anon.1, ptr %59, i32 0, i32 5
  %61 = getelementptr inbounds [16 x i8], ptr %60, i64 0, i64 0
  store i8 0, ptr %61, align 4, !tbaa !11
  %62 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %63 = getelementptr inbounds %struct.anon.1, ptr %62, i32 0, i32 6
  store i32 0, ptr %63, align 4, !tbaa !11
  %64 = call noalias ptr @malloc(i64 noundef 40) #8
  %65 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %66 = getelementptr inbounds %struct.anon.1, ptr %65, i32 0, i32 1
  store ptr %64, ptr %66, align 8, !tbaa !11
  %67 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %68 = getelementptr inbounds %struct.anon.1, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = icmp ne ptr %69, null
  br i1 %70, label %73, label %71

71:                                               ; preds = %52
  %72 = call ptr @__errno_location() #9
  store i32 12, ptr %72, align 4, !tbaa !12
  store i32 -1, ptr %6, align 4
  br label %99

73:                                               ; preds = %52
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %76 = getelementptr inbounds %struct.anon.1, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !11
  %78 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %77, i32 0, i32 0
  store ptr %74, ptr %78, align 8, !tbaa !14
  %79 = load i64, ptr %9, align 8, !tbaa !9
  %80 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %81 = getelementptr inbounds %struct.anon.1, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %82, i32 0, i32 1
  store i64 %79, ptr %83, align 8, !tbaa !19
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %86 = getelementptr inbounds %struct.anon.1, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  %88 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %87, i32 0, i32 2
  store ptr %84, ptr %88, align 8, !tbaa !20
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %91 = getelementptr inbounds %struct.anon.1, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !11
  %93 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %92, i32 0, i32 3
  store ptr %89, ptr %93, align 8, !tbaa !21
  %94 = getelementptr inbounds %"class.zmq::msg_t", ptr %12, i32 0, i32 0
  %95 = getelementptr inbounds %struct.anon.1, ptr %94, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  %97 = getelementptr inbounds %"struct.zmq::msg_t::content_t", ptr %96, i32 0, i32 4
  call void @_ZN3zmq16atomic_counter_tC2Ej(ptr noundef nonnull align 8 dereferenceable(4) %97, i32 noundef 0)
  br label %98

98:                                               ; preds = %73, %34
  store i32 0, ptr %6, align 4
  br label %99

99:                                               ; preds = %98, %71
  %100 = load i32, ptr %6, align 4
  ret i32 %100
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

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

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

declare i32 @fflush(ptr noundef) #6

declare void @_ZN3zmq9zmq_abortEPKc(ptr noundef) #6

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 = { nounwind 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 #2 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #3 = { 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 #4 = { 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 #5 = { 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 = { "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 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { nounwind willreturn memory(none) }

!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, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSN3zmq5msg_t9content_tE", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !16, i64 32}
!16 = !{!"_ZTSN3zmq16atomic_counter_tE", !17, i64 0}
!17 = !{!"_ZTSSt6atomicIjE", !18, i64 0}
!18 = !{!"_ZTSSt13__atomic_baseIjE", !13, i64 0}
!19 = !{!15, !10, i64 8}
!20 = !{!15, !6, i64 16}
!21 = !{!15, !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.2 = external hidden unnamed_addr constant [107 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, 1) i32 @_ZN3zmq5msg_t9init_dataEPvmPFvS1_S1_ES1_(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(64) %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 align 2 {
  %6 = icmp eq ptr %1, null
  %7 = icmp ne i64 %2, 0
  %.not13 = and i1 %6, %7
  br i1 %.not13, label %8, label %13, !prof !5

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

13:                                               ; preds = %5, %8
  %14 = icmp eq ptr %3, null
  store ptr null, ptr %0, align 8, !tbaa !10
  %15 = getelementptr inbounds i8, ptr %0, i64 42
  %16 = getelementptr inbounds i8, ptr %0, i64 43
  br i1 %14, label %17, label %22

17:                                               ; preds = %13
  store i8 104, ptr %15, align 2, !tbaa !10
  store i8 0, ptr %16, align 1, !tbaa !10
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %18, align 8, !tbaa !10
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %2, ptr %19, align 8, !tbaa !10
  %20 = getelementptr inbounds i8, ptr %0, i64 44
  store i8 0, ptr %20, align 4, !tbaa !10
  %21 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 0, ptr %21, align 4, !tbaa !10
  br label %34

22:                                               ; preds = %13
  store i8 102, ptr %15, align 2, !tbaa !10
  store i8 0, ptr %16, align 1, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %0, i64 44
  store i8 0, ptr %23, align 4, !tbaa !10
  %24 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 0, ptr %24, align 4, !tbaa !10
  %25 = tail call noalias dereferenceable_or_null(40) ptr @malloc(i64 noundef 40) #7
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %25, ptr %26, align 8, !tbaa !10
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %27, label %29

27:                                               ; preds = %22
  %28 = tail call ptr @__errno_location() #8
  store i32 12, ptr %28, align 4, !tbaa !11
  br label %34

29:                                               ; preds = %22
  store ptr %1, ptr %25, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %25, i64 8
  store i64 %2, ptr %30, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %25, i64 16
  store ptr %3, ptr %31, align 8, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %25, i64 24
  store ptr %4, ptr %32, align 8, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %25, i64 32
  tail call void @_ZN3zmq16atomic_counter_tC2Ej(ptr noundef nonnull align 8 dereferenceable(4) %33, i32 noundef 0)
  br label %34

34:                                               ; preds = %17, %29, %27
  %.0 = phi i32 [ -1, %27 ], [ 0, %29 ], [ 0, %17 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #2

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

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

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

declare void @_ZN3zmq9zmq_abortEPKc(ptr noundef) local_unnamed_addr #5

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #3 = { 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 #4 = { 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 #5 = { "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 = { cold nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind willreturn memory(none) }

!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, !12, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTSN3zmq5msg_t9content_tE", !7, i64 0, !15, i64 8, !7, i64 16, !7, i64 24, !16, i64 32}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_ZTSN3zmq16atomic_counter_tE", !17, i64 0}
!17 = !{!"_ZTSSt6atomicIjE", !18, i64 0}
!18 = !{!"_ZTSSt13__atomic_baseIjE", !12, i64 0}
!19 = !{!14, !15, i64 8}
!20 = !{!14, !7, i64 16}
!21 = !{!14, !7, i64 24}


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