; LLVM IR from kazunetakahashi/atcoder :: 201411_201509/0725_ARC042/D3.ll (Z6answerv)

; 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::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@X = external dso_local global i64, align 8
@P = external dso_local global i64, align 8
@A = external dso_local global i64, align 8
@B = external dso_local global i64, align 8
@m = external dso_local global i64, align 8
@gyaku = external dso_local global i64, align 8
@M = external dso_local global %"class.std::unordered_map", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._Z6answerv = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5poweri(i32 noundef) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z4bsgsx(i64 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEEixERS5_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6answerv() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i32, align 4
  %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 i32, align 4
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @X)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) @P)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(8) @A)
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(8) @B)
  %13 = load i64, ptr @A, align 8, !tbaa !5
  %14 = load i64, ptr @P, align 8, !tbaa !5
  %15 = sub nsw i64 %14, 1
  %16 = srem i64 %13, %15
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %30, label %18

18:                                               ; preds = %0
  %19 = load i64, ptr @A, align 8, !tbaa !5
  %20 = load i64, ptr @A, align 8, !tbaa !5
  %21 = load i64, ptr @P, align 8, !tbaa !5
  %22 = sub nsw i64 %21, 1
  %23 = srem i64 %20, %22
  %24 = sub nsw i64 %19, %23
  %25 = load i64, ptr @P, align 8, !tbaa !5
  %26 = sub nsw i64 %25, 1
  %27 = add nsw i64 %24, %26
  %28 = load i64, ptr @B, align 8, !tbaa !5
  %29 = icmp sle i64 %27, %28
  br i1 %29, label %30, label %33

30:                                               ; preds = %18, %0
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %31, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %148

33:                                               ; preds = %18
  %34 = load i64, ptr @B, align 8, !tbaa !5
  %35 = load i64, ptr @A, align 8, !tbaa !5
  %36 = sub nsw i64 %34, %35
  %37 = add nsw i64 %36, 1
  %38 = icmp sgt i64 %37, 16777216
  br i1 %38, label %39, label %114

39:                                               ; preds = %33
  %40 = load i64, ptr @P, align 8, !tbaa !5
  %41 = sub nsw i64 %40, 1
  %42 = load i64, ptr @B, align 8, !tbaa !5
  %43 = srem i64 %42, %41
  store i64 %43, ptr @B, align 8, !tbaa !5
  %44 = load i64, ptr @P, align 8, !tbaa !5
  %45 = sub nsw i64 %44, 1
  %46 = load i64, ptr @A, align 8, !tbaa !5
  %47 = srem i64 %46, %45
  store i64 %47, ptr @A, align 8, !tbaa !5
  %48 = load i64, ptr @P, align 8, !tbaa !5
  %49 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %48)
  %50 = fadd double %49, 1.000000e+00
  %51 = fptosi double %50 to i64
  store i64 %51, ptr @m, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #7
  store i64 1, ptr %1, align 8, !tbaa !5
  call void @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(56) @M) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %68, %39
  %53 = load i32, ptr %2, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr @m, align 8, !tbaa !5
  %56 = icmp slt i64 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %71

58:                                               ; preds = %52
  %59 = load i32, ptr %2, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEEixERS5_(ptr noundef nonnull align 8 dereferenceable(56) @M, ptr noundef nonnull align 8 dereferenceable(8) %1)
  store i64 %60, ptr %61, align 8, !tbaa !5
  %62 = load i64, ptr @X, align 8, !tbaa !5
  %63 = load i64, ptr %1, align 8, !tbaa !5
  %64 = mul nsw i64 %63, %62
  store i64 %64, ptr %1, align 8, !tbaa !5
  %65 = load i64, ptr @P, align 8, !tbaa !5
  %66 = load i64, ptr %1, align 8, !tbaa !5
  %67 = srem i64 %66, %65
  store i64 %67, ptr %1, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %58
  %69 = load i32, ptr %2, align 4, !tbaa !9
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %2, align 4, !tbaa !9
  br label %52, !llvm.loop !11

71:                                               ; preds = %57
  %72 = load i64, ptr @P, align 8, !tbaa !5
  %73 = icmp eq i64 %72, 2
  br i1 %73, label %74, label %75

74:                                               ; preds = %71
  br label %82

75:                                               ; preds = %71
  %76 = load i64, ptr @P, align 8, !tbaa !5
  %77 = sub nsw i64 %76, 1
  %78 = load i64, ptr @m, align 8, !tbaa !5
  %79 = sub nsw i64 %77, %78
  %80 = trunc i64 %79 to i32
  %81 = call noundef i64 @_Z5poweri(i32 noundef %80)
  br label %82

82:                                               ; preds = %75, %74
  %83 = phi i64 [ 1, %74 ], [ %81, %75 ]
  store i64 %83, ptr @gyaku, align 8, !tbaa !5
  %84 = load i64, ptr @gyaku, align 8, !tbaa !5
  %85 = load i64, ptr @m, align 8, !tbaa !5
  %86 = trunc i64 %85 to i32
  %87 = call noundef i64 @_Z5poweri(i32 noundef %86)
  %88 = mul nsw i64 %84, %87
  %89 = load i64, ptr @P, align 8, !tbaa !5
  %90 = srem i64 %88, %89
  %91 = icmp eq i64 %90, 1
  br i1 %91, label %92, label %93

92:                                               ; preds = %82
  br label %95

93:                                               ; preds = %82
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 52, ptr noundef @__PRETTY_FUNCTION__._Z6answerv) #8
  unreachable

94:                                               ; No predecessors!
  br label %95

95:                                               ; preds = %94, %92
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %96

96:                                               ; preds = %108, %95
  %97 = load i64, ptr %4, align 8, !tbaa !5
  %98 = add nsw i64 %97, 1
  store i64 %98, ptr %4, align 8, !tbaa !5
  %99 = call noundef i64 @_Z4bsgsx(i64 noundef %98)
  store i64 %99, ptr %3, align 8, !tbaa !5
  br label %100

100:                                              ; preds = %96
  %101 = load i64, ptr @A, align 8, !tbaa !5
  %102 = load i64, ptr %3, align 8, !tbaa !5
  %103 = icmp sgt i64 %101, %102
  br i1 %103, label %108, label %104

104:                                              ; preds = %100
  %105 = load i64, ptr %3, align 8, !tbaa !5
  %106 = load i64, ptr @B, align 8, !tbaa !5
  %107 = icmp sgt i64 %105, %106
  br label %108

108:                                              ; preds = %104, %100
  %109 = phi i1 [ true, %100 ], [ %107, %104 ]
  br i1 %109, label %96, label %110, !llvm.loop !13

110:                                              ; preds = %108
  %111 = load i64, ptr %4, align 8, !tbaa !5
  %112 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %111)
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %112, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #7
  br label %148

114:                                              ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %115 = load i64, ptr @P, align 8, !tbaa !5
  store i64 %115, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %116 = load i64, ptr @A, align 8, !tbaa !5
  %117 = trunc i64 %116 to i32
  %118 = call noundef i64 @_Z5poweri(i32 noundef %117)
  store i64 %118, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %119

119:                                              ; preds = %140, %114
  %120 = load i32, ptr %7, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = load i64, ptr @B, align 8, !tbaa !5
  %123 = load i64, ptr @A, align 8, !tbaa !5
  %124 = sub nsw i64 %122, %123
  %125 = icmp sle i64 %121, %124
  br i1 %125, label %127, label %126

126:                                              ; preds = %119
  store i32 7, ptr %8, align 4
  br label %143

127:                                              ; preds = %119
  %128 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %129 = load i64, ptr %128, align 8, !tbaa !5
  store i64 %129, ptr %5, align 8, !tbaa !5
  %130 = load i64, ptr %5, align 8, !tbaa !5
  %131 = icmp eq i64 %130, 1
  br i1 %131, label %132, label %133

132:                                              ; preds = %127
  store i32 7, ptr %8, align 4
  br label %143

133:                                              ; preds = %127
  %134 = load i64, ptr @X, align 8, !tbaa !5
  %135 = load i64, ptr %6, align 8, !tbaa !5
  %136 = mul nsw i64 %135, %134
  store i64 %136, ptr %6, align 8, !tbaa !5
  %137 = load i64, ptr @P, align 8, !tbaa !5
  %138 = load i64, ptr %6, align 8, !tbaa !5
  %139 = srem i64 %138, %137
  store i64 %139, ptr %6, align 8, !tbaa !5
  br label %140

140:                                              ; preds = %133
  %141 = load i32, ptr %7, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %7, align 4, !tbaa !9
  br label %119, !llvm.loop !14

143:                                              ; preds = %132, %126
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %144

144:                                              ; preds = %143
  %145 = load i64, ptr %5, align 8, !tbaa !5
  %146 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %145)
  %147 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %146, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %148

148:                                              ; preds = %144, %110, %30
  ret void
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(56)) #5 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #6

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 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 = { 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 #5 = { 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 #6 = { noreturn nounwind "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 #7 = { nounwind }
attributes #8 = { noreturn 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@X = external dso_local global i64, align 8
@P = external dso_local global i64, align 8
@A = external dso_local global i64, align 8
@B = external dso_local global i64, align 8
@m = external dso_local local_unnamed_addr global i64, align 8
@gyaku = external dso_local local_unnamed_addr global i64, align 8
@M = external dso_local global %"class.std::unordered_map", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__._Z6answerv = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5poweri(i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z4bsgsx(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEEixERS5_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6answerv() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @X)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(8) @P)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(8) @A)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(8) @B)
  %8 = load i64, ptr @A, align 8, !tbaa !5
  %9 = load i64, ptr @P, align 8, !tbaa !5
  %10 = add nsw i64 %9, -1
  %11 = srem i64 %8, %10
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %17, label %13

13:                                               ; preds = %0
  %14 = sub i64 %8, %11
  %15 = add nsw i64 %14, %10
  %16 = load i64, ptr @B, align 8, !tbaa !5
  %.not = icmp sgt i64 %15, %16
  br i1 %.not, label %20, label %17

17:                                               ; preds = %13, %0
  %18 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 1)
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %85

20:                                               ; preds = %13
  %21 = sub nsw i64 %16, %8
  %22 = icmp sgt i64 %21, 16777215
  br i1 %22, label %23, label %65

23:                                               ; preds = %20
  %24 = srem i64 %16, %10
  store i64 %24, ptr @B, align 8, !tbaa !5
  store i64 %11, ptr @A, align 8, !tbaa !5
  %25 = tail call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %9)
  %26 = fadd double %25, 1.000000e+00
  %27 = fptosi double %26 to i64
  store i64 %27, ptr @m, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  store i64 1, ptr %1, align 8, !tbaa !5
  tail call void @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(56) @M) #7
  %28 = load i64, ptr @m, align 8, !tbaa !5
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %.lr.ph23, label %.._crit_edge24_crit_edge

.._crit_edge24_crit_edge:                         ; preds = %23
  %.pre = load i64, ptr @P, align 8, !tbaa !5
  br label %._crit_edge24

._crit_edge24:                                    ; preds = %.lr.ph23, %.._crit_edge24_crit_edge
  %30 = phi i64 [ %.pre, %.._crit_edge24_crit_edge ], [ %36, %.lr.ph23 ]
  %.lcssa17 = phi i64 [ %28, %.._crit_edge24_crit_edge ], [ %38, %.lr.ph23 ]
  %31 = icmp eq i64 %30, 2
  br i1 %31, label %45, label %40

.lr.ph23:                                         ; preds = %23, %.lr.ph23
  %indvars.iv27 = phi i64 [ %indvars.iv.next28, %.lr.ph23 ], [ 0, %23 ]
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEEixERS5_(ptr noundef nonnull align 8 dereferenceable(56) @M, ptr noundef nonnull align 8 dereferenceable(8) %1)
  store i64 %indvars.iv27, ptr %32, align 8, !tbaa !5
  %33 = load i64, ptr @X, align 8, !tbaa !5
  %34 = load i64, ptr %1, align 8, !tbaa !5
  %35 = mul nsw i64 %34, %33
  %36 = load i64, ptr @P, align 8, !tbaa !5
  %37 = srem i64 %35, %36
  store i64 %37, ptr %1, align 8, !tbaa !5
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %38 = load i64, ptr @m, align 8, !tbaa !5
  %39 = icmp sgt i64 %38, %indvars.iv.next28
  br i1 %39, label %.lr.ph23, label %._crit_edge24, !llvm.loop !9

40:                                               ; preds = %._crit_edge24
  %41 = xor i64 %.lcssa17, -1
  %42 = add i64 %30, %41
  %43 = trunc i64 %42 to i32
  %44 = call noundef i64 @_Z5poweri(i32 noundef %43)
  %.pre30 = load i64, ptr @m, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %._crit_edge24, %40
  %46 = phi i64 [ %.pre30, %40 ], [ %.lcssa17, %._crit_edge24 ]
  %47 = phi i64 [ %44, %40 ], [ 1, %._crit_edge24 ]
  store i64 %47, ptr @gyaku, align 8, !tbaa !5
  %48 = trunc i64 %46 to i32
  %49 = call noundef i64 @_Z5poweri(i32 noundef %48)
  %50 = mul nsw i64 %49, %47
  %51 = load i64, ptr @P, align 8, !tbaa !5
  %52 = srem i64 %50, %51
  %53 = icmp eq i64 %52, 1
  br i1 %53, label %.preheader, label %54

54:                                               ; preds = %45
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 52, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6answerv) #8
  unreachable

.preheader:                                       ; preds = %45, %.preheader
  %.09 = phi i64 [ %55, %.preheader ], [ 0, %45 ]
  %55 = add nuw nsw i64 %.09, 1
  %56 = call noundef i64 @_Z4bsgsx(i64 noundef %55)
  %57 = load i64, ptr @A, align 8, !tbaa !5
  %58 = icmp sgt i64 %57, %56
  %59 = load i64, ptr @B, align 8
  %60 = icmp sgt i64 %56, %59
  %61 = select i1 %58, i1 true, i1 %60
  br i1 %61, label %.preheader, label %62, !llvm.loop !11

62:                                               ; preds = %.preheader
  %63 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %55)
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %63, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  br label %85

65:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 %9, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %66 = trunc i64 %8 to i32
  %67 = tail call noundef i64 @_Z5poweri(i32 noundef %66)
  store i64 %67, ptr %3, align 8, !tbaa !5
  %68 = load i64, ptr @B, align 8, !tbaa !5
  %69 = load i64, ptr @A, align 8, !tbaa !5
  %.not1618 = icmp slt i64 %68, %69
  br i1 %.not1618, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %65, %73
  %indvars.iv = phi i64 [ %indvars.iv.next, %73 ], [ 0, %65 ]
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %71 = load i64, ptr %70, align 8, !tbaa !5
  store i64 %71, ptr %2, align 8, !tbaa !5
  %72 = icmp eq i64 %71, 1
  br i1 %72, label %._crit_edge, label %73

73:                                               ; preds = %.lr.ph
  %74 = load i64, ptr @X, align 8, !tbaa !5
  %75 = load i64, ptr %3, align 8, !tbaa !5
  %76 = mul nsw i64 %75, %74
  %77 = load i64, ptr @P, align 8, !tbaa !5
  %78 = srem i64 %76, %77
  store i64 %78, ptr %3, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %79 = load i64, ptr @B, align 8, !tbaa !5
  %80 = load i64, ptr @A, align 8, !tbaa !5
  %81 = sub nsw i64 %79, %80
  %.not16.not = icmp sgt i64 %81, %indvars.iv
  br i1 %.not16.not, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %73, %.lr.ph, %65
  %82 = phi i64 [ %9, %65 ], [ %71, %73 ], [ 1, %.lr.ph ]
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %82)
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %83, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %85

85:                                               ; preds = %._crit_edge, %62, %17
  ret void
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt13unordered_mapIxxSt4hashIxESt8equal_toIxESaISt4pairIKxxEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #5 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 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 = { 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 #5 = { 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 #6 = { noreturn nounwind "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 #7 = { nounwind }
attributes #8 = { noreturn 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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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