; LLVM IR from godzilla-foundation/godzilla-community :: core/deps/nanomsg-1.1.5/src/utils (list)

; 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_list_item = type { ptr, ptr }
%struct.nn_list = type { ptr, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [113 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1

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

declare void @nn_backtrace_print() #1

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

declare i32 @fflush(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @nn_list_insert(ptr noundef %0, ptr noundef %1, ptr noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  br label %7

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

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

22:                                               ; preds = %7
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.nn_list_item, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  br label %34

30:                                               ; preds = %23
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.nn_list, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  br label %34

34:                                               ; preds = %30, %26
  %35 = phi ptr [ %29, %26 ], [ %33, %30 ]
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nn_list_item, ptr %36, i32 0, i32 1
  store ptr %35, ptr %37, align 8, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.nn_list_item, ptr %39, i32 0, i32 0
  store ptr %38, ptr %40, align 8, !tbaa !13
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.nn_list_item, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %51

45:                                               ; preds = %34
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nn_list_item, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.nn_list_item, ptr %49, i32 0, i32 0
  store ptr %46, ptr %50, align 8, !tbaa !13
  br label %51

51:                                               ; preds = %45, %34
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.nn_list_item, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !13
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %62

56:                                               ; preds = %51
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.nn_list_item, ptr %58, i32 0, i32 0
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = getelementptr inbounds %struct.nn_list_item, ptr %60, i32 0, i32 1
  store ptr %57, ptr %61, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %56, %51
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.nn_list, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !14
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %73

67:                                               ; preds = %62
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.nn_list, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !14
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = icmp eq ptr %70, %71
  br i1 %72, label %73, label %77

73:                                               ; preds = %67, %62
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.nn_list, ptr %75, i32 0, i32 0
  store ptr %74, ptr %76, align 8, !tbaa !14
  br label %77

77:                                               ; preds = %73, %67
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = icmp ne ptr %78, null
  br i1 %79, label %84, label %80

80:                                               ; preds = %77
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.nn_list, ptr %82, i32 0, i32 1
  store ptr %81, ptr %83, align 8, !tbaa !11
  br label %84

84:                                               ; preds = %80, %77
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @nn_list_item_isinlist(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = { 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 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 }
attributes #6 = { 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, !6, i64 8}
!10 = !{!"nn_list_item", !6, i64 0, !6, i64 8}
!11 = !{!12, !6, i64 8}
!12 = !{!"nn_list", !6, i64 0, !6, i64 8}
!13 = !{!10, !6, i64 0}
!14 = !{!12, !6, 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"

@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 [113 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1

declare void @nn_backtrace_print() local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @nn_list_insert(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = tail call i32 @nn_list_item_isinlist(ptr noundef %1)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %10, label %5, !prof !5

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

10:                                               ; preds = %3
  %.not24 = icmp eq ptr %2, null
  %. = select i1 %.not24, ptr %0, ptr %2
  %.in = getelementptr inbounds i8, ptr %., i64 8
  %11 = load ptr, ptr %.in, align 8, !tbaa !6
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %11, ptr %12, align 8, !tbaa !10
  store ptr %2, ptr %1, align 8, !tbaa !12
  %.not25 = icmp eq ptr %11, null
  br i1 %.not25, label %14, label %13

13:                                               ; preds = %10
  store ptr %1, ptr %11, align 8, !tbaa !12
  %.pr = load ptr, ptr %1, align 8, !tbaa !12
  br label %14

14:                                               ; preds = %13, %10
  %15 = phi ptr [ %.pr, %13 ], [ %2, %10 ]
  %.not26 = icmp eq ptr %15, null
  br i1 %.not26, label %18, label %16

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %1, ptr %17, align 8, !tbaa !10
  br label %18

18:                                               ; preds = %16, %14
  %19 = load ptr, ptr %0, align 8, !tbaa !13
  %.not27 = icmp eq ptr %19, null
  %20 = icmp eq ptr %19, %2
  %or.cond = or i1 %.not27, %20
  br i1 %or.cond, label %21, label %22

21:                                               ; preds = %18
  store ptr %1, ptr %0, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %18, %21
  br i1 %.not24, label %23, label %25

23:                                               ; preds = %22
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %24, align 8, !tbaa !15
  br label %25

25:                                               ; preds = %23, %22
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @nn_list_item_isinlist(ptr noundef) local_unnamed_addr #3

attributes #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 = { 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 #2 = { 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 #3 = { 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 }
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 2000, i32 1}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 8}
!11 = !{!"nn_list_item", !7, i64 0, !7, i64 8}
!12 = !{!11, !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"nn_list", !7, i64 0, !7, i64 8}
!15 = !{!14, !7, i64 8}


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