; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/SHORT/COOK68/Problem D/gvaibhav.ll (Z5Queryeb)

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

%"class.std::vector.1" = type { %"struct.std::_Vector_base.2" }
%"struct.std::_Vector_base.2" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@pointer = external dso_local global [2 x i32], align 4
@M = external dso_local global [2 x %"class.std::vector.1"], align 16
@B = external dso_local global [2 x %"class.std::vector.1"], align 16

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef x86_fp80 @_Z5Queryeb(x86_fp80 noundef %0, i1 noundef zeroext %1) #1 {
  %3 = alloca x86_fp80, align 16
  %4 = alloca i8, align 1
  store x86_fp80 %0, ptr %3, align 16, !tbaa !5
  %5 = zext i1 %1 to i8
  store i8 %5, ptr %4, align 1, !tbaa !9
  %6 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc i8 %6 to i1
  %8 = zext i1 %7 to i64
  %9 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !13
  %11 = sext i32 %10 to i64
  %12 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %13 = trunc i8 %12 to i1
  %14 = zext i1 %13 to i64
  %15 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %14
  %16 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #2
  %17 = icmp uge i64 %11, %16
  br i1 %17, label %18, label %30

18:                                               ; preds = %2
  %19 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %20 = trunc i8 %19 to i1
  %21 = zext i1 %20 to i64
  %22 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %21
  %23 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #2
  %24 = sub i64 %23, 1
  %25 = trunc i64 %24 to i32
  %26 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %27 = trunc i8 %26 to i1
  %28 = zext i1 %27 to i64
  %29 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %28
  store i32 %25, ptr %29, align 4, !tbaa !13
  br label %30

30:                                               ; preds = %18, %2
  br label %31

31:                                               ; preds = %107, %30
  %32 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %33 = trunc i8 %32 to i1
  %34 = zext i1 %33 to i64
  %35 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !13
  %37 = sext i32 %36 to i64
  %38 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %39 = trunc i8 %38 to i1
  %40 = zext i1 %39 to i64
  %41 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %40
  %42 = call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %41) #2
  %43 = sub i64 %42, 1
  %44 = icmp ult i64 %37, %43
  br i1 %44, label %45, label %105

45:                                               ; preds = %31
  %46 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %47 = trunc i8 %46 to i1
  %48 = zext i1 %47 to i64
  %49 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %48
  %50 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %51 = trunc i8 %50 to i1
  %52 = zext i1 %51 to i64
  %53 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !13
  %55 = add nsw i32 %54, 1
  %56 = sext i32 %55 to i64
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %56) #2
  %58 = load i64, ptr %57, align 8, !tbaa !15
  %59 = sitofp i64 %58 to x86_fp80
  %60 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %61 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %62 = trunc i8 %61 to i1
  %63 = zext i1 %62 to i64
  %64 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @B, i64 0, i64 %63
  %65 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %66 = trunc i8 %65 to i1
  %67 = zext i1 %66 to i64
  %68 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !13
  %70 = add nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %64, i64 noundef %71) #2
  %73 = load i64, ptr %72, align 8, !tbaa !15
  %74 = sitofp i64 %73 to x86_fp80
  %75 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %59, x86_fp80 %60, x86_fp80 %74)
  %76 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %77 = trunc i8 %76 to i1
  %78 = zext i1 %77 to i64
  %79 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %78
  %80 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %81 = trunc i8 %80 to i1
  %82 = zext i1 %81 to i64
  %83 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !13
  %85 = sext i32 %84 to i64
  %86 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %79, i64 noundef %85) #2
  %87 = load i64, ptr %86, align 8, !tbaa !15
  %88 = sitofp i64 %87 to x86_fp80
  %89 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %90 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %91 = trunc i8 %90 to i1
  %92 = zext i1 %91 to i64
  %93 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @B, i64 0, i64 %92
  %94 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %95 = trunc i8 %94 to i1
  %96 = zext i1 %95 to i64
  %97 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !13
  %99 = sext i32 %98 to i64
  %100 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %93, i64 noundef %99) #2
  %101 = load i64, ptr %100, align 8, !tbaa !15
  %102 = sitofp i64 %101 to x86_fp80
  %103 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %88, x86_fp80 %89, x86_fp80 %102)
  %104 = fcmp olt x86_fp80 %75, %103
  br label %105

105:                                              ; preds = %45, %31
  %106 = phi i1 [ false, %31 ], [ %104, %45 ]
  br i1 %106, label %107, label %114

107:                                              ; preds = %105
  %108 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %109 = trunc i8 %108 to i1
  %110 = zext i1 %109 to i64
  %111 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !13
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %111, align 4, !tbaa !13
  br label %31, !llvm.loop !17

114:                                              ; preds = %105
  %115 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %116 = trunc i8 %115 to i1
  %117 = zext i1 %116 to i64
  %118 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %117
  %119 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %120 = trunc i8 %119 to i1
  %121 = zext i1 %120 to i64
  %122 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !13
  %124 = sext i32 %123 to i64
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %118, i64 noundef %124) #2
  %126 = load i64, ptr %125, align 8, !tbaa !15
  %127 = sitofp i64 %126 to x86_fp80
  %128 = load x86_fp80, ptr %3, align 16, !tbaa !5
  %129 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %130 = trunc i8 %129 to i1
  %131 = zext i1 %130 to i64
  %132 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @B, i64 0, i64 %131
  %133 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %134 = trunc i8 %133 to i1
  %135 = zext i1 %134 to i64
  %136 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !13
  %138 = sext i32 %137 to i64
  %139 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %132, i64 noundef %138) #2
  %140 = load i64, ptr %139, align 8, !tbaa !15
  %141 = sitofp i64 %140 to x86_fp80
  %142 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %127, x86_fp80 %128, x86_fp80 %141)
  ret x86_fp80 %142
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%"class.std::vector.1" = type { %"struct.std::_Vector_base.2" }
%"struct.std::_Vector_base.2" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@pointer = external dso_local local_unnamed_addr global [2 x i32], align 4
@M = external dso_local global [2 x %"class.std::vector.1"], align 16
@B = external dso_local global [2 x %"class.std::vector.1"], align 16

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef x86_fp80 @_Z5Queryeb(x86_fp80 noundef %0, i1 noundef zeroext %1) local_unnamed_addr #1 {
  %3 = zext i1 %1 to i64
  %4 = getelementptr inbounds [2 x i32], ptr @pointer, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @M, i64 0, i64 %3
  %8 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %.not = icmp ugt i64 %8, %6
  br i1 %.not, label %._crit_edge, label %9

._crit_edge:                                      ; preds = %2
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %13

9:                                                ; preds = %2
  %10 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %11 = trunc i64 %10 to i32
  %12 = add i32 %11, -1
  store i32 %12, ptr %4, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %._crit_edge, %9
  %14 = phi i32 [ %.pre, %._crit_edge ], [ %12, %9 ]
  %15 = sext i32 %14 to i64
  %16 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %17 = add i64 %16, -1
  %18 = icmp ugt i64 %17, %15
  br i1 %18, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %13
  %19 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @B, i64 0, i64 %3
  br label %20

20:                                               ; preds = %.lr.ph, %46
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %23) #2
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = sitofp i64 %25 to x86_fp80
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %29) #2
  %31 = load i64, ptr %30, align 8, !tbaa !9
  %32 = sitofp i64 %31 to x86_fp80
  %33 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %26, x86_fp80 %0, x86_fp80 %32)
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %35) #2
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = sitofp i64 %37 to x86_fp80
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %40) #2
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = sitofp i64 %42 to x86_fp80
  %44 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %38, x86_fp80 %0, x86_fp80 %43)
  %45 = fcmp olt x86_fp80 %33, %44
  br i1 %45, label %46, label %.critedge

46:                                               ; preds = %20
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = tail call noundef i64 @_ZNKSt6vectorIxSaIxEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %51 = add i64 %50, -1
  %52 = icmp ugt i64 %51, %49
  br i1 %52, label %20, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %20, %46, %13
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %54) #2
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = sitofp i64 %56 to x86_fp80
  %58 = getelementptr inbounds [2 x %"class.std::vector.1"], ptr @B, i64 0, i64 %3
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIxSaIxEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %58, i64 noundef %60) #2
  %62 = load i64, ptr %61, align 8, !tbaa !9
  %63 = sitofp i64 %62 to x86_fp80
  %64 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %57, x86_fp80 %0, x86_fp80 %63)
  ret x86_fp80 %64
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass