; LLVM IR from fritzsedlazeck/SURVIVOR :: src/vcfs/Merge_VCF.ll (Z13parse_strandsPKc)

; 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.std::pair" = type { i8, i8 }

@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 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: 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 i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local i16 @_Z13parse_strandsPKc(ptr noundef %0) #2 {
  %2 = alloca %"struct.std::pair", align 1
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @_ZNSt4pairIbbEC2IbbTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 1 dereferenceable(2) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %6

6:                                                ; preds = %67, %1
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load i64, ptr %4, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %7, i64 %8
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = sext i8 %10 to i32
  %12 = icmp ne i32 %11, 9
  br i1 %12, label %13, label %29

13:                                               ; preds = %6
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load i64, ptr %4, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %14, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !11
  %18 = sext i8 %17 to i32
  %19 = icmp ne i32 %18, 10
  br i1 %19, label %20, label %27

20:                                               ; preds = %13
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load i64, ptr %4, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %21, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp ne i32 %25, 0
  br label %27

27:                                               ; preds = %20, %13
  %28 = phi i1 [ false, %13 ], [ %26, %20 ]
  br label %29

29:                                               ; preds = %27, %6
  %30 = phi i1 [ false, %6 ], [ %28, %27 ]
  br i1 %30, label %31, label %70

31:                                               ; preds = %29
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load i64, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  %35 = call i32 @strncmp(ptr noundef %34, ptr noundef @.str.4, i64 noundef 4) #5
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %31
  %38 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 0
  store i8 0, ptr %38, align 1, !tbaa !12
  %39 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 1
  store i8 1, ptr %39, align 1, !tbaa !15
  store i32 1, ptr %5, align 4
  br label %71

40:                                               ; preds = %31
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load i64, ptr %4, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %41, i64 %42
  %44 = call i32 @strncmp(ptr noundef %43, ptr noundef @.str.5, i64 noundef 4) #5
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %49

46:                                               ; preds = %40
  %47 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 0
  store i8 0, ptr %47, align 1, !tbaa !12
  %48 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 1
  store i8 0, ptr %48, align 1, !tbaa !15
  store i32 1, ptr %5, align 4
  br label %71

49:                                               ; preds = %40
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load i64, ptr %4, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  %53 = call i32 @strncmp(ptr noundef %52, ptr noundef @.str.6, i64 noundef 4) #5
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %58

55:                                               ; preds = %49
  %56 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 0
  store i8 1, ptr %56, align 1, !tbaa !12
  %57 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 1
  store i8 0, ptr %57, align 1, !tbaa !15
  store i32 1, ptr %5, align 4
  br label %71

58:                                               ; preds = %49
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load i64, ptr %4, align 8, !tbaa !9
  %61 = getelementptr inbounds i8, ptr %59, i64 %60
  %62 = call i32 @strncmp(ptr noundef %61, ptr noundef @.str.7, i64 noundef 4) #5
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %67

64:                                               ; preds = %58
  %65 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 0
  store i8 1, ptr %65, align 1, !tbaa !12
  %66 = getelementptr inbounds %"struct.std::pair", ptr %2, i32 0, i32 1
  store i8 1, ptr %66, align 1, !tbaa !15
  store i32 1, ptr %5, align 4
  br label %71

67:                                               ; preds = %58
  %68 = load i64, ptr %4, align 8, !tbaa !9
  %69 = add i64 %68, 1
  store i64 %69, ptr %4, align 8, !tbaa !9
  br label %6, !llvm.loop !16

70:                                               ; preds = %29
  store i32 1, ptr %5, align 4
  br label %71

71:                                               ; preds = %70, %64, %55, %46, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %72 = load i16, ptr %2, align 1
  ret i16 %72
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIbbEC2IbbTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 1 dereferenceable(2)) unnamed_addr #3 align 2

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 = { mustprogress 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 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTSSt4pairIbbE", !14, i64 0, !14, i64 1}
!14 = !{!"bool", !7, i64 0}
!15 = !{!13, !14, i64 1}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%"struct.std::pair" = type { i8, i8 }

@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local i16 @_Z13parse_strandsPKc(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca %"struct.std::pair", align 2
  call void @_ZNSt4pairIbbEC2IbbTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 1 dereferenceable(2) %2)
  br label %3

3:                                                ; preds = %18, %1
  %.0 = phi i64 [ 0, %1 ], [ %21, %18 ]
  %4 = getelementptr inbounds i8, ptr %0, i64 %.0
  %5 = load i8, ptr %4, align 1, !tbaa !5
  switch i8 %5, label %6 [
    i8 9, label %.critedge
    i8 10, label %.critedge
    i8 0, label %.critedge
  ]

6:                                                ; preds = %3
  %7 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef 4) #2
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  store i8 0, ptr %2, align 2, !tbaa !8
  br label %.critedge.sink.split

10:                                               ; preds = %6
  %11 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.5, i64 noundef 4) #2
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  store i8 0, ptr %2, align 2, !tbaa !8
  br label %.critedge.sink.split

14:                                               ; preds = %10
  %15 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef 4) #2
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  store i8 1, ptr %2, align 2, !tbaa !8
  br label %.critedge.sink.split

18:                                               ; preds = %14
  %19 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.7, i64 noundef 4) #2
  %20 = icmp eq i32 %19, 0
  %21 = add i64 %.0, 1
  br i1 %20, label %22, label %3, !llvm.loop !11

22:                                               ; preds = %18
  store i8 1, ptr %2, align 2, !tbaa !8
  br label %.critedge.sink.split

.critedge.sink.split:                             ; preds = %9, %13, %17, %22
  %.sink = phi i8 [ 1, %22 ], [ 0, %17 ], [ 0, %13 ], [ 1, %9 ]
  %23 = getelementptr inbounds i8, ptr %2, i64 1
  store i8 %.sink, ptr %23, align 1, !tbaa !13
  br label %.critedge

.critedge:                                        ; preds = %3, %3, %3, %.critedge.sink.split
  %24 = load i16, ptr %2, align 2
  ret i16 %24
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIbbEC2IbbTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 1 dereferenceable(2)) unnamed_addr #1 align 2

attributes #0 = { 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 #1 = { mustprogress 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 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++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTSSt4pairIbbE", !10, i64 0, !10, i64 1}
!10 = !{!"bool", !6, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!9, !10, i64 1}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass