; LLVM IR from clibs/clib :: deps/semver (semver)

; 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.semver_version_s = type { i32, i32, 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 i32 @semver_compare_version(ptr noundef byval(%struct.semver_version_s) align 8 %0, ptr noundef byval(%struct.semver_version_s) align 8 %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %6 = getelementptr inbounds %struct.semver_version_s, ptr %0, i32 0, i32 0
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.semver_version_s, ptr %1, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = call i32 @binary_comparison(i32 noundef %7, i32 noundef %9)
  store i32 %10, ptr %4, align 4, !tbaa !11
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %26

12:                                               ; preds = %2
  %13 = getelementptr inbounds %struct.semver_version_s, ptr %0, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = getelementptr inbounds %struct.semver_version_s, ptr %1, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = call i32 @binary_comparison(i32 noundef %14, i32 noundef %16)
  store i32 %17, ptr %4, align 4, !tbaa !11
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %25

19:                                               ; preds = %12
  %20 = getelementptr inbounds %struct.semver_version_s, ptr %0, i32 0, i32 2
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.semver_version_s, ptr %1, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !13
  %24 = call i32 @binary_comparison(i32 noundef %21, i32 noundef %23)
  store i32 %24, ptr %3, align 4
  store i32 1, ptr %5, align 4
  br label %28

25:                                               ; preds = %12
  br label %26

26:                                               ; preds = %25, %2
  %27 = load i32, ptr %4, align 4, !tbaa !11
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %5, align 4
  br label %28

28:                                               ; preds = %26, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %29 = load i32, ptr %3, align 4
  ret i32 %29
}

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

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, !7, i64 0}
!6 = !{!"semver_version_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !7, i64 8}


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

; Function Attrs: nounwind uwtable
define dso_local i32 @semver_compare_version(ptr nocapture noundef readonly byval(%struct.semver_version_s) align 8 %0, ptr nocapture noundef readonly byval(%struct.semver_version_s) align 8 %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = load i32, ptr %1, align 8, !tbaa !5
  %5 = tail call i32 @binary_comparison(i32 noundef %3, i32 noundef %4)
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %20

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = tail call i32 @binary_comparison(i32 noundef %9, i32 noundef %11)
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %7
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = tail call i32 @binary_comparison(i32 noundef %16, i32 noundef %18)
  br label %20

20:                                               ; preds = %2, %7, %14
  %.02 = phi i32 [ %19, %14 ], [ %12, %7 ], [ %5, %2 ]
  ret i32 %.02
}

; Function Attrs: nounwind uwtable
declare hidden i32 @binary_comparison(i32 noundef, i32 noundef) local_unnamed_addr #0

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

!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 0}
!6 = !{!"semver_version_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 8}


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