; LLVM IR from CactiLab/Sherloc-Cortex-M-CFVD :: Sherloc_runtime/evaluation/src/sglib_dllist (dllist)

; 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.sglib_dllist_iterator = type { ptr, ptr, ptr, ptr, ptr }
%struct.dllist = type { i32, ptr, ptr }

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

; 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 @sglib_dllist_it_next(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %8, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %9, i32 0, i32 1
  store ptr null, ptr %10, align 8, !tbaa !9
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %38

15:                                               ; preds = %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  store ptr %18, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %19, i32 0, i32 3
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  store ptr %21, ptr %5, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %33, %15
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %31

25:                                               ; preds = %22
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call i32 %26(ptr noundef %27, ptr noundef %28)
  %30 = icmp ne i32 %29, 0
  br label %31

31:                                               ; preds = %25, %22
  %32 = phi i1 [ false, %22 ], [ %30, %25 ]
  br i1 %32, label %33, label %37

33:                                               ; preds = %31
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.dllist, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  store ptr %36, ptr %3, align 8, !tbaa !5
  br label %22, !llvm.loop !16

37:                                               ; preds = %31
  br label %38

38:                                               ; preds = %37, %1
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %47

41:                                               ; preds = %38
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.dllist, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %45, i32 0, i32 1
  store ptr %44, ptr %46, align 8, !tbaa !9
  br label %90

47:                                               ; preds = %38
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  store ptr %50, ptr %3, align 8, !tbaa !5
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %51, i32 0, i32 2
  store ptr null, ptr %52, align 8, !tbaa !18
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %80

57:                                               ; preds = %47
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %58, i32 0, i32 4
  %60 = load ptr, ptr %59, align 8, !tbaa !12
  store ptr %60, ptr %4, align 8, !tbaa !5
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !11
  store ptr %63, ptr %5, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %75, %57
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %73

67:                                               ; preds = %64
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call i32 %68(ptr noundef %69, ptr noundef %70)
  %72 = icmp ne i32 %71, 0
  br label %73

73:                                               ; preds = %67, %64
  %74 = phi i1 [ false, %64 ], [ %72, %67 ]
  br i1 %74, label %75, label %79

75:                                               ; preds = %73
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.dllist, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  store ptr %78, ptr %3, align 8, !tbaa !5
  br label %64, !llvm.loop !20

79:                                               ; preds = %73
  br label %80

80:                                               ; preds = %79, %47
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %89

83:                                               ; preds = %80
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.dllist, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !19
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %87, i32 0, i32 2
  store ptr %86, ptr %88, align 8, !tbaa !18
  br label %89

89:                                               ; preds = %83, %80
  br label %90

90:                                               ; preds = %89, %41
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.sglib_dllist_iterator, ptr %92, i32 0, i32 0
  store ptr %91, ptr %93, align 8, !tbaa !21
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret ptr %94
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 8}
!10 = !{!"sglib_dllist_iterator", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!10, !6, i64 24}
!12 = !{!10, !6, i64 32}
!13 = !{!14, !6, i64 16}
!14 = !{!"dllist", !15, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !6, i64 16}
!19 = !{!14, !6, i64 8}
!20 = distinct !{!20, !17}
!21 = !{!10, !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"

; Function Attrs: nounwind uwtable
define dso_local ptr @sglib_dllist_it_next(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr null, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.critedge, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %.not3355 = icmp eq ptr %3, null
  br i1 %.not3355, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !12
  store ptr null, ptr %9, align 8, !tbaa !12
  br label %20

.lr.ph:                                           ; preds = %6, %12
  %.056 = phi ptr [ %14, %12 ], [ %3, %6 ]
  %11 = tail call i32 %5(ptr noundef %8, ptr noundef nonnull %.056) #1
  %.not34 = icmp eq i32 %11, 0
  br i1 %.not34, label %.critedge.thread42, label %12

12:                                               ; preds = %.lr.ph
  %13 = getelementptr inbounds i8, ptr %.056, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %.not33 = icmp eq ptr %14, null
  br i1 %.not33, label %._crit_edge, label %.lr.ph, !llvm.loop !16

.critedge:                                        ; preds = %1
  %.not35 = icmp eq ptr %3, null
  br i1 %.not35, label %.thread, label %.critedge.thread42

.thread:                                          ; preds = %.critedge
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  store ptr null, ptr %15, align 8, !tbaa !12
  br label %.critedge2

.critedge.thread42:                               ; preds = %.lr.ph, %.critedge
  %.145 = phi ptr [ %3, %.critedge ], [ %.056, %.lr.ph ]
  %17 = getelementptr inbounds i8, ptr %.145, i64 16
  br label %.critedge2.thread.sink.split

._crit_edge:                                      ; preds = %12
  %.pr.pre = load ptr, ptr %4, align 8, !tbaa !10
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  store ptr null, ptr %18, align 8, !tbaa !12
  %.not36 = icmp eq ptr %.pr.pre, null
  br i1 %.not36, label %.critedge2, label %20

20:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %21 = phi ptr [ %10, %._crit_edge.thread ], [ %19, %._crit_edge ]
  %22 = phi ptr [ %9, %._crit_edge.thread ], [ %18, %._crit_edge ]
  %.pr66 = phi ptr [ %5, %._crit_edge.thread ], [ %.pr.pre, %._crit_edge ]
  %23 = load ptr, ptr %7, align 8, !tbaa !11
  %.not3757 = icmp eq ptr %21, null
  br i1 %.not3757, label %.critedge2.thread, label %.lr.ph60

.lr.ph60:                                         ; preds = %20, %25
  %.258 = phi ptr [ %27, %25 ], [ %21, %20 ]
  %24 = tail call i32 %.pr66(ptr noundef nonnull %.258, ptr noundef %23) #1
  %.not38 = icmp eq i32 %24, 0
  br i1 %.not38, label %.critedge2.thread49, label %25

25:                                               ; preds = %.lr.ph60
  %26 = getelementptr inbounds i8, ptr %.258, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %.not37 = icmp eq ptr %27, null
  br i1 %.not37, label %.critedge2.thread, label %.lr.ph60, !llvm.loop !19

.critedge2:                                       ; preds = %.thread, %._crit_edge
  %28 = phi ptr [ %18, %._crit_edge ], [ %15, %.thread ]
  %.3 = phi ptr [ %19, %._crit_edge ], [ %16, %.thread ]
  %.not39 = icmp eq ptr %.3, null
  br i1 %.not39, label %.critedge2.thread, label %.critedge2.thread49

.critedge2.thread49:                              ; preds = %.lr.ph60, %.critedge2
  %.352 = phi ptr [ %.3, %.critedge2 ], [ %.258, %.lr.ph60 ]
  %29 = phi ptr [ %28, %.critedge2 ], [ %22, %.lr.ph60 ]
  %30 = getelementptr inbounds i8, ptr %.352, i64 8
  br label %.critedge2.thread.sink.split

.critedge2.thread.sink.split:                     ; preds = %.critedge.thread42, %.critedge2.thread49
  %.sink70 = phi ptr [ %30, %.critedge2.thread49 ], [ %17, %.critedge.thread42 ]
  %.sink69 = phi ptr [ %29, %.critedge2.thread49 ], [ %2, %.critedge.thread42 ]
  %.4.ph = phi ptr [ %.352, %.critedge2.thread49 ], [ %.145, %.critedge.thread42 ]
  %31 = load ptr, ptr %.sink70, align 8, !tbaa !20
  store ptr %31, ptr %.sink69, align 8, !tbaa !20
  br label %.critedge2.thread

.critedge2.thread:                                ; preds = %25, %.critedge2.thread.sink.split, %20, %.critedge2
  %.4 = phi ptr [ null, %.critedge2 ], [ null, %20 ], [ %.4.ph, %.critedge2.thread.sink.split ], [ null, %25 ]
  store ptr %.4, ptr %0, align 8, !tbaa !21
  ret ptr %.4
}

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 = { 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 8}
!6 = !{!"sglib_dllist_iterator", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 24}
!11 = !{!6, !7, i64 32}
!12 = !{!6, !7, i64 16}
!13 = !{!14, !7, i64 16}
!14 = !{!"dllist", !15, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!"int", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!14, !7, i64 8}
!19 = distinct !{!19, !17}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass