; LLVM IR from EarlGray/language-incubator :: bf/bfi1.ll (Z9interpretRKSt6vectorI2OpSaIS0_EERSiRSo)

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

; 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 uwtable
declare dso_local noundef i32 @_Z9find_jumpRKSt6vectorI2OpSaIS0_EEjS0_(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9interpretRKSt6vectorI2OpSaIS0_EERSiRSo(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [30000 x i8], align 16
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 30000, ptr %9) #5
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 30000, i1 false)
  br label %13

13:                                               ; preds = %93, %91, %3
  br label %14

14:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorI2OpSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %17)
  %19 = load i32, ptr %18, align 4, !tbaa !11
  store i32 %19, ptr %11, align 4, !tbaa !11
  %20 = load i32, ptr %11, align 4, !tbaa !11
  switch i32 %20, label %81 [
    i32 0, label %21
    i32 1, label %29
    i32 2, label %37
    i32 3, label %40
    i32 4, label %43
    i32 5, label %50
    i32 6, label %57
    i32 7, label %69
  ]

21:                                               ; preds = %14
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds [30000 x i8], ptr %9, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !13
  %26 = zext i8 %25 to i32
  %27 = add nsw i32 %26, 1
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %24, align 1, !tbaa !13
  br label %81

29:                                               ; preds = %14
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds [30000 x i8], ptr %9, i64 0, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !13
  %34 = zext i8 %33 to i32
  %35 = sub nsw i32 %34, 1
  %36 = trunc i32 %35 to i8
  store i8 %36, ptr %32, align 1, !tbaa !13
  br label %81

37:                                               ; preds = %14
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = sub i32 %38, 1
  store i32 %39, ptr %8, align 4, !tbaa !9
  br label %81

40:                                               ; preds = %14
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = add i32 %41, 1
  store i32 %42, ptr %8, align 4, !tbaa !9
  br label %81

43:                                               ; preds = %14
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds [30000 x i8], ptr %9, i64 0, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !13
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo3putEc(ptr noundef nonnull align 8 dereferenceable(8) %44, i8 noundef signext %48)
  br label %81

50:                                               ; preds = %14
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) %51, ptr noundef nonnull align 1 dereferenceable(1) %10)
  %53 = load i8, ptr %10, align 1, !tbaa !13
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds [30000 x i8], ptr %9, i64 0, i64 %55
  store i8 %53, ptr %56, align 1, !tbaa !13
  br label %81

57:                                               ; preds = %14
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds [30000 x i8], ptr %9, i64 0, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !13
  %62 = zext i8 %61 to i32
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %68

64:                                               ; preds = %57
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load i32, ptr %7, align 4, !tbaa !9
  %67 = call noundef i32 @_Z9find_jumpRKSt6vectorI2OpSaIS0_EEjS0_(ptr noundef nonnull align 8 dereferenceable(24) %65, i32 noundef %66, i32 noundef 7)
  store i32 %67, ptr %7, align 4, !tbaa !9
  store i32 2, ptr %12, align 4
  br label %91, !llvm.loop !14

68:                                               ; preds = %57
  br label %81

69:                                               ; preds = %14
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds [30000 x i8], ptr %9, i64 0, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !13
  %74 = zext i8 %73 to i32
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %80

76:                                               ; preds = %69
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = load i32, ptr %7, align 4, !tbaa !9
  %79 = call noundef i32 @_Z9find_jumpRKSt6vectorI2OpSaIS0_EEjS0_(ptr noundef nonnull align 8 dereferenceable(24) %77, i32 noundef %78, i32 noundef 6)
  store i32 %79, ptr %7, align 4, !tbaa !9
  store i32 2, ptr %12, align 4
  br label %91, !llvm.loop !14

80:                                               ; preds = %69
  br label %81

81:                                               ; preds = %80, %68, %50, %43, %40, %37, %29, %21, %14
  %82 = load i32, ptr %7, align 4, !tbaa !9
  %83 = add i32 %82, 1
  store i32 %83, ptr %7, align 4, !tbaa !9
  %84 = load i32, ptr %7, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = call noundef i64 @_ZNKSt6vectorI2OpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %86) #5
  %88 = icmp uge i64 %85, %87
  br i1 %88, label %89, label %90

89:                                               ; preds = %81
  store i32 3, ptr %12, align 4
  br label %91

90:                                               ; preds = %81
  store i32 0, ptr %12, align 4
  br label %91

91:                                               ; preds = %90, %89, %76, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  %92 = load i32, ptr %12, align 4
  switch i32 %92, label %95 [
    i32 0, label %93
    i32 2, label %13
    i32 3, label %94
  ]

93:                                               ; preds = %91
  br label %13, !llvm.loop !14

94:                                               ; preds = %91
  call void @llvm.lifetime.end.p0(i64 30000, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void

95:                                               ; preds = %91
  unreachable
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo3putEc(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #3

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS2Op", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 uwtable
declare dso_local noundef i32 @_Z9find_jumpRKSt6vectorI2OpSaIS0_EEjS0_(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9interpretRKSt6vectorI2OpSaIS0_EERSiRSo(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) local_unnamed_addr #1 {
  %4 = alloca [30000 x i8], align 16
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 30000, ptr nonnull %4) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(30000) %4, i8 0, i64 30000, i1 false)
  br label %6

6:                                                ; preds = %select.unfold, %3
  %.021 = phi i32 [ 0, %3 ], [ %.2, %select.unfold ]
  %.020 = phi i32 [ 0, %3 ], [ %.1, %select.unfold ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #5
  %7 = zext i32 %.020 to i64
  %8 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorI2OpSaIS0_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7)
  %9 = load i32, ptr %8, align 4, !tbaa !5
  switch i32 %9, label %43 [
    i32 0, label %10
    i32 1, label %15
    i32 2, label %20
    i32 3, label %22
    i32 4, label %24
    i32 5, label %29
    i32 6, label %34
    i32 7, label %39
  ]

10:                                               ; preds = %6
  %11 = zext i32 %.021 to i64
  %12 = getelementptr inbounds [30000 x i8], ptr %4, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = add i8 %13, 1
  store i8 %14, ptr %12, align 1, !tbaa !9
  br label %43

15:                                               ; preds = %6
  %16 = zext i32 %.021 to i64
  %17 = getelementptr inbounds [30000 x i8], ptr %4, i64 0, i64 %16
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = add i8 %18, -1
  store i8 %19, ptr %17, align 1, !tbaa !9
  br label %43

20:                                               ; preds = %6
  %21 = add i32 %.021, -1
  br label %43

22:                                               ; preds = %6
  %23 = add i32 %.021, 1
  br label %43

24:                                               ; preds = %6
  %25 = zext i32 %.021 to i64
  %26 = getelementptr inbounds [30000 x i8], ptr %4, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo3putEc(ptr noundef nonnull align 8 dereferenceable(8) %2, i8 noundef signext %27)
  br label %43

29:                                               ; preds = %6
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 1 dereferenceable(1) %5)
  %31 = load i8, ptr %5, align 1, !tbaa !9
  %32 = zext i32 %.021 to i64
  %33 = getelementptr inbounds [30000 x i8], ptr %4, i64 0, i64 %32
  store i8 %31, ptr %33, align 1, !tbaa !9
  br label %43

34:                                               ; preds = %6
  %35 = zext i32 %.021 to i64
  %36 = getelementptr inbounds [30000 x i8], ptr %4, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = icmp eq i8 %37, 0
  br i1 %38, label %select.unfold.sink.split, label %43, !llvm.loop !10

39:                                               ; preds = %6
  %40 = zext i32 %.021 to i64
  %41 = getelementptr inbounds [30000 x i8], ptr %4, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %.not = icmp eq i8 %42, 0
  br i1 %.not, label %43, label %select.unfold.sink.split, !llvm.loop !10

43:                                               ; preds = %39, %34, %29, %24, %22, %20, %15, %10, %6
  %.122 = phi i32 [ %.021, %6 ], [ %.021, %39 ], [ %.021, %34 ], [ %.021, %29 ], [ %.021, %24 ], [ %23, %22 ], [ %21, %20 ], [ %.021, %15 ], [ %.021, %10 ]
  %44 = add i32 %.020, 1
  %45 = zext i32 %44 to i64
  %46 = call noundef i64 @_ZNKSt6vectorI2OpSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %.not23 = icmp ugt i64 %46, %45
  br i1 %.not23, label %select.unfold, label %48

select.unfold.sink.split:                         ; preds = %39, %34
  %.sink = phi i32 [ 7, %34 ], [ 6, %39 ]
  %47 = call noundef i32 @_Z9find_jumpRKSt6vectorI2OpSaIS0_EEjS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.020, i32 noundef %.sink)
  br label %select.unfold

select.unfold:                                    ; preds = %select.unfold.sink.split, %43
  %.2 = phi i32 [ %.122, %43 ], [ %.021, %select.unfold.sink.split ]
  %.1 = phi i32 [ %44, %43 ], [ %47, %select.unfold.sink.split ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #5
  br label %6

48:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 30000, ptr nonnull %4) #5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo3putEc(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #3

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { 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 #5 = { 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 = !{!"_ZTS2Op", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass