; LLVM IR from godzilla-foundation/godzilla-community :: core/deps/nanomsg-1.1.5/src/transports/inproc (binproc)

; 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.nn_ep_ops = type { ptr, ptr }
%struct.nn_binproc = type { %struct.nn_fsm, i32, %struct.nn_ins_item, %struct.nn_list }
%struct.nn_fsm = type { ptr, ptr, i32, i32, ptr, ptr, ptr, %struct.nn_fsm_event }
%struct.nn_fsm_event = type { ptr, i32, ptr, i32, %struct.nn_queue_item }
%struct.nn_queue_item = type { ptr }
%struct.nn_ins_item = type { %struct.nn_list_item, ptr, i32 }
%struct.nn_list_item = type { ptr, ptr }
%struct.nn_list = type { ptr, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [128 x i8], align 1
@nn_binproc_ops = external hidden constant %struct.nn_ep_ops, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @nn_binproc_create(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %7 = call ptr @nn_alloc_(i64 noundef 144)
  store ptr %7, ptr %5, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  %11 = xor i1 %10, true
  %12 = zext i1 %11 to i32
  %13 = sext i32 %12 to i64
  %14 = call i64 @llvm.expect.i64(i64 %13, i64 0)
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %8
  call void @nn_backtrace_print()
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 64) #6
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = call i32 @fflush(ptr noundef %19)
  call void @nn_err_abort() #7
  unreachable

21:                                               ; preds = %8
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nn_binproc, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @nn_ins_item_init(ptr noundef %25, ptr noundef %26)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.nn_binproc, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call ptr @nn_ep_getctx(ptr noundef %29)
  call void @nn_fsm_init_root(ptr noundef %28, ptr noundef @nn_binproc_handler, ptr noundef @nn_binproc_shutdown, ptr noundef %30)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.nn_binproc, ptr %31, i32 0, i32 1
  store i32 1, ptr %32, align 8, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.nn_binproc, ptr %33, i32 0, i32 3
  call void @nn_list_init(ptr noundef %34)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.nn_binproc, ptr %35, i32 0, i32 0
  call void @nn_fsm_start(ptr noundef %36)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.nn_binproc, ptr %37, i32 0, i32 2
  %39 = call i32 @nn_ins_bind(ptr noundef %38, ptr noundef @nn_binproc_connect)
  store i32 %39, ptr %4, align 4, !tbaa !18
  %40 = load i32, ptr %4, align 4, !tbaa !18
  %41 = icmp slt i32 %40, 0
  br i1 %41, label %42, label %54

42:                                               ; preds = %23
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.nn_binproc, ptr %43, i32 0, i32 3
  call void @nn_list_term(ptr noundef %44)
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.nn_binproc, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct.nn_fsm, ptr %46, i32 0, i32 2
  store i32 1, ptr %47, align 8, !tbaa !19
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.nn_binproc, ptr %48, i32 0, i32 0
  call void @nn_fsm_term(ptr noundef %49)
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.nn_binproc, ptr %50, i32 0, i32 2
  call void @nn_ins_item_term(ptr noundef %51)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nn_free(ptr noundef %52)
  %53 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %53, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %57

54:                                               ; preds = %23
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  call void @nn_ep_tran_setup(ptr noundef %55, ptr noundef @nn_binproc_ops, ptr noundef %56)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %57

57:                                               ; preds = %54, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %58 = load i32, ptr %2, align 4
  ret i32 %58
}

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

declare ptr @nn_alloc_(i64 noundef) #2

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

declare void @nn_backtrace_print() #2

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

declare i32 @fflush(ptr noundef) #2

; Function Attrs: noreturn
declare void @nn_err_abort() #5

declare void @nn_ins_item_init(ptr noundef, ptr noundef) #2

declare void @nn_fsm_init_root(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @nn_binproc_handler(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @nn_binproc_shutdown(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

declare ptr @nn_ep_getctx(ptr noundef) #2

declare void @nn_list_init(ptr noundef) #2

declare void @nn_fsm_start(ptr noundef) #2

declare i32 @nn_ins_bind(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @nn_binproc_connect(ptr noundef, ptr noundef) #0

declare void @nn_list_term(ptr noundef) #2

declare void @nn_fsm_term(ptr noundef) #2

declare void @nn_ins_item_term(ptr noundef) #2

declare void @nn_free(ptr noundef) #2

declare void @nn_ep_tran_setup(ptr noundef, ptr noundef, ptr noundef) #2

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

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

!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/C++ TBAA"}
!9 = !{!10, !12, i64 88}
!10 = !{!"nn_binproc", !11, i64 0, !12, i64 88, !15, i64 96, !17, i64 128}
!11 = !{!"nn_fsm", !6, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !13, i64 48}
!12 = !{!"int", !7, i64 0}
!13 = !{!"nn_fsm_event", !6, i64 0, !12, i64 8, !6, i64 16, !12, i64 24, !14, i64 32}
!14 = !{!"nn_queue_item", !6, i64 0}
!15 = !{!"nn_ins_item", !16, i64 0, !6, i64 16, !12, i64 24}
!16 = !{!"nn_list_item", !6, i64 0, !6, i64 8}
!17 = !{!"nn_list", !6, i64 0, !6, i64 8}
!18 = !{!12, !12, i64 0}
!19 = !{!10, !12, i64 16}


; 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.nn_ep_ops = type { ptr, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [128 x i8], align 1
@nn_binproc_ops = external hidden constant %struct.nn_ep_ops, align 8

; Function Attrs: nounwind uwtable
define dso_local range(i32 -2147483648, 1) i32 @nn_binproc_create(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @nn_alloc_(i64 noundef 144) #4
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %3, label %8, !prof !5

3:                                                ; preds = %1
  tail call void @nn_backtrace_print() #4
  %4 = load ptr, ptr @stderr, align 8, !tbaa !6
  %5 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %4, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 64) #5
  %6 = load ptr, ptr @stderr, align 8, !tbaa !6
  %7 = tail call i32 @fflush(ptr noundef %6)
  tail call void @nn_err_abort() #6
  unreachable

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %2, i64 96
  tail call void @nn_ins_item_init(ptr noundef nonnull %9, ptr noundef %0) #4
  %10 = tail call ptr @nn_ep_getctx(ptr noundef %0) #4
  tail call void @nn_fsm_init_root(ptr noundef nonnull %2, ptr noundef nonnull @nn_binproc_handler, ptr noundef nonnull @nn_binproc_shutdown, ptr noundef %10) #4
  %11 = getelementptr inbounds i8, ptr %2, i64 88
  store i32 1, ptr %11, align 8, !tbaa !10
  %12 = getelementptr inbounds i8, ptr %2, i64 128
  tail call void @nn_list_init(ptr noundef nonnull %12) #4
  tail call void @nn_fsm_start(ptr noundef nonnull %2) #4
  %13 = tail call i32 @nn_ins_bind(ptr noundef nonnull %9, ptr noundef nonnull @nn_binproc_connect) #4
  %14 = icmp slt i32 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %8
  tail call void @nn_list_term(ptr noundef nonnull %12) #4
  %16 = getelementptr inbounds i8, ptr %2, i64 16
  store i32 1, ptr %16, align 8, !tbaa !19
  tail call void @nn_fsm_term(ptr noundef nonnull %2) #4
  tail call void @nn_ins_item_term(ptr noundef nonnull %9) #4
  tail call void @nn_free(ptr noundef nonnull %2) #4
  br label %18

17:                                               ; preds = %8
  tail call void @nn_ep_tran_setup(ptr noundef %0, ptr noundef nonnull @nn_binproc_ops, ptr noundef nonnull %2) #4
  br label %18

18:                                               ; preds = %17, %15
  %.0 = phi i32 [ %13, %15 ], [ 0, %17 ]
  ret i32 %.0
}

declare ptr @nn_alloc_(i64 noundef) local_unnamed_addr #1

declare void @nn_backtrace_print() local_unnamed_addr #1

; 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

; Function Attrs: noreturn
declare void @nn_err_abort() local_unnamed_addr #3

declare void @nn_ins_item_init(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @nn_fsm_init_root(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @nn_binproc_handler(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @nn_binproc_shutdown(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #0

declare ptr @nn_ep_getctx(ptr noundef) local_unnamed_addr #1

declare void @nn_list_init(ptr noundef) local_unnamed_addr #1

declare void @nn_fsm_start(ptr noundef) local_unnamed_addr #1

declare i32 @nn_ins_bind(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @nn_binproc_connect(ptr noundef, ptr noundef) #0

declare void @nn_list_term(ptr noundef) local_unnamed_addr #1

declare void @nn_fsm_term(ptr noundef) local_unnamed_addr #1

declare void @nn_ins_item_term(ptr noundef) local_unnamed_addr #1

declare void @nn_free(ptr noundef) local_unnamed_addr #1

declare void @nn_ep_tran_setup(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { noreturn "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 }
attributes #5 = { cold nounwind }
attributes #6 = { noreturn 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/C++ TBAA"}
!10 = !{!11, !13, i64 88}
!11 = !{!"nn_binproc", !12, i64 0, !13, i64 88, !16, i64 96, !18, i64 128}
!12 = !{!"nn_fsm", !7, i64 0, !7, i64 8, !13, i64 16, !13, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !14, i64 48}
!13 = !{!"int", !8, i64 0}
!14 = !{!"nn_fsm_event", !7, i64 0, !13, i64 8, !7, i64 16, !13, i64 24, !15, i64 32}
!15 = !{!"nn_queue_item", !7, i64 0}
!16 = !{!"nn_ins_item", !17, i64 0, !7, i64 16, !13, i64 24}
!17 = !{!"nn_list_item", !7, i64 0, !7, i64 8}
!18 = !{!"nn_list", !7, i64 0, !7, i64 8}
!19 = !{!11, !13, i64 16}


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