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

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

; 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: inlinehint mustprogress nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #1

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z11parse_mantaPc(ptr noundef %0) #2 {
  %2 = alloca %"struct.std::pair.9", align 4
  %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 @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %6 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 0
  store i32 0, ptr %6, align 4, !tbaa !9
  %7 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 1
  store i32 0, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store i64 0, ptr %4, align 8, !tbaa !13
  br label %8

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

15:                                               ; preds = %8
  %16 = load i64, ptr %4, align 8, !tbaa !13
  %17 = add i64 %16, 1
  store i64 %17, ptr %4, align 8, !tbaa !13
  br label %8, !llvm.loop !16

18:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !18
  br label %19

19:                                               ; preds = %81, %18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i64, ptr %4, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !15
  %24 = sext i8 %23 to i32
  %25 = icmp ne i32 %24, 10
  br i1 %25, label %26, label %33

26:                                               ; preds = %19
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %27, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !15
  %31 = sext i8 %30 to i32
  %32 = icmp ne i32 %31, 0
  br label %33

33:                                               ; preds = %26, %19
  %34 = phi i1 [ false, %19 ], [ %32, %26 ]
  br i1 %34, label %35, label %84

35:                                               ; preds = %33
  %36 = load i32, ptr %5, align 4, !tbaa !18
  %37 = icmp sgt i32 %36, 3
  br i1 %37, label %38, label %71

38:                                               ; preds = %35
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = load i64, ptr %4, align 8, !tbaa !13
  %41 = sub i64 %40, 1
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !15
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %44, 58
  br i1 %45, label %46, label %54

46:                                               ; preds = %38
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load i64, ptr %4, align 8, !tbaa !13
  %49 = getelementptr inbounds i8, ptr %47, i64 %48
  %50 = call i32 @atoi(ptr noundef %49) #5
  %51 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = add nsw i32 %52, %50
  store i32 %53, ptr %51, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %46, %38
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i64, ptr %4, align 8, !tbaa !13
  %57 = sub i64 %56, 1
  %58 = getelementptr inbounds i8, ptr %55, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !15
  %60 = sext i8 %59 to i32
  %61 = icmp eq i32 %60, 44
  br i1 %61, label %62, label %70

62:                                               ; preds = %54
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = load i64, ptr %4, align 8, !tbaa !13
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  %66 = call i32 @atoi(ptr noundef %65) #5
  %67 = getelementptr inbounds %"struct.std::pair.9", ptr %2, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !12
  %69 = add nsw i32 %68, %66
  store i32 %69, ptr %67, align 4, !tbaa !12
  br label %70

70:                                               ; preds = %62, %54
  br label %71

71:                                               ; preds = %70, %35
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = load i64, ptr %4, align 8, !tbaa !13
  %74 = getelementptr inbounds i8, ptr %72, i64 %73
  %75 = load i8, ptr %74, align 1, !tbaa !15
  %76 = sext i8 %75 to i32
  %77 = icmp eq i32 %76, 58
  br i1 %77, label %78, label %81

78:                                               ; preds = %71
  %79 = load i32, ptr %5, align 4, !tbaa !18
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %5, align 4, !tbaa !18
  br label %81

81:                                               ; preds = %78, %71
  %82 = load i64, ptr %4, align 8, !tbaa !13
  %83 = add i64 %82, 1
  store i64 %83, ptr %4, align 8, !tbaa !13
  br label %19, !llvm.loop !19

84:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %85 = load i64, ptr %2, align 4
  ret i64 %85
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint mustprogress nounwind willreturn memory(read) 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 = { 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, !11, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!11, !11, i64 0}
!19 = distinct !{!19, !17}


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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local i64 @_Z11parse_mantaPc(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = alloca %"struct.std::pair.9", align 8
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES3_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 0, ptr %3, align 4, !tbaa !10
  br label %4

4:                                                ; preds = %4, %1
  %.019 = phi i64 [ 0, %1 ], [ %7, %4 ]
  %5 = getelementptr inbounds i8, ptr %0, i64 %.019
  %6 = load i8, ptr %5, align 1, !tbaa !11
  %.not = icmp eq i8 %6, 9
  %7 = add i64 %.019, 1
  br i1 %.not, label %.preheader, label %4, !llvm.loop !12

.preheader:                                       ; preds = %4, %22
  %8 = phi i8 [ %.pre, %22 ], [ 9, %4 ]
  %9 = phi i32 [ %23, %22 ], [ 0, %4 ]
  %10 = phi i32 [ %24, %22 ], [ 0, %4 ]
  %.120 = phi i64 [ %27, %22 ], [ %.019, %4 ]
  %.0 = phi i32 [ %spec.select, %22 ], [ 0, %4 ]
  %11 = getelementptr inbounds i8, ptr %0, i64 %.120
  switch i8 %8, label %12 [
    i8 10, label %.critedge
    i8 0, label %.critedge
  ]

12:                                               ; preds = %.preheader
  %13 = icmp ugt i32 %.0, 3
  br i1 %13, label %14, label %22

14:                                               ; preds = %12
  %15 = getelementptr i8, ptr %11, i64 -1
  %16 = load i8, ptr %15, align 1, !tbaa !11
  switch i8 %16, label %22 [
    i8 58, label %.thread
    i8 44, label %19
  ]

.thread:                                          ; preds = %14
  %17 = call i32 @atoi(ptr nocapture noundef %11) #2
  %18 = add nsw i32 %9, %17
  store i32 %18, ptr %2, align 8, !tbaa !5
  br label %22

19:                                               ; preds = %14
  %20 = call i32 @atoi(ptr nocapture noundef %11) #2
  %21 = add nsw i32 %10, %20
  store i32 %21, ptr %3, align 4, !tbaa !10
  br label %22

22:                                               ; preds = %14, %.thread, %19, %12
  %23 = phi i32 [ %9, %14 ], [ %18, %.thread ], [ %9, %19 ], [ %9, %12 ]
  %24 = phi i32 [ %10, %14 ], [ %10, %.thread ], [ %21, %19 ], [ %10, %12 ]
  %25 = icmp eq i8 %8, 58
  %26 = zext i1 %25 to i32
  %spec.select = add nuw nsw i32 %.0, %26
  %27 = add i64 %.120, 1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 %27
  %.pre = load i8, ptr %.phi.trans.insert, align 1, !tbaa !11
  br label %.preheader, !llvm.loop !14

.critedge:                                        ; preds = %.preheader, %.preheader
  %28 = load i64, ptr %2, align 8
  ret i64 %28
}

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

attributes #0 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSSt4pairIiiE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass