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

; 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::ipc_address_t" = type { %struct.sockaddr_un, i64 }
%struct.sockaddr_un = type { i16, [108 x i8] }

@__const._ZNK3zmq13ipc_address_t9to_stringERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.prefix = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3zmq13ipc_address_t9to_stringERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [7 x i8], align 1
  %7 = alloca [115 x i8], align 16
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  %12 = getelementptr inbounds %"class.zmq::ipc_address_t", ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.sockaddr_un, ptr %12, i32 0, i32 0
  %14 = load i16, ptr %13, align 8, !tbaa !9
  %15 = zext i16 %14 to i32
  %16 = icmp ne i32 %15, 1
  br i1 %16, label %17, label %19

17:                                               ; preds = %2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #5
  store i32 -1, ptr %3, align 4
  br label %71

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 7, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 @__const._ZNK3zmq13ipc_address_t9to_stringERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.prefix, i64 7, i1 false)
  call void @llvm.lifetime.start.p0(i64 115, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = getelementptr inbounds [115 x i8], ptr %7, i64 0, i64 0
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds [7 x i8], ptr %6, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %21, ptr align 1 %22, i64 6, i1 false)
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 6
  store ptr %24, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %25 = getelementptr inbounds %"class.zmq::ipc_address_t", ptr %11, i32 0, i32 0
  %26 = getelementptr inbounds %struct.sockaddr_un, ptr %25, i32 0, i32 1
  %27 = getelementptr inbounds [108 x i8], ptr %26, i64 0, i64 0
  store ptr %27, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.zmq::ipc_address_t", ptr %11, i32 0, i32 0
  %29 = getelementptr inbounds %struct.sockaddr_un, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds [108 x i8], ptr %29, i64 0, i64 0
  %31 = load i8, ptr %30, align 2, !tbaa !14
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %44, label %33

33:                                               ; preds = %19
  %34 = getelementptr inbounds %"class.zmq::ipc_address_t", ptr %11, i32 0, i32 0
  %35 = getelementptr inbounds %struct.sockaddr_un, ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds [108 x i8], ptr %35, i64 0, i64 1
  %37 = load i8, ptr %36, align 1, !tbaa !14
  %38 = icmp ne i8 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %33
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i32 1
  store ptr %41, ptr %8, align 8, !tbaa !5
  store i8 64, ptr %40, align 1, !tbaa !14
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i32 1
  store ptr %43, ptr %9, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %39, %33, %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %"class.zmq::ipc_address_t", ptr %11, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !15
  %48 = sub i64 %47, 2
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.zmq::ipc_address_t", ptr %11, i32 0, i32 0
  %51 = getelementptr inbounds %struct.sockaddr_un, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds [108 x i8], ptr %51, i64 0, i64 0
  %53 = ptrtoint ptr %49 to i64
  %54 = ptrtoint ptr %52 to i64
  %55 = sub i64 %53, %54
  %56 = sub i64 %48, %55
  %57 = call i64 @strnlen(ptr noundef %45, i64 noundef %56) #6
  store i64 %57, ptr %10, align 8, !tbaa !16
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = load i64, ptr %10, align 8, !tbaa !16
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %58, ptr align 1 %59, i64 %60, i1 false)
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds [115 x i8], ptr %7, i64 0, i64 0
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds [115 x i8], ptr %7, i64 0, i64 0
  %65 = ptrtoint ptr %63 to i64
  %66 = ptrtoint ptr %64 to i64
  %67 = sub i64 %65, %66
  %68 = load i64, ptr %10, align 8, !tbaa !16
  %69 = add i64 %67, %68
  %70 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %61, ptr noundef %62, i64 noundef %69)
  store i32 0, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 115, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 7, ptr %6) #5
  br label %71

71:                                               ; preds = %44, %17
  %72 = load i32, ptr %3, align 4
  ret i32 %72
}

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strnlen(ptr noundef, i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) #2 align 2

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

!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, !12, i64 0}
!10 = !{!"_ZTSN3zmq13ipc_address_tE", !11, i64 0, !13, i64 112}
!11 = !{!"_ZTS11sockaddr_un", !12, i64 0, !7, i64 2}
!12 = !{!"short", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!10, !13, i64 112}
!16 = !{!13, !13, 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"

@__const._ZNK3zmq13ipc_address_t9to_stringERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.prefix = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, 1) i32 @_ZNK3zmq13ipc_address_t9to_stringERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #2 align 2 {
  %3 = alloca [115 x i8], align 16
  %4 = load i16, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i16 %4, 1
  br i1 %.not, label %6, label %5

5:                                                ; preds = %2
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #5
  br label %28

6:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 115, ptr nonnull %3) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(6) %3, ptr noundef nonnull align 1 dereferenceable(6) @__const._ZNK3zmq13ipc_address_t9to_stringERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.prefix, i64 6, i1 false)
  %7 = getelementptr inbounds i8, ptr %3, i64 6
  %8 = getelementptr inbounds i8, ptr %0, i64 2
  %9 = load i8, ptr %8, align 2, !tbaa !12
  %.not16 = icmp eq i8 %9, 0
  br i1 %.not16, label %10, label %15

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 3
  %12 = load i8, ptr %11, align 1, !tbaa !12
  %.not17 = icmp eq i8 %12, 0
  br i1 %.not17, label %15, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %3, i64 7
  store i8 64, ptr %7, align 2, !tbaa !12
  br label %15

15:                                               ; preds = %13, %10, %6
  %.015 = phi ptr [ %7, %6 ], [ %14, %13 ], [ %7, %10 ]
  %.014 = phi ptr [ %8, %6 ], [ %11, %13 ], [ %8, %10 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 112
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = ptrtoint ptr %.014 to i64
  %19 = ptrtoint ptr %8 to i64
  %20 = add nsw i64 %19, -2
  %.neg = sub i64 %20, %18
  %21 = add i64 %.neg, %17
  %22 = tail call i64 @strnlen(ptr noundef nonnull %.014, i64 noundef %21) #6
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %.015, ptr nonnull align 1 %.014, i64 %22, i1 false)
  %23 = ptrtoint ptr %.015 to i64
  %24 = ptrtoint ptr %3 to i64
  %25 = sub i64 %23, %24
  %26 = add i64 %25, %22
  %27 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull %3, i64 noundef %26)
  call void @llvm.lifetime.end.p0(i64 115, ptr nonnull %3) #5
  br label %28

28:                                               ; preds = %15, %5
  %.0 = phi i32 [ -1, %5 ], [ 0, %15 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strnlen(ptr nocapture noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6assignEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) local_unnamed_addr #2 align 2

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

!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, !8, i64 0}
!6 = !{!"_ZTSN3zmq13ipc_address_tE", !7, i64 0, !11, i64 112}
!7 = !{!"_ZTS11sockaddr_un", !8, i64 0, !9, i64 2}
!8 = !{!"short", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!9, !9, i64 0}
!13 = !{!6, !11, i64 112}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass