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

@.str.2 = external hidden unnamed_addr constant [2 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: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

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

14:                                               ; preds = %77, %2
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %21

17:                                               ; preds = %14
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %7, align 4, !tbaa !9
  %20 = icmp slt i32 %18, 4
  br label %21

21:                                               ; preds = %17, %14
  %22 = phi i1 [ false, %14 ], [ %20, %17 ]
  br i1 %22, label %23, label %78

23:                                               ; preds = %21
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i8, ptr @.str.2, align 1, !tbaa !11
  %26 = sext i8 %25 to i32
  %27 = call ptr @strchr(ptr noundef %24, i32 noundef %26) #5
  store ptr %27, ptr %10, align 8, !tbaa !5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %23
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = call i64 @strlen(ptr noundef %31) #5
  store i64 %32, ptr %6, align 8, !tbaa !12
  br label %39

33:                                               ; preds = %23
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = ptrtoint ptr %34 to i64
  %37 = ptrtoint ptr %35 to i64
  %38 = sub i64 %36, %37
  store i64 %38, ptr %6, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %33, %30
  %40 = load i64, ptr %6, align 8, !tbaa !12
  %41 = icmp ugt i64 %40, 50
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %79

43:                                               ; preds = %39
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = call i64 @strtol(ptr noundef %44, ptr noundef %11, i32 noundef 10) #4
  %46 = trunc i64 %45 to i32
  store i32 %46, ptr %8, align 4, !tbaa !9
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = icmp ne ptr %47, %48
  br i1 %49, label %50, label %56

50:                                               ; preds = %43
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load i8, ptr %51, align 1, !tbaa !11
  %53 = sext i8 %52 to i32
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %50
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %79

56:                                               ; preds = %50, %43
  %57 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %57, label %70 [
    i32 1, label %58
    i32 2, label %62
    i32 3, label %66
  ]

58:                                               ; preds = %56
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.semver_version_s, ptr %60, i32 0, i32 0
  store i32 %59, ptr %61, align 8, !tbaa !14
  br label %70

62:                                               ; preds = %56
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.semver_version_s, ptr %64, i32 0, i32 1
  store i32 %63, ptr %65, align 4, !tbaa !16
  br label %70

66:                                               ; preds = %56
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.semver_version_s, ptr %68, i32 0, i32 2
  store i32 %67, ptr %69, align 8, !tbaa !17
  br label %70

70:                                               ; preds = %66, %62, %58, %56
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %77

74:                                               ; preds = %70
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %75, i64 1
  store ptr %76, ptr %9, align 8, !tbaa !5
  br label %77

77:                                               ; preds = %74, %73
  br label %14, !llvm.loop !18

78:                                               ; preds = %21
  store i32 0, ptr %3, align 4
  store i32 1, ptr %12, align 4
  br label %79

79:                                               ; preds = %78, %55, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %80 = load i32, ptr %3, align 4
  ret i32 %80
}

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

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "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 "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 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"semver_version_s", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!15, !10, i64 4}
!17 = !{!15, !10, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn uwtable
define dso_local range(i32 -1, 1) i32 @semver_parse_version(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %.not28 = icmp eq ptr %0, null
  br i1 %.not28, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = load i8, ptr @.str.2, align 1, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %0, i32 noundef %5) #5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %12

10:                                               ; preds = %.lr.ph
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #5
  br label %16

12:                                               ; preds = %.lr.ph
  %13 = ptrtoint ptr %8 to i64
  %14 = ptrtoint ptr %0 to i64
  %15 = sub i64 %13, %14
  br label %16

16:                                               ; preds = %12, %10
  %.021 = phi i64 [ %11, %10 ], [ %15, %12 ]
  %17 = icmp ugt i64 %.021, 50
  br i1 %17, label %.critedge, label %18

18:                                               ; preds = %16
  %19 = call i64 @strtol(ptr noundef nonnull %0, ptr noundef nonnull %3, i32 noundef 10) #4
  %20 = trunc i64 %19 to i32
  %21 = load ptr, ptr %3, align 8, !tbaa !8
  %.not26 = icmp eq ptr %21, %8
  br i1 %.not26, label %select.unfold, label %22

22:                                               ; preds = %18
  %23 = load i8, ptr %21, align 1, !tbaa !5
  %.not27 = icmp eq i8 %23, 0
  br i1 %.not27, label %select.unfold, label %.critedge

select.unfold:                                    ; preds = %22, %18
  store i32 %20, ptr %1, align 8, !tbaa !10
  %24 = getelementptr inbounds i8, ptr %8, i64 1
  br i1 %9, label %.critedge, label %25

25:                                               ; preds = %select.unfold
  %26 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %24, i32 noundef %5) #5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %32, label %28

28:                                               ; preds = %25
  %29 = ptrtoint ptr %26 to i64
  %30 = ptrtoint ptr %24 to i64
  %31 = sub i64 %29, %30
  br label %34

32:                                               ; preds = %25
  %33 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %24) #5
  br label %34

34:                                               ; preds = %32, %28
  %.021.1 = phi i64 [ %33, %32 ], [ %31, %28 ]
  %35 = icmp ugt i64 %.021.1, 50
  br i1 %35, label %.critedge, label %36

36:                                               ; preds = %34
  %37 = call i64 @strtol(ptr noundef nonnull %24, ptr noundef nonnull %3, i32 noundef 10) #4
  %38 = trunc i64 %37 to i32
  %39 = load ptr, ptr %3, align 8, !tbaa !8
  %.not26.1 = icmp eq ptr %39, %26
  br i1 %.not26.1, label %select.unfold.1, label %40

40:                                               ; preds = %36
  %41 = load i8, ptr %39, align 1, !tbaa !5
  %.not27.1 = icmp eq i8 %41, 0
  br i1 %.not27.1, label %select.unfold.1, label %.critedge

select.unfold.1:                                  ; preds = %40, %36
  store i32 %38, ptr %7, align 4, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %26, i64 1
  br i1 %27, label %.critedge, label %43

43:                                               ; preds = %select.unfold.1
  %44 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %42, i32 noundef %5) #5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %50, label %46

46:                                               ; preds = %43
  %47 = ptrtoint ptr %44 to i64
  %48 = ptrtoint ptr %42 to i64
  %49 = sub i64 %47, %48
  br label %52

50:                                               ; preds = %43
  %51 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %42) #5
  br label %52

52:                                               ; preds = %50, %46
  %.021.2 = phi i64 [ %51, %50 ], [ %49, %46 ]
  %53 = icmp ugt i64 %.021.2, 50
  br i1 %53, label %.critedge, label %54

54:                                               ; preds = %52
  %55 = call i64 @strtol(ptr noundef nonnull %42, ptr noundef nonnull %3, i32 noundef 10) #4
  %56 = trunc i64 %55 to i32
  %57 = load ptr, ptr %3, align 8, !tbaa !8
  %.not26.2 = icmp eq ptr %57, %44
  br i1 %.not26.2, label %select.unfold.2, label %58

58:                                               ; preds = %54
  %59 = load i8, ptr %57, align 1, !tbaa !5
  %.not27.2 = icmp eq i8 %59, 0
  br i1 %.not27.2, label %select.unfold.2, label %.critedge

select.unfold.2:                                  ; preds = %58, %54
  store i32 %56, ptr %6, align 8, !tbaa !14
  %60 = getelementptr inbounds i8, ptr %44, i64 1
  br i1 %45, label %.critedge, label %61

61:                                               ; preds = %select.unfold.2
  %62 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %60, i32 noundef %5) #5
  %63 = icmp eq ptr %62, null
  br i1 %63, label %68, label %64

64:                                               ; preds = %61
  %65 = ptrtoint ptr %62 to i64
  %66 = ptrtoint ptr %60 to i64
  %67 = sub i64 %65, %66
  br label %70

68:                                               ; preds = %61
  %69 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %60) #5
  br label %70

70:                                               ; preds = %68, %64
  %.021.3 = phi i64 [ %69, %68 ], [ %67, %64 ]
  %71 = icmp ugt i64 %.021.3, 50
  br i1 %71, label %.critedge, label %72

72:                                               ; preds = %70
  %73 = call i64 @strtol(ptr noundef nonnull %60, ptr noundef nonnull %3, i32 noundef 10) #4
  %74 = load ptr, ptr %3, align 8, !tbaa !8
  %.not26.3 = icmp eq ptr %74, %62
  br i1 %.not26.3, label %select.unfold.3, label %75

75:                                               ; preds = %72
  %76 = load i8, ptr %74, align 1, !tbaa !5
  %.not27.3 = icmp eq i8 %76, 0
  br i1 %.not27.3, label %select.unfold.3, label %.critedge

select.unfold.3:                                  ; preds = %72, %75
  br label %.critedge

.critedge:                                        ; preds = %select.unfold.3, %16, %22, %select.unfold, %34, %40, %select.unfold.1, %52, %58, %select.unfold.2, %70, %75, %2
  %.0 = phi i32 [ 0, %2 ], [ -1, %16 ], [ -1, %22 ], [ 0, %select.unfold ], [ -1, %34 ], [ -1, %40 ], [ 0, %select.unfold.1 ], [ -1, %52 ], [ -1, %58 ], [ 0, %select.unfold.2 ], [ -1, %70 ], [ -1, %75 ], [ 0, %select.unfold.3 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret i32 %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { mustprogress nofree nounwind willreturn 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 = { mustprogress nofree nounwind willreturn "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 = { nounwind willreturn memory(read) }

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


; Effective O3 passes: ADCEPass,BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass