; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/src (libsignaletic)

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

; Function Attrs: inlinehint nounwind uwtable
declare dso_local void @sig_Status_reportResult(ptr noundef, i32 noundef) #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: nounwind uwtable
define dso_local void @sig_List_insert(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.sig_List, ptr %11, i32 0, i32 2
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = icmp ugt i64 %10, %13
  br i1 %14, label %18, label %15

15:                                               ; preds = %4
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = icmp ult i64 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %15, %4
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  call void @sig_Status_reportResult(ptr noundef %19, i32 noundef 2)
  br label %71

20:                                               ; preds = %15
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.sig_List, ptr %22, i32 0, i32 2
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i64 %21, %24
  br i1 %25, label %26, label %30

26:                                               ; preds = %20
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  call void @sig_List_append(ptr noundef %27, ptr noundef %28, ptr noundef %29)
  br label %71

30:                                               ; preds = %20
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.sig_List, ptr %31, i32 0, i32 2
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.sig_List, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !13
  %37 = icmp uge i64 %33, %36
  br i1 %37, label %38, label %40

38:                                               ; preds = %30
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  call void @sig_Status_reportResult(ptr noundef %39, i32 noundef 3)
  br label %71

40:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.sig_List, ptr %41, i32 0, i32 2
  %43 = load i64, ptr %42, align 8, !tbaa !11
  %44 = sub i64 %43, 1
  store i64 %44, ptr %9, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %62, %40
  %46 = load i64, ptr %9, align 8, !tbaa !9
  %47 = icmp uge i64 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %65

49:                                               ; preds = %45
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.sig_List, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !14
  %53 = load i64, ptr %9, align 8, !tbaa !9
  %54 = getelementptr inbounds ptr, ptr %52, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.sig_List, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = add i64 %59, 1
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  store ptr %55, ptr %61, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %49
  %63 = load i64, ptr %9, align 8, !tbaa !9
  %64 = add i64 %63, -1
  store i64 %64, ptr %9, align 8, !tbaa !9
  br label %45, !llvm.loop !15

65:                                               ; preds = %48
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.sig_List, ptr %66, i32 0, i32 2
  %68 = load i64, ptr %67, align 8, !tbaa !11
  %69 = add i64 %68, 1
  store i64 %69, ptr %67, align 8, !tbaa !11
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  call void @sig_Status_reportResult(ptr noundef %70, i32 noundef 1)
  br label %71

71:                                               ; preds = %65, %38, %26, %18
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @sig_List_append(ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { inlinehint 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 = { 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 }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"sig_List", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !6, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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: inlinehint nounwind uwtable
declare dso_local void @sig_Status_reportResult(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @sig_List_insert(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = icmp ult i64 %6, %1
  br i1 %7, label %8, label %9

8:                                                ; preds = %4
  tail call void @sig_Status_reportResult(ptr noundef %3, i32 noundef 2)
  br label %20

9:                                                ; preds = %4
  %10 = icmp eq i64 %6, %1
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  tail call void @sig_List_append(ptr noundef nonnull %0, ptr noundef %2, ptr noundef %3)
  br label %20

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %.not = icmp ult i64 %6, %14
  br i1 %.not, label %.preheader, label %15

15:                                               ; preds = %12
  tail call void @sig_Status_reportResult(ptr noundef %3, i32 noundef 3)
  br label %20

.preheader:                                       ; preds = %12, %.preheader
  %.0.in = phi i64 [ %.0, %.preheader ], [ %6, %12 ]
  %.0 = add i64 %.0.in, -1
  %16 = load ptr, ptr %0, align 8, !tbaa !12
  %17 = getelementptr inbounds ptr, ptr %16, i64 %.0
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds ptr, ptr %16, i64 %.0.in
  store ptr %18, ptr %19, align 8, !tbaa !13
  br label %.preheader, !llvm.loop !14

20:                                               ; preds = %15, %11, %8
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @sig_List_append(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { inlinehint 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 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" }

!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, !10, i64 16}
!6 = !{!"sig_List", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass