; LLVM IR from pupnp/pupnp :: upnp/src/threadutil (LinkedList)

; 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.LINKEDLIST = type { %struct.LISTNODE, %struct.LISTNODE, i64, %struct.FREELIST, ptr, ptr }
%struct.LISTNODE = type { ptr, ptr, ptr }
%struct.FREELIST = type { ptr, i64, i32, i32 }

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__.ListDelNode = external hidden unnamed_addr constant [49 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ListDelNode(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %14

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 182, ptr noundef @__PRETTY_FUNCTION__.ListDelNode) #4
  unreachable

14:                                               ; preds = %12
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.LINKEDLIST, ptr %16, i32 0, i32 0
  %18 = icmp ne ptr %15, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  br label %21

20:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 183, ptr noundef @__PRETTY_FUNCTION__.ListDelNode) #4
  unreachable

21:                                               ; preds = %19
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.LINKEDLIST, ptr %23, i32 0, i32 1
  %25 = icmp ne ptr %22, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  br label %28

27:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 184, ptr noundef @__PRETTY_FUNCTION__.ListDelNode) #4
  unreachable

28:                                               ; preds = %26
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %44

31:                                               ; preds = %28
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.LINKEDLIST, ptr %33, i32 0, i32 0
  %35 = icmp eq ptr %32, %34
  br i1 %35, label %44, label %36

36:                                               ; preds = %31
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.LINKEDLIST, ptr %38, i32 0, i32 1
  %40 = icmp eq ptr %37, %39
  br i1 %40, label %44, label %41

41:                                               ; preds = %36
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %45, label %44

44:                                               ; preds = %41, %36, %31, %28
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %84

45:                                               ; preds = %41
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.LISTNODE, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  store ptr %48, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.LISTNODE, ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.LISTNODE, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !14
  %55 = getelementptr inbounds %struct.LISTNODE, ptr %54, i32 0, i32 1
  store ptr %51, ptr %55, align 8, !tbaa !13
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.LISTNODE, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.LISTNODE, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = getelementptr inbounds %struct.LISTNODE, ptr %61, i32 0, i32 0
  store ptr %58, ptr %62, align 8, !tbaa !14
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = call i32 @freeListNode(ptr noundef %63, ptr noundef %64)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.LINKEDLIST, ptr %66, i32 0, i32 2
  %68 = load i64, ptr %67, align 8, !tbaa !15
  %69 = add nsw i64 %68, -1
  store i64 %69, ptr %67, align 8, !tbaa !15
  %70 = load i32, ptr %7, align 4, !tbaa !9
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %82

72:                                               ; preds = %45
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.LINKEDLIST, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %82

77:                                               ; preds = %72
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.LINKEDLIST, ptr %78, i32 0, i32 4
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  call void %80(ptr noundef %81)
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %77, %72, %45
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %83, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %84

84:                                               ; preds = %82, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %85 = load ptr, ptr %4, align 8
  ret ptr %85
}

; Function Attrs: nounwind uwtable
declare hidden i32 @freeListNode(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { 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 }
attributes #4 = { 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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"LISTNODE", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 0}
!15 = !{!16, !17, i64 48}
!16 = !{!"LINKEDLIST", !12, i64 0, !12, i64 24, !17, i64 48, !18, i64 56, !6, i64 80, !6, i64 88}
!17 = !{!"long", !7, i64 0}
!18 = !{!"FREELIST", !6, i64 0, !17, i64 8, !10, i64 16, !10, i64 20}
!19 = !{!16, !6, i64 80}


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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__.ListDelNode = external hidden unnamed_addr constant [49 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @ListDelNode(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 182, ptr noundef nonnull @__PRETTY_FUNCTION__.ListDelNode) #2
  unreachable

5:                                                ; preds = %3
  %.not29 = icmp eq ptr %1, %0
  br i1 %.not29, label %6, label %7

6:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 183, ptr noundef nonnull @__PRETTY_FUNCTION__.ListDelNode) #2
  unreachable

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %.not30 = icmp eq ptr %8, %1
  br i1 %.not30, label %9, label %10

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 184, ptr noundef nonnull @__PRETTY_FUNCTION__.ListDelNode) #2
  unreachable

10:                                               ; preds = %7
  %.not31 = icmp eq ptr %1, null
  br i1 %.not31, label %26, label %11

11:                                               ; preds = %10
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !10
  %16 = load ptr, ptr %1, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  store ptr %15, ptr %17, align 8, !tbaa !10
  store ptr %16, ptr %15, align 8, !tbaa !11
  %18 = tail call i32 @freeListNode(ptr noundef nonnull %1, ptr noundef nonnull %0)
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  %20 = load i64, ptr %19, align 8, !tbaa !12
  %21 = add nsw i64 %20, -1
  store i64 %21, ptr %19, align 8, !tbaa !12
  %.not32 = icmp eq i32 %2, 0
  br i1 %.not32, label %26, label %22

22:                                               ; preds = %11
  %23 = getelementptr inbounds i8, ptr %0, i64 80
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %.not33 = icmp eq ptr %24, null
  br i1 %.not33, label %26, label %25

25:                                               ; preds = %22
  tail call void %24(ptr noundef %13) #3
  br label %26

26:                                               ; preds = %11, %22, %25, %10
  %.025 = phi ptr [ null, %10 ], [ null, %25 ], [ %13, %22 ], [ %13, %11 ]
  ret ptr %.025
}

; Function Attrs: nounwind uwtable
declare hidden i32 @freeListNode(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { noreturn 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 #1 = { 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 = { noreturn nounwind }
attributes #3 = { 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, !7, i64 16}
!6 = !{!"LISTNODE", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !14, i64 48}
!13 = !{!"LINKEDLIST", !6, i64 0, !6, i64 24, !14, i64 48, !15, i64 56, !7, i64 80, !7, i64 88}
!14 = !{!"long", !8, i64 0}
!15 = !{!"FREELIST", !7, i64 0, !14, i64 8, !16, i64 16, !16, i64 20}
!16 = !{!"int", !8, i64 0}
!17 = !{!13, !7, i64 80}


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