; LLVM IR from tangjz/acm-icpc :: lydsy (3207)

; 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.std::pair" = type { i64, i64 }

@a = external dso_local global [100001 x i64], align 16
@H = external dso_local global [100001 x %"struct.std::pair"], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5Buildiii(i32 noundef, i32 noundef, 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 zeroext i1 @_Z5queryiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4Hashv() #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6getintIyEvRT_(ptr noundef nonnull align 8 dereferenceable(8)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %17, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sle i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %20

13:                                               ; preds = %8
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %15
  call void @_Z6getintIyEvRT_(ptr noundef nonnull align 8 dereferenceable(8) %16)
  br label %17

17:                                               ; preds = %13
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %4, align 4, !tbaa !5
  br label %8, !llvm.loop !9

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

21:                                               ; preds = %74, %20
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load i32, ptr @k, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %77

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %70, %26
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = load i32, ptr @k, align 4, !tbaa !5
  %30 = add nsw i32 %28, %29
  %31 = sub nsw i32 %30, 1
  %32 = load i32, ptr @n, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %27
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %73

35:                                               ; preds = %27
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @H, i64 0, i64 %37
  %39 = getelementptr inbounds %"struct.std::pair", ptr %38, i32 0, i32 0
  %40 = load i64, ptr %39, align 16, !tbaa !11
  %41 = mul i64 %40, 13
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = add nsw i32 %42, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !14
  %48 = add i64 %41, %47
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @H, i64 0, i64 %50
  %52 = getelementptr inbounds %"struct.std::pair", ptr %51, i32 0, i32 0
  store i64 %48, ptr %52, align 16, !tbaa !11
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @H, i64 0, i64 %54
  %56 = getelementptr inbounds %"struct.std::pair", ptr %55, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !15
  %58 = mul i64 %57, 29
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !14
  %65 = add i64 %58, %64
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @H, i64 0, i64 %67
  %69 = getelementptr inbounds %"struct.std::pair", ptr %68, i32 0, i32 1
  store i64 %65, ptr %69, align 8, !tbaa !15
  br label %70

70:                                               ; preds = %35
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %7, align 4, !tbaa !5
  br label %27, !llvm.loop !16

73:                                               ; preds = %34
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %5, align 4, !tbaa !5
  br label %21, !llvm.loop !17

77:                                               ; preds = %25
  %78 = load i32, ptr @n, align 4, !tbaa !5
  %79 = load i32, ptr @k, align 4, !tbaa !5
  %80 = sub nsw i32 %78, %79
  %81 = add nsw i32 %80, 1
  call void @_Z5Buildiii(i32 noundef 1, i32 noundef %81, i32 noundef 1)
  br label %82

82:                                               ; preds = %86, %77
  %83 = load i32, ptr @m, align 4, !tbaa !5
  %84 = add nsw i32 %83, -1
  store i32 %84, ptr @m, align 4, !tbaa !5
  %85 = icmp ne i32 %83, 0
  br i1 %85, label %86, label %100

86:                                               ; preds = %82
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @_Z4Hashv()
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = load i32, ptr %3, align 4, !tbaa !5
  %89 = load i32, ptr @k, align 4, !tbaa !5
  %90 = sub nsw i32 %88, %89
  %91 = add nsw i32 %90, 1
  %92 = load i32, ptr @n, align 4, !tbaa !5
  %93 = load i32, ptr @k, align 4, !tbaa !5
  %94 = sub nsw i32 %92, %93
  %95 = add nsw i32 %94, 1
  %96 = call noundef zeroext i1 @_Z5queryiiiii(i32 noundef %87, i32 noundef %91, i32 noundef 1, i32 noundef %95, i32 noundef 1)
  %97 = zext i1 %96 to i64
  %98 = select i1 %96, ptr @.str, ptr @.str.1
  %99 = call i32 @puts(ptr noundef %98)
  br label %82, !llvm.loop !18

100:                                              ; preds = %82
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %101 = load i32, ptr %1, align 4
  ret i32 %101
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #0

declare i32 @puts(ptr noundef) #3

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

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

@a = external dso_local global [100001 x i64], align 16
@H = external dso_local local_unnamed_addr global [100001 x %"struct.std::pair"], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5Buildiii(i32 noundef, i32 noundef, 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 zeroext i1 @_Z5queryiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4Hashv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6getintIyEvRT_(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  tail call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @n)
  tail call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @m)
  tail call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @k)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not24 = icmp slt i32 %3, 1
  br i1 %.not24, label %.preheader22, label %.lr.ph

.preheader22:                                     ; preds = %.lr.ph, %0
  %.lcssa23 = phi i32 [ %3, %0 ], [ %8, %.lr.ph ]
  %4 = load i32, ptr @k, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 1
  %.not2026 = icmp sgt i32 %4, %.lcssa23
  %or.cond = or i1 %5, %.not2026
  br i1 %or.cond, label %._crit_edge30, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader22
  %6 = zext nneg i32 %4 to i64
  br label %.preheader

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %7 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %indvars.iv
  tail call void @_Z6getintIyEvRT_(ptr noundef nonnull align 8 dereferenceable(8) %7)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %.not.not = icmp slt i64 %indvars.iv, %9
  br i1 %.not.not, label %.lr.ph, label %.preheader22, !llvm.loop !9

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %indvars.iv41 = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next42, %._crit_edge ]
  br label %14

._crit_edge30:                                    ; preds = %._crit_edge, %.preheader22
  %10 = add i32 %.lcssa23, 1
  %11 = sub i32 %10, %4
  tail call void @_Z5Buildiii(i32 noundef 1, i32 noundef %11, i32 noundef 1)
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr @m, align 4, !tbaa !5
  %.not1932 = icmp eq i32 %12, 0
  br i1 %.not1932, label %._crit_edge35, label %.lr.ph34

._crit_edge:                                      ; preds = %14
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next42, %6
  br i1 %exitcond.not, label %._crit_edge30, label %.preheader, !llvm.loop !11

14:                                               ; preds = %.preheader, %14
  %indvars.iv38 = phi i64 [ 1, %.preheader ], [ %indvars.iv.next39, %14 ]
  %15 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr @H, i64 0, i64 %indvars.iv38
  %16 = load i64, ptr %15, align 16, !tbaa !12
  %17 = mul i64 %16, 13
  %18 = add nuw nsw i64 %indvars.iv38, %indvars.iv41
  %19 = getelementptr inbounds [100001 x i64], ptr @a, i64 0, i64 %18
  %20 = load i64, ptr %19, align 8, !tbaa !15
  %21 = add i64 %17, %20
  store i64 %21, ptr %15, align 16, !tbaa !12
  %22 = getelementptr inbounds i8, ptr %15, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !16
  %24 = mul i64 %23, 29
  %25 = add i64 %24, %20
  store i64 %25, ptr %22, align 8, !tbaa !16
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %26 = trunc i64 %indvars.iv38 to i32
  %27 = add i32 %4, %26
  %.not20 = icmp sgt i32 %27, %.lcssa23
  br i1 %.not20, label %._crit_edge, label %14, !llvm.loop !17

.lr.ph34:                                         ; preds = %._crit_edge30, %.lr.ph34
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @_Z4Hashv()
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = load i32, ptr @k, align 4, !tbaa !5
  %31 = add i32 %29, 1
  %32 = sub i32 %31, %30
  %33 = load i32, ptr @n, align 4, !tbaa !5
  %reass.sub = sub i32 %33, %30
  %34 = add i32 %reass.sub, 1
  %35 = call noundef zeroext i1 @_Z5queryiiiii(i32 noundef %28, i32 noundef %32, i32 noundef 1, i32 noundef %34, i32 noundef 1)
  %36 = select i1 %35, ptr @.str, ptr @.str.1
  %37 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %36)
  %38 = load i32, ptr @m, align 4, !tbaa !5
  %39 = add nsw i32 %38, -1
  store i32 %39, ptr @m, align 4, !tbaa !5
  %.not19 = icmp eq i32 %38, 0
  br i1 %.not19, label %._crit_edge35, label %.lr.ph34, !llvm.loop !18

._crit_edge35:                                    ; preds = %.lr.ph34, %._crit_edge30
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6getintIiEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

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 = { mustprogress norecurse 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 = { nofree 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 #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 = !{!"int", !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 = !{!13, !14, i64 0}
!13 = !{!"_ZTSSt4pairIyyE", !14, i64 0, !14, i64 8}
!14 = !{!"long long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!13, !14, i64 8}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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