; LLVM IR from fritzsedlazeck/SURVIVOR :: src/simulator/Error_scanner.ll (Z10get_lengthSt6vectorI7CigarOpSaIS0_EE)

; 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.CigarOp = type { i8, 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI7CigarOpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z10get_lengthSt6vectorI7CigarOpSaIS0_EE(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %5

5:                                                ; preds = %40, %1
  %6 = load i64, ptr %4, align 8, !tbaa !9
  %7 = call noundef i64 @_ZNKSt6vectorI7CigarOpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %8 = icmp ult i64 %6, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %43

10:                                               ; preds = %5
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %11) #2
  %13 = getelementptr inbounds %struct.CigarOp, ptr %12, i32 0, i32 0
  %14 = load i8, ptr %13, align 4, !tbaa !11
  %15 = sext i8 %14 to i32
  %16 = icmp eq i32 %15, 68
  br i1 %16, label %31, label %17

17:                                               ; preds = %10
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %18) #2
  %20 = getelementptr inbounds %struct.CigarOp, ptr %19, i32 0, i32 0
  %21 = load i8, ptr %20, align 4, !tbaa !11
  %22 = sext i8 %21 to i32
  %23 = icmp eq i32 %22, 77
  br i1 %23, label %31, label %24

24:                                               ; preds = %17
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %25) #2
  %27 = getelementptr inbounds %struct.CigarOp, ptr %26, i32 0, i32 0
  %28 = load i8, ptr %27, align 4, !tbaa !11
  %29 = sext i8 %28 to i32
  %30 = icmp eq i32 %29, 78
  br i1 %30, label %31, label %39

31:                                               ; preds = %24, %17, %10
  %32 = load i64, ptr %4, align 8, !tbaa !9
  %33 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %32) #2
  %34 = getelementptr inbounds %struct.CigarOp, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = sext i32 %35 to i64
  %37 = load i64, ptr %3, align 8, !tbaa !9
  %38 = add i64 %37, %36
  store i64 %38, ptr %3, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %31, %24
  br label %40

40:                                               ; preds = %39
  %41 = load i64, ptr %4, align 8, !tbaa !9
  %42 = add i64 %41, 1
  store i64 %42, ptr %4, align 8, !tbaa !9
  br label %5, !llvm.loop !15

43:                                               ; preds = %9
  %44 = load i64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i64 %44
}

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

!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, !7, i64 0}
!12 = !{!"_ZTS7CigarOp", !7, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI7CigarOpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z10get_lengthSt6vectorI7CigarOpSaIS0_EE(ptr noundef nonnull %0) local_unnamed_addr #0 {
  %2 = tail call noundef i64 @_ZNKSt6vectorI7CigarOpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %20, %1
  %.08.lcssa = phi i64 [ 0, %1 ], [ %.1, %20 ]
  ret i64 %.08.lcssa

.lr.ph:                                           ; preds = %1, %20
  %.010 = phi i64 [ %21, %20 ], [ 0, %1 ]
  %.089 = phi i64 [ %.1, %20 ], [ 0, %1 ]
  %3 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.010) #1
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i8 %4, 68
  br i1 %5, label %14, label %6

6:                                                ; preds = %.lr.ph
  %7 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.010) #1
  %8 = load i8, ptr %7, align 4, !tbaa !5
  %9 = icmp eq i8 %8, 77
  br i1 %9, label %14, label %10

10:                                               ; preds = %6
  %11 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.010) #1
  %12 = load i8, ptr %11, align 4, !tbaa !5
  %13 = icmp eq i8 %12, 78
  br i1 %13, label %14, label %20

14:                                               ; preds = %10, %6, %.lr.ph
  %15 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI7CigarOpSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.010) #1
  %16 = getelementptr inbounds i8, ptr %15, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !10
  %18 = sext i32 %17 to i64
  %19 = add i64 %.089, %18
  br label %20

20:                                               ; preds = %10, %14
  %.1 = phi i64 [ %19, %14 ], [ %.089, %10 ]
  %21 = add nuw i64 %.010, 1
  %22 = tail call noundef i64 @_ZNKSt6vectorI7CigarOpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !11
}

attributes #0 = { 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 #1 = { 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 = !{!"_ZTS7CigarOp", !7, i64 0, !9, i64 4}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!6, !9, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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