; LLVM IR from fritzsedlazeck/SURVIVOR :: src/convert/Process_Lumpy.ll (Z10get_coordsPKc)

; 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.strregion = type { %struct.strcoordinate, %struct.strcoordinate }
%struct.strcoordinate = type { i32, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10get_coordsPKc(ptr dead_on_unwind noalias writable sret(%struct.strregion) align 8 %0, ptr noundef %1) #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i1, align 1
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !11
  store i1 false, ptr %7, align 1
  call void @_ZN9strregionC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  store i8 0, ptr %8, align 1, !tbaa !13
  br label %11

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

18:                                               ; preds = %11
  %19 = load i32, ptr %6, align 4, !tbaa !11
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %41

21:                                               ; preds = %18
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %22, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !15
  %26 = sext i8 %25 to i32
  %27 = icmp ne i32 %26, 58
  br i1 %27, label %28, label %41

28:                                               ; preds = %21
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = getelementptr inbounds %struct.strregion, ptr %0, i32 0, i32 0
  %34 = getelementptr inbounds %struct.strcoordinate, ptr %33, i32 0, i32 1
  %35 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %34, i8 noundef signext %32)
          to label %36 unwind label %37

36:                                               ; preds = %28
  br label %41

37:                                               ; preds = %69, %28
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %9, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @_ZN9strregionD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %121

41:                                               ; preds = %36, %21, %18
  %42 = load i32, ptr %6, align 4, !tbaa !11
  %43 = icmp eq i32 %42, 2
  br i1 %43, label %44, label %59

44:                                               ; preds = %41
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = sub i64 %46, 1
  %48 = getelementptr inbounds i8, ptr %45, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !15
  %50 = sext i8 %49 to i32
  %51 = icmp eq i32 %50, 58
  br i1 %51, label %52, label %59

52:                                               ; preds = %44
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = getelementptr inbounds i8, ptr %53, i64 %54
  %56 = call i32 @atoi(ptr noundef %55) #5
  %57 = getelementptr inbounds %struct.strregion, ptr %0, i32 0, i32 0
  %58 = getelementptr inbounds %struct.strcoordinate, ptr %57, i32 0, i32 0
  store i32 %56, ptr %58, align 8, !tbaa !16
  br label %59

59:                                               ; preds = %52, %44, %41
  %60 = load i8, ptr %8, align 1, !tbaa !13, !range !21, !noundef !22
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %78

62:                                               ; preds = %59
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = load i64, ptr %5, align 8, !tbaa !9
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !15
  %67 = sext i8 %66 to i32
  %68 = icmp ne i32 %67, 58
  br i1 %68, label %69, label %78

69:                                               ; preds = %62
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i64, ptr %5, align 8, !tbaa !9
  %72 = getelementptr inbounds i8, ptr %70, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !15
  %74 = getelementptr inbounds %struct.strregion, ptr %0, i32 0, i32 1
  %75 = getelementptr inbounds %struct.strcoordinate, ptr %74, i32 0, i32 1
  %76 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %75, i8 noundef signext %73)
          to label %77 unwind label %37

77:                                               ; preds = %69
  br label %78

78:                                               ; preds = %77, %62, %59
  %79 = load i32, ptr %6, align 4, !tbaa !11
  %80 = icmp eq i32 %79, 3
  br i1 %80, label %81, label %96

81:                                               ; preds = %78
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load i64, ptr %5, align 8, !tbaa !9
  %84 = sub i64 %83, 1
  %85 = getelementptr inbounds i8, ptr %82, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !15
  %87 = sext i8 %86 to i32
  %88 = icmp eq i32 %87, 58
  br i1 %88, label %89, label %96

89:                                               ; preds = %81
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = load i64, ptr %5, align 8, !tbaa !9
  %92 = getelementptr inbounds i8, ptr %90, i64 %91
  %93 = call i32 @atoi(ptr noundef %92) #5
  %94 = getelementptr inbounds %struct.strregion, ptr %0, i32 0, i32 1
  %95 = getelementptr inbounds %struct.strcoordinate, ptr %94, i32 0, i32 0
  store i32 %93, ptr %95, align 8, !tbaa !23
  br label %96

96:                                               ; preds = %89, %81, %78
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load i64, ptr %5, align 8, !tbaa !9
  %99 = getelementptr inbounds i8, ptr %97, i64 %98
  %100 = load i8, ptr %99, align 1, !tbaa !15
  %101 = sext i8 %100 to i32
  %102 = icmp eq i32 %101, 59
  br i1 %102, label %103, label %104

103:                                              ; preds = %96
  store i8 1, ptr %8, align 1, !tbaa !13
  br label %104

104:                                              ; preds = %103, %96
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = load i64, ptr %5, align 8, !tbaa !9
  %107 = getelementptr inbounds i8, ptr %105, i64 %106
  %108 = load i8, ptr %107, align 1, !tbaa !15
  %109 = sext i8 %108 to i32
  %110 = icmp eq i32 %109, 58
  br i1 %110, label %111, label %114

111:                                              ; preds = %104
  store i8 0, ptr %8, align 1, !tbaa !13
  %112 = load i32, ptr %6, align 4, !tbaa !11
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %6, align 4, !tbaa !11
  br label %114

114:                                              ; preds = %111, %104
  %115 = load i64, ptr %5, align 8, !tbaa !9
  %116 = add i64 %115, 1
  store i64 %116, ptr %5, align 8, !tbaa !9
  br label %11, !llvm.loop !24

117:                                              ; preds = %11
  store i1 true, ptr %7, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  %118 = load i1, ptr %7, align 1
  br i1 %118, label %120, label %119

119:                                              ; preds = %117
  call void @_ZN9strregionD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) #4
  br label %120

120:                                              ; preds = %119, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void

121:                                              ; preds = %37
  %122 = load ptr, ptr %9, align 8
  %123 = load i32, ptr %10, align 4
  %124 = insertvalue { ptr, i32 } poison, ptr %122, 0
  %125 = insertvalue { ptr, i32 } %124, i32 %123, 1
  resume { ptr, i32 } %125
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9strregionD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) 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 = { inlinehint 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"_ZTS9strregion", !18, i64 0, !18, i64 40}
!18 = !{!"_ZTS13strcoordinate", !12, i64 0, !19, i64 8}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !10, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!17, !12, i64 40}
!24 = distinct !{!24, !25}
!25 = !{!"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.strregion = type { %struct.strcoordinate, %struct.strcoordinate }
%struct.strcoordinate = type { i32, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10get_coordsPKc(ptr dead_on_unwind noalias nonnull writable sret(%struct.strregion) align 8 %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN9strregionC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) #3
  %3 = load i8, ptr %1, align 1, !tbaa !5
  %.not36 = icmp eq i8 %3, 9
  br i1 %.not36, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  br label %7

7:                                                ; preds = %.lr.ph, %35
  %8 = phi i8 [ %3, %.lr.ph ], [ %42, %35 ]
  %.039 = phi i64 [ 0, %.lr.ph ], [ %40, %35 ]
  %.03038 = phi i32 [ 1, %.lr.ph ], [ %.1, %35 ]
  %.03137 = phi i1 [ false, %.lr.ph ], [ %.2, %35 ]
  %9 = getelementptr inbounds i8, ptr %1, i64 %.039
  %10 = icmp ne i32 %.03038, 1
  %.not34 = icmp eq i8 %8, 58
  %or.cond = or i1 %10, %.not34
  br i1 %or.cond, label %15, label %11

11:                                               ; preds = %7
  %12 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %4, i8 noundef signext %8)
          to label %.thread unwind label %13

13:                                               ; preds = %25, %11
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN9strregionD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %0) #3
  resume { ptr, i32 } %14

15:                                               ; preds = %7
  %16 = icmp eq i32 %.03038, 2
  br i1 %16, label %17, label %.thread

17:                                               ; preds = %15
  %18 = getelementptr i8, ptr %9, i64 -1
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp eq i8 %19, 58
  br i1 %20, label %21, label %.thread

21:                                               ; preds = %17
  %22 = tail call i32 @atoi(ptr nocapture noundef %9) #4
  store i32 %22, ptr %0, align 8, !tbaa !8
  br label %.thread

.thread:                                          ; preds = %11, %21, %17, %15
  br i1 %.03137, label %23, label %27

23:                                               ; preds = %.thread
  %24 = load i8, ptr %9, align 1, !tbaa !5
  %.not35 = icmp eq i8 %24, 58
  br i1 %.not35, label %27, label %25

25:                                               ; preds = %23
  %26 = invoke noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32) %5, i8 noundef signext %24)
          to label %27 unwind label %13

27:                                               ; preds = %25, %23, %.thread
  %28 = icmp eq i32 %.03038, 3
  br i1 %28, label %29, label %35

29:                                               ; preds = %27
  %30 = getelementptr i8, ptr %9, i64 -1
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = icmp eq i8 %31, 58
  br i1 %32, label %33, label %35

33:                                               ; preds = %29
  %34 = tail call i32 @atoi(ptr nocapture noundef %9) #4
  store i32 %34, ptr %6, align 8, !tbaa !16
  br label %35

35:                                               ; preds = %33, %29, %27
  %36 = load i8, ptr %9, align 1, !tbaa !5
  %37 = icmp eq i8 %36, 59
  %spec.select = select i1 %37, i1 true, i1 %.03137
  %38 = icmp eq i8 %36, 58
  %not. = xor i1 %38, true
  %.2 = select i1 %not., i1 %spec.select, i1 false
  %39 = zext i1 %38 to i32
  %.1 = add nuw nsw i32 %.03038, %39
  %40 = add i64 %.039, 1
  %41 = getelementptr inbounds i8, ptr %1, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %.not = icmp eq i8 %42, 9
  br i1 %.not, label %._crit_edge, label %7, !llvm.loop !17

._crit_edge:                                      ; preds = %35, %2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9strregionC2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEpLEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9strregionD2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #2 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 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 = { inlinehint 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 #3 = { nounwind }
attributes #4 = { 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, !11, i64 0}
!9 = !{!"_ZTS9strregion", !10, i64 0, !10, i64 40}
!10 = !{!"_ZTS13strcoordinate", !11, i64 0, !12, i64 8}
!11 = !{!"int", !6, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !15, i64 8, !6, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!"long", !6, i64 0}
!16 = !{!9, !11, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass