; LLVM IR from tangjz/acm-icpc :: codeforces/complete/756F.ll (Z4termv)

; 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.Number = type { i32, i32, i32 }
%"struct.std::pair" = type { i32, i32 }

@num = external dso_local global %struct.Number, align 4
@typ = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._Z4termv = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z3powSt4pairIiiEi(i64, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z3geniiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6nxtSymv() #3

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z4termv() #1 {
  %1 = alloca %"struct.std::pair", align 4
  %2 = alloca %struct.Number, align 4
  %3 = alloca %struct.Number, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca %"struct.std::pair", align 4
  %11 = alloca %"struct.std::pair", align 4
  %12 = alloca %"struct.std::pair", align 4
  %13 = alloca %"struct.std::pair", align 4
  %14 = alloca %"struct.std::pair", align 4
  %15 = alloca %"struct.std::pair", align 4
  %16 = alloca %"struct.std::pair", align 4
  %17 = load i32, ptr @typ, align 4, !tbaa !5
  %18 = icmp eq i32 %17, 5
  br i1 %18, label %19, label %20

19:                                               ; preds = %0
  br label %22

20:                                               ; preds = %0
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 69, ptr noundef @__PRETTY_FUNCTION__._Z4termv) #5
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  call void @llvm.lifetime.start.p0(i64 12, ptr %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 @num, i64 12, i1 false), !tbaa.struct !9
  call void @_Z6nxtSymv()
  %23 = load i32, ptr @typ, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %161

25:                                               ; preds = %22
  call void @_Z6nxtSymv()
  %26 = load i32, ptr @typ, align 4, !tbaa !5
  %27 = icmp eq i32 %26, 5
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  br label %31

29:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 75, ptr noundef @__PRETTY_FUNCTION__._Z4termv) #5
  unreachable

30:                                               ; No predecessors!
  br label %31

31:                                               ; preds = %30, %28
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 @num, i64 12, i1 false), !tbaa.struct !9
  call void @_Z6nxtSymv()
  %32 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !10
  %34 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !10
  %36 = icmp eq i32 %33, %35
  br i1 %36, label %37, label %67

37:                                               ; preds = %31
  %38 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !12
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %38, align 4, !tbaa !12
  %41 = icmp sge i32 %40, 1000000007
  br i1 %41, label %42, label %46

42:                                               ; preds = %37
  %43 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 0
  %44 = load i32, ptr %43, align 4, !tbaa !12
  %45 = sub nsw i32 %44, 1000000007
  store i32 %45, ptr %43, align 4, !tbaa !12
  br label %46

46:                                               ; preds = %42, %37
  %47 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 1
  %48 = load i32, ptr %47, align 4, !tbaa !13
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %47, align 4, !tbaa !13
  %50 = icmp sge i32 %49, 1000000006
  br i1 %50, label %51, label %55

51:                                               ; preds = %46
  %52 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !13
  %54 = sub nsw i32 %53, 1000000006
  store i32 %54, ptr %52, align 4, !tbaa !13
  br label %55

55:                                               ; preds = %51, %46
  %56 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 0
  %57 = load i32, ptr %56, align 4, !tbaa !12
  %58 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 0
  %59 = load i32, ptr %58, align 4, !tbaa !12
  %60 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !13
  %62 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 1
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !10
  %66 = call i64 @_Z3geniiiii(i32 noundef %57, i32 noundef %59, i32 noundef %61, i32 noundef %63, i32 noundef %65)
  store i64 %66, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %160

67:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %73, %67
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 2
  %71 = load i32, ptr %70, align 4, !tbaa !10
  %72 = icmp ne i32 %69, %71
  br i1 %72, label %73, label %84

73:                                               ; preds = %68
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = mul nsw i64 10, %75
  %77 = srem i64 %76, 1000000007
  %78 = trunc i64 %77 to i32
  store i32 %78, ptr %5, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = mul nsw i64 10, %80
  %82 = srem i64 %81, 1000000006
  %83 = trunc i64 %82 to i32
  store i32 %83, ptr %6, align 4, !tbaa !5
  br label %68, !llvm.loop !14

84:                                               ; preds = %68
  %85 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !12
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !13
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 2
  %92 = load i32, ptr %91, align 4, !tbaa !10
  %93 = call i64 @_Z3geniiiii(i32 noundef %86, i32 noundef %87, i32 noundef %89, i32 noundef %90, i32 noundef %92)
  store i64 %93, ptr %1, align 4
  br label %94

94:                                               ; preds = %156, %84
  %95 = load i32, ptr %5, align 4, !tbaa !5
  %96 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 2
  %97 = load i32, ptr %96, align 4, !tbaa !10
  %98 = icmp ne i32 %95, %97
  br i1 %98, label %99, label %159

99:                                               ; preds = %94
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = mul nsw i64 10, %101
  %103 = srem i64 %102, 1000000007
  %104 = trunc i64 %103 to i32
  store i32 %104, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = mul nsw i64 10, %106
  %108 = srem i64 %107, 1000000006
  %109 = trunc i64 %108 to i32
  store i32 %109, ptr %8, align 4, !tbaa !5
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 2
  %112 = load i32, ptr %111, align 4, !tbaa !10
  %113 = icmp eq i32 %110, %112
  br i1 %113, label %114, label %145

114:                                              ; preds = %99
  %115 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 0
  %116 = load i32, ptr %115, align 4, !tbaa !12
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %115, align 4, !tbaa !12
  %118 = icmp sge i32 %117, 1000000007
  br i1 %118, label %119, label %123

119:                                              ; preds = %114
  %120 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 0
  %121 = load i32, ptr %120, align 4, !tbaa !12
  %122 = sub nsw i32 %121, 1000000007
  store i32 %122, ptr %120, align 4, !tbaa !12
  br label %123

123:                                              ; preds = %119, %114
  %124 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 1
  %125 = load i32, ptr %124, align 4, !tbaa !13
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %124, align 4, !tbaa !13
  %127 = icmp sge i32 %126, 1000000006
  br i1 %127, label %128, label %132

128:                                              ; preds = %123
  %129 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 1
  %130 = load i32, ptr %129, align 4, !tbaa !13
  %131 = sub nsw i32 %130, 1000000006
  store i32 %131, ptr %129, align 4, !tbaa !13
  br label %132

132:                                              ; preds = %128, %123
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %1, i64 8, i1 false)
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 0
  %135 = load i32, ptr %134, align 4, !tbaa !12
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = getelementptr inbounds %struct.Number, ptr %3, i32 0, i32 1
  %138 = load i32, ptr %137, align 4, !tbaa !13
  %139 = load i32, ptr %7, align 4, !tbaa !5
  %140 = call i64 @_Z3geniiiii(i32 noundef %133, i32 noundef %135, i32 noundef %136, i32 noundef %138, i32 noundef %139)
  store i64 %140, ptr %11, align 4
  %141 = load i64, ptr %10, align 4
  %142 = load i64, ptr %11, align 4
  %143 = call i64 @_Z5mergeSt4pairIiiES0_(i64 %141, i64 %142)
  store i64 %143, ptr %9, align 4
  %144 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %156

145:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %1, i64 8, i1 false)
  %146 = load i32, ptr %5, align 4, !tbaa !5
  %147 = load i32, ptr %7, align 4, !tbaa !5
  %148 = load i32, ptr %6, align 4, !tbaa !5
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = load i32, ptr %7, align 4, !tbaa !5
  %151 = call i64 @_Z3geniiiii(i32 noundef %146, i32 noundef %147, i32 noundef %148, i32 noundef %149, i32 noundef %150)
  store i64 %151, ptr %14, align 4
  %152 = load i64, ptr %13, align 4
  %153 = load i64, ptr %14, align 4
  %154 = call i64 @_Z5mergeSt4pairIiiES0_(i64 %152, i64 %153)
  store i64 %154, ptr %12, align 4
  %155 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %156

156:                                              ; preds = %145, %132
  %157 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %157, ptr %5, align 4, !tbaa !5
  %158 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %158, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %94, !llvm.loop !16

159:                                              ; preds = %94
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %160

160:                                              ; preds = %159, %55
  call void @llvm.lifetime.end.p0(i64 12, ptr %3) #6
  br label %179

161:                                              ; preds = %22
  %162 = load i32, ptr @typ, align 4, !tbaa !5
  %163 = icmp eq i32 %162, 3
  br i1 %163, label %164, label %176

164:                                              ; preds = %161
  call void @_Z6nxtSymv()
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %165 = call i64 @_Z10expressionv()
  store i64 %165, ptr %15, align 4
  %166 = load i32, ptr @typ, align 4, !tbaa !5
  %167 = icmp eq i32 %166, 4
  br i1 %167, label %168, label %169

168:                                              ; preds = %164
  br label %171

169:                                              ; preds = %164
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 115, ptr noundef @__PRETTY_FUNCTION__._Z4termv) #5
  unreachable

170:                                              ; No predecessors!
  br label %171

171:                                              ; preds = %170, %168
  call void @_Z6nxtSymv()
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %15, i64 8, i1 false)
  %172 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 1
  %173 = load i32, ptr %172, align 4, !tbaa !13
  %174 = load i64, ptr %16, align 4
  %175 = call i64 @_Z3powSt4pairIiiEi(i64 %174, i32 noundef %173)
  store i64 %175, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %179

176:                                              ; preds = %161
  %177 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 0
  %178 = getelementptr inbounds %struct.Number, ptr %2, i32 0, i32 2
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(4) %177, ptr noundef nonnull align 4 dereferenceable(4) %178)
  store i32 1, ptr %4, align 4
  br label %179

179:                                              ; preds = %176, %171, %160
  call void @llvm.lifetime.end.p0(i64 12, ptr %2) #6
  %180 = load i64, ptr %1, align 4
  ret i64 %180
}

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z10expressionv() #1

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: readwrite) }
attributes #3 = { 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 = { 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 #5 = { noreturn nounwind }
attributes #6 = { 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 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!10 = !{!11, !6, i64 8}
!11 = !{!"_ZTS6Number", !6, i64 0, !6, i64 4, !6, i64 8}
!12 = !{!11, !6, i64 0}
!13 = !{!11, !6, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

%struct.Number = type { i32, i32, i32 }
%"struct.std::pair" = type { i32, i32 }

@num = external dso_local local_unnamed_addr global %struct.Number, align 4
@typ = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._Z4termv = external hidden unnamed_addr constant [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z3powSt4pairIiiEi(i64, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z3geniiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6nxtSymv() local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z4termv() local_unnamed_addr #1 {
  %1 = alloca %"struct.std::pair", align 8
  %2 = alloca %struct.Number, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca %"struct.std::pair", align 8
  %5 = load i32, ptr @typ, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 5
  br i1 %6, label %8, label %7

7:                                                ; preds = %0
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 69, ptr noundef nonnull @__PRETTY_FUNCTION__._Z4termv) #5
  unreachable

8:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) @num, i64 12, i1 false), !tbaa.struct !9
  tail call void @_Z6nxtSymv()
  %9 = load i32, ptr @typ, align 4, !tbaa !5
  switch i32 %9, label %62 [
    i32 2, label %10
    i32 3, label %53
  ]

10:                                               ; preds = %8
  tail call void @_Z6nxtSymv()
  %11 = load i32, ptr @typ, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 5
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 75, ptr noundef nonnull @__PRETTY_FUNCTION__._Z4termv) #5
  unreachable

14:                                               ; preds = %10
  %.sroa.024.0.copyload = load i32, ptr @num, align 4, !tbaa !5
  %.sroa.13.0.copyload = load i32, ptr getelementptr inbounds (i8, ptr @num, i64 4), align 4, !tbaa !5
  %.sroa.23.0.copyload = load i32, ptr getelementptr inbounds (i8, ptr @num, i64 8), align 4, !tbaa !5
  tail call void @_Z6nxtSymv()
  %15 = getelementptr inbounds i8, ptr %2, i64 8
  %16 = load i32, ptr %15, align 4, !tbaa !10
  %17 = icmp eq i32 %16, %.sroa.23.0.copyload
  br i1 %17, label %18, label %.preheader

.preheader:                                       ; preds = %14
  %.not53 = icmp eq i32 %16, 1
  br i1 %.not53, label %._crit_edge, label %.lr.ph

18:                                               ; preds = %14
  %19 = icmp sgt i32 %.sroa.024.0.copyload, 1000000005
  %spec.select.v = select i1 %19, i32 -1000000006, i32 1
  %spec.select = add nsw i32 %spec.select.v, %.sroa.024.0.copyload
  %20 = icmp sgt i32 %.sroa.13.0.copyload, 1000000004
  %.sroa.13.0.v = select i1 %20, i32 -1000000005, i32 1
  %.sroa.13.0 = add nsw i32 %.sroa.13.0.v, %.sroa.13.0.copyload
  %21 = load i32, ptr %2, align 4, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %2, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = tail call i64 @_Z3geniiiii(i32 noundef %21, i32 noundef %spec.select, i32 noundef %23, i32 noundef %.sroa.13.0, i32 noundef %.sroa.23.0.copyload)
  store i64 %24, ptr %1, align 8
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.055 = phi i64 [ %26, %.lr.ph ], [ 1, %.preheader ]
  %.03754 = phi i64 [ %29, %.lr.ph ], [ 1, %.preheader ]
  %25 = mul nsw i64 %.055, 10
  %26 = srem i64 %25, 1000000007
  %27 = trunc nsw i64 %26 to i32
  %28 = mul nsw i64 %.03754, 10
  %29 = srem i64 %28, 1000000006
  %.not = icmp eq i32 %16, %27
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %30 = trunc nsw i64 %29 to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %.037.lcssa = phi i32 [ 1, %.preheader ], [ %30, %._crit_edge.loopexit ]
  %31 = load i32, ptr %2, align 4, !tbaa !12
  %32 = getelementptr inbounds i8, ptr %2, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !13
  %34 = tail call i64 @_Z3geniiiii(i32 noundef %31, i32 noundef %16, i32 noundef %33, i32 noundef %.037.lcssa, i32 noundef %16)
  store i64 %34, ptr %1, align 8
  %.not5157 = icmp eq i32 %16, %.sroa.23.0.copyload
  br i1 %.not5157, label %.loopexit, label %.lr.ph63.preheader

.lr.ph63.preheader:                               ; preds = %._crit_edge
  %35 = sext i32 %16 to i64
  %36 = mul nsw i64 %35, 10
  %37 = srem i64 %36, 1000000007
  %38 = trunc nsw i64 %37 to i32
  %39 = icmp eq i32 %.sroa.23.0.copyload, %38
  br i1 %39, label %.loopexit.loopexit, label %.lr.ph63

.lr.ph63:                                         ; preds = %.lr.ph63.preheader, %.lr.ph63
  %40 = phi i32 [ %51, %.lr.ph63 ], [ %38, %.lr.ph63.preheader ]
  %.1385868 = phi i32 [ %44, %.lr.ph63 ], [ %.037.lcssa, %.lr.ph63.preheader ]
  %.15967 = phi i32 [ %40, %.lr.ph63 ], [ %16, %.lr.ph63.preheader ]
  %41 = sext i32 %.1385868 to i64
  %42 = mul nsw i64 %41, 10
  %43 = srem i64 %42, 1000000006
  %44 = trunc nsw i64 %43 to i32
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %.sroa.03.0.copyload = load i64, ptr %1, align 8
  %45 = call i64 @_Z3geniiiii(i32 noundef %.15967, i32 noundef %40, i32 noundef %.1385868, i32 noundef %44, i32 noundef %40)
  %46 = call i64 @_Z5mergeSt4pairIiiES0_(i64 %.sroa.03.0.copyload, i64 %45)
  store i64 %46, ptr %4, align 8
  %47 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %48 = sext i32 %40 to i64
  %49 = mul nsw i64 %48, 10
  %50 = srem i64 %49, 1000000007
  %51 = trunc nsw i64 %50 to i32
  %52 = icmp eq i32 %.sroa.23.0.copyload, %51
  br i1 %52, label %.loopexit.loopexit, label %.lr.ph63

53:                                               ; preds = %8
  tail call void @_Z6nxtSymv()
  %54 = tail call i64 @_Z10expressionv()
  %55 = load i32, ptr @typ, align 4, !tbaa !5
  %56 = icmp eq i32 %55, 4
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 115, ptr noundef nonnull @__PRETTY_FUNCTION__._Z4termv) #5
  unreachable

58:                                               ; preds = %53
  tail call void @_Z6nxtSymv()
  %59 = getelementptr inbounds i8, ptr %2, i64 4
  %60 = load i32, ptr %59, align 4, !tbaa !13
  %61 = tail call i64 @_Z3powSt4pairIiiEi(i64 %54, i32 noundef %60)
  store i64 %61, ptr %1, align 8
  br label %.loopexit

62:                                               ; preds = %8
  %63 = getelementptr inbounds i8, ptr %2, i64 8
  call void @_ZNSt4pairIiiEC2IRiS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %63)
  br label %.loopexit

.loopexit.loopexit:                               ; preds = %.lr.ph63, %.lr.ph63.preheader
  %.159.lcssa = phi i32 [ %16, %.lr.ph63.preheader ], [ %40, %.lr.ph63 ]
  %.13858.lcssa = phi i32 [ %.037.lcssa, %.lr.ph63.preheader ], [ %44, %.lr.ph63 ]
  %64 = icmp sgt i32 %.sroa.024.0.copyload, 1000000005
  %spec.select52.v = select i1 %64, i32 -1000000006, i32 1
  %spec.select52 = add nsw i32 %spec.select52.v, %.sroa.024.0.copyload
  %65 = icmp sgt i32 %.sroa.13.0.copyload, 1000000004
  %.sroa.13.2.v = select i1 %65, i32 -1000000005, i32 1
  %.sroa.13.2 = add nsw i32 %.sroa.13.2.v, %.sroa.13.0.copyload
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %.sroa.05.0.copyload = load i64, ptr %1, align 8
  %66 = call i64 @_Z3geniiiii(i32 noundef %.159.lcssa, i32 noundef %spec.select52, i32 noundef %.13858.lcssa, i32 noundef %.sroa.13.2, i32 noundef %.sroa.23.0.copyload)
  %67 = call i64 @_Z5mergeSt4pairIiiES0_(i64 %.sroa.05.0.copyload, i64 %66)
  store i64 %67, ptr %3, align 8
  %68 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %._crit_edge, %18, %62, %58
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #6
  %69 = load i64, ptr %1, align 8
  ret i64 %69
}

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_Z10expressionv() local_unnamed_addr #1

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: readwrite) }
attributes #3 = { 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 = { 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 #5 = { noreturn nounwind }
attributes #6 = { 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 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!10 = !{!11, !6, i64 8}
!11 = !{!"_ZTS6Number", !6, i64 0, !6, i64 4, !6, i64 8}
!12 = !{!11, !6, i64 0}
!13 = !{!11, !6, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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