; LLVM IR from alexpizarroj/acm-icpc-trd :: src/math/deterministic-miller-rabin.ll (Z6mrtesty)

; 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" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@mr_values = external dso_local global %"class.std::vector", align 8

; 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 @_Z7fastexpyyy(i64 noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z6mrtesty(i64 noundef %0) #2 {
  %2 = alloca i1, align 1
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  %15 = load i64, ptr %3, align 8, !tbaa !5
  %16 = icmp eq i64 %15, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %104

18:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = sub i64 %19, 1
  store i64 %20, 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 !5
  br label %21

21:                                               ; preds = %25, %18
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = urem i64 %22, 2
  %24 = icmp eq i64 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %21
  %26 = load i64, ptr %5, align 8, !tbaa !5
  %27 = add i64 %26, 1
  store i64 %27, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = udiv i64 %28, 2
  store i64 %29, ptr %4, align 8, !tbaa !5
  br label %21, !llvm.loop !9

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

31:                                               ; preds = %97, %30
  %32 = load i64, ptr %6, align 8, !tbaa !5
  %33 = call noundef i64 @_ZNKSt6vectorIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @mr_values) #4
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 4, ptr %7, align 4
  br label %100

36:                                               ; preds = %31
  %37 = load i64, ptr %6, align 8, !tbaa !5
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIySaIyEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @mr_values, i64 noundef %37) #4
  %39 = load i64, ptr %38, align 8, !tbaa !5
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = sub i64 %40, 1
  %42 = icmp ugt i64 %39, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %36
  br label %97

44:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %45 = load i64, ptr %6, align 8, !tbaa !5
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIySaIyEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @mr_values, i64 noundef %45) #4
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = load i64, ptr %4, align 8, !tbaa !5
  %49 = load i64, ptr %3, align 8, !tbaa !5
  %50 = call noundef i64 @_Z7fastexpyyy(i64 noundef %47, i64 noundef %48, i64 noundef %49)
  store i64 %50, ptr %8, align 8, !tbaa !5
  %51 = load i64, ptr %8, align 8, !tbaa !5
  %52 = load i64, ptr %3, align 8, !tbaa !5
  %53 = urem i64 %51, %52
  %54 = icmp eq i64 %53, 1
  br i1 %54, label %55, label %56

55:                                               ; preds = %44
  store i32 6, ptr %7, align 4
  br label %94

56:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  store i8 0, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 0, ptr %10, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %84, %56
  %58 = load i64, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %59 = load i64, ptr %5, align 8, !tbaa !5
  %60 = sub i64 %59, 1
  store i64 %60, ptr %12, align 8, !tbaa !5
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIyERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %62 = load i64, ptr %61, align 8, !tbaa !5
  %63 = icmp ule i64 %58, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br i1 %63, label %65, label %64

64:                                               ; preds = %57
  store i32 7, ptr %7, align 4
  br label %87

65:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %66 = load i64, ptr %10, align 8, !tbaa !5
  %67 = load i64, ptr %3, align 8, !tbaa !5
  %68 = call noundef i64 @_Z7fastexpyyy(i64 noundef 2, i64 noundef %66, i64 noundef %67)
  store i64 %68, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %69 = load i64, ptr %8, align 8, !tbaa !5
  %70 = load i64, ptr %13, align 8, !tbaa !5
  %71 = load i64, ptr %3, align 8, !tbaa !5
  %72 = call noundef i64 @_Z7fastexpyyy(i64 noundef %69, i64 noundef %70, i64 noundef %71)
  store i64 %72, ptr %14, align 8, !tbaa !5
  %73 = load i64, ptr %14, align 8, !tbaa !5
  %74 = load i64, ptr %3, align 8, !tbaa !5
  %75 = urem i64 %73, %74
  %76 = load i64, ptr %3, align 8, !tbaa !5
  %77 = sub i64 %76, 1
  %78 = icmp eq i64 %75, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %65
  store i8 1, ptr %9, align 1, !tbaa !11
  store i32 7, ptr %7, align 4
  br label %81

80:                                               ; preds = %65
  store i32 0, ptr %7, align 4
  br label %81

81:                                               ; preds = %80, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %82 = load i32, ptr %7, align 4
  switch i32 %82, label %87 [
    i32 0, label %83
  ]

83:                                               ; preds = %81
  br label %84

84:                                               ; preds = %83
  %85 = load i64, ptr %10, align 8, !tbaa !5
  %86 = add i64 %85, 1
  store i64 %86, ptr %10, align 8, !tbaa !5
  br label %57, !llvm.loop !13

87:                                               ; preds = %81, %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %88

88:                                               ; preds = %87
  %89 = load i8, ptr %9, align 1, !tbaa !11, !range !14, !noundef !15
  %90 = trunc i8 %89 to i1
  br i1 %90, label %92, label %91

91:                                               ; preds = %88
  store i1 false, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %93

92:                                               ; preds = %88
  store i32 0, ptr %7, align 4
  br label %93

93:                                               ; preds = %92, %91
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %94

94:                                               ; preds = %93, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %95 = load i32, ptr %7, align 4
  switch i32 %95, label %100 [
    i32 0, label %96
    i32 6, label %97
  ]

96:                                               ; preds = %94
  br label %97

97:                                               ; preds = %96, %94, %43
  %98 = load i64, ptr %6, align 8, !tbaa !5
  %99 = add i64 %98, 1
  store i64 %99, ptr %6, align 8, !tbaa !5
  br label %31, !llvm.loop !16

100:                                              ; preds = %94, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %101 = load i32, ptr %7, align 4
  switch i32 %101, label %103 [
    i32 4, label %102
  ]

102:                                              ; preds = %100
  store i1 true, ptr %2, align 1
  store i32 1, ptr %7, align 4
  br label %103

103:                                              ; preds = %102, %100
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %104

104:                                              ; preds = %103, %17
  %105 = load i1, ptr %2, align 1
  ret i1 %105
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIyERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { 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 }

!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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !10}


; 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" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned long long, std::allocator<unsigned long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@mr_values = external dso_local global %"class.std::vector", align 8

; 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 nounwind uwtable
declare dso_local noundef i64 @_Z7fastexpyyy(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z6mrtesty(i64 noundef %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = icmp eq i64 %0, 1
  br i1 %4, label %.critedge, label %5

5:                                                ; preds = %1
  %6 = add i64 %0, -1
  %7 = and i64 %6, 1
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader47

.preheader47:                                     ; preds = %.lr.ph, %5
  %.035.lcssa = phi i64 [ -1, %5 ], [ %.03549, %.lr.ph ]
  %.030.lcssa = phi i64 [ %6, %5 ], [ %11, %.lr.ph ]
  %9 = tail call noundef i64 @_ZNKSt6vectorIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @mr_values) #3
  %.not44.not53.not = icmp eq i64 %9, 0
  br i1 %.not44.not53.not, label %.critedge, label %.lr.ph55

.lr.ph:                                           ; preds = %5, %.lr.ph
  %.03050 = phi i64 [ %11, %.lr.ph ], [ %6, %5 ]
  %.03549 = phi i64 [ %10, %.lr.ph ], [ 0, %5 ]
  %10 = add i64 %.03549, 1
  %11 = lshr exact i64 %.03050, 1
  %12 = and i64 %.03050, 2
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %.lr.ph, label %.preheader47, !llvm.loop !5

.lr.ph55:                                         ; preds = %.preheader47, %.thread
  %.04054 = phi i64 [ %32, %.thread ], [ 0, %.preheader47 ]
  %14 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIySaIyEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @mr_values, i64 noundef %.04054) #3
  %15 = load i64, ptr %14, align 8, !tbaa !7
  %16 = icmp ugt i64 %15, %6
  br i1 %16, label %.thread, label %17

17:                                               ; preds = %.lr.ph55
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIySaIyEEixEm(ptr noundef nonnull align 8 dereferenceable(24) @mr_values, i64 noundef %.04054) #3
  %19 = load i64, ptr %18, align 8, !tbaa !7
  %20 = call noundef i64 @_Z7fastexpyyy(i64 noundef %19, i64 noundef %.030.lcssa, i64 noundef %0)
  %21 = urem i64 %20, %0
  %22 = icmp eq i64 %21, 1
  br i1 %22, label %.thread, label %.preheader

.preheader:                                       ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store i64 0, ptr %2, align 8, !tbaa !7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store i64 %.035.lcssa, ptr %3, align 8, !tbaa !7
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIyERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %28

24:                                               ; preds = %28
  %25 = add i64 %.03152, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store i64 0, ptr %2, align 8, !tbaa !7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store i64 %.035.lcssa, ptr %3, align 8, !tbaa !7
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIyERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %27 = load i64, ptr %26, align 8, !tbaa !7
  %.not.not = icmp ugt i64 %25, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br i1 %.not.not, label %.critedge, label %28, !llvm.loop !11

28:                                               ; preds = %.preheader, %24
  %.03152 = phi i64 [ 0, %.preheader ], [ %25, %24 ]
  %29 = call noundef i64 @_Z7fastexpyyy(i64 noundef 2, i64 noundef %.03152, i64 noundef %0)
  %30 = call noundef i64 @_Z7fastexpyyy(i64 noundef %20, i64 noundef %29, i64 noundef %0)
  %31 = urem i64 %30, %0
  %.not43 = icmp eq i64 %31, %6
  br i1 %.not43, label %.thread, label %24

.thread:                                          ; preds = %28, %17, %.lr.ph55
  %32 = add nuw i64 %.04054, 1
  %33 = call noundef i64 @_ZNKSt6vectorIySaIyEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) @mr_values) #3
  %.not44.not = icmp ult i64 %32, %33
  br i1 %.not44.not, label %.lr.ph55, label %.critedge, !llvm.loop !12

.critedge:                                        ; preds = %.thread, %24, %.preheader47, %1
  %.6 = phi i1 [ false, %1 ], [ true, %.preheader47 ], [ false, %24 ], [ true, %.thread ]
  ret i1 %.6
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIyERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { 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 }

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


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass