; LLVM IR from tangjz/acm-icpc :: hdu (5401)

; 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::map.0" = type { %"class.std::_Rb_tree.1" }
%"class.std::_Rb_tree.1" = type { %"struct.std::_Rb_tree<std::pair<int, std::pair<long long, long long>>, std::pair<const std::pair<int, std::pair<long long, long long>>, int>, std::_Select1st<std::pair<const std::pair<int, std::pair<long long, long long>>, int>>, std::less<std::pair<int, std::pair<long long, long long>>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, std::pair<long long, long long>>, std::pair<const std::pair<int, std::pair<long long, long long>>, int>, std::_Select1st<std::pair<const std::pair<int, std::pair<long long, long long>>, int>>, std::less<std::pair<int, std::pair<long long, long long>>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }

@sum = external dso_local global %"class.std::map", align 8
@dist = external dso_local global %"class.std::map.0", align 8
@m = external dso_local global i32, align 4
@a = external dso_local global [61 x i32], align 16
@b = external dso_local global [61 x i32], align 16
@l = external dso_local global [61 x i32], align 16
@ans = external dso_local global [61 x i32], align 16
@c = external dso_local global [61 x i64], align 16
@d = external dso_local global [61 x i64], align 16
@sz = external dso_local global [61 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 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 noundef i32 @_Z3Ansi(i32 noundef) #1

; 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
  store i32 0, ptr %1, align 4
  br label %4

4:                                                ; preds = %64, %0
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %65

7:                                                ; preds = %4
  call void @llvm.memset.p0.i64(ptr align 16 @ans, i8 -1, i64 244, i1 false)
  call void @_ZNSt3mapISt4pairIiS0_IxxEEiSt4lessIS2_ESaIS0_IKS2_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @dist) #6
  call void @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @sum) #6
  store i64 1, ptr @sz, align 16, !tbaa !5
  store i32 0, ptr @ans, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %48, %7
  %9 = load i32, ptr %2, align 4, !tbaa !9
  %10 = load i32, ptr @m, align 4, !tbaa !9
  %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 %2) #6
  br label %51

13:                                               ; preds = %8
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i32, ptr @a, i64 %15
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds i32, ptr @b, i64 %18
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i64, ptr @c, i64 %21
  %23 = load i32, ptr %2, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i64, ptr @d, i64 %24
  %26 = load i32, ptr %2, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr @l, i64 %27
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %16, ptr noundef %19, ptr noundef %22, ptr noundef %25, ptr noundef %28)
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [61 x i32], ptr @a, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = load i32, ptr %2, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [61 x i32], ptr @b, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !5
  %44 = add nsw i64 %36, %43
  %45 = load i32, ptr %2, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %46
  store i64 %44, ptr %47, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %13
  %49 = load i32, ptr %2, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %2, align 4, !tbaa !9
  br label %8, !llvm.loop !11

51:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %61, %51
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = load i32, ptr @m, align 4, !tbaa !9
  %55 = icmp sle i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %64

57:                                               ; preds = %52
  %58 = load i32, ptr %3, align 4, !tbaa !9
  %59 = call noundef i32 @_Z3Ansi(i32 noundef %58)
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %59)
  br label %61

61:                                               ; preds = %57
  %62 = load i32, ptr %3, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %3, align 4, !tbaa !9
  br label %52, !llvm.loop !13

64:                                               ; preds = %56
  br label %4, !llvm.loop !14

65:                                               ; preds = %4
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

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

declare i32 @printf(ptr noundef, ...) #3

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, long long>, std::pair<const std::pair<int, long long>, int>, std::_Select1st<std::pair<const std::pair<int, long long>, int>>, std::less<std::pair<int, long long>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::map.0" = type { %"class.std::_Rb_tree.1" }
%"class.std::_Rb_tree.1" = type { %"struct.std::_Rb_tree<std::pair<int, std::pair<long long, long long>>, std::pair<const std::pair<int, std::pair<long long, long long>>, int>, std::_Select1st<std::pair<const std::pair<int, std::pair<long long, long long>>, int>>, std::less<std::pair<int, std::pair<long long, long long>>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<int, std::pair<long long, long long>>, std::pair<const std::pair<int, std::pair<long long, long long>>, int>, std::_Select1st<std::pair<const std::pair<int, std::pair<long long, long long>>, int>>, std::less<std::pair<int, std::pair<long long, long long>>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }

@sum = external dso_local global %"class.std::map", align 8
@dist = external dso_local global %"class.std::map.0", align 8
@m = external dso_local global i32, align 4
@a = external dso_local global [61 x i32], align 16
@b = external dso_local global [61 x i32], align 16
@l = external dso_local global [61 x i32], align 16
@ans = external dso_local local_unnamed_addr global [61 x i32], align 16
@c = external dso_local global [61 x i64], align 16
@d = external dso_local global [61 x i64], align 16
@sz = external dso_local local_unnamed_addr global [61 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph20, label %._crit_edge

.loopexit:                                        ; preds = %.lr.ph19, %.lr.ph20, %.preheader
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %.lr.ph20, label %._crit_edge, !llvm.loop !5

.lr.ph20:                                         ; preds = %0, %.loopexit
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(244) @ans, i8 -1, i64 244, i1 false)
  tail call void @_ZNSt3mapISt4pairIiS0_IxxEEiSt4lessIS2_ESaIS0_IKS2_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @dist) #5
  tail call void @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @sum) #5
  store i64 1, ptr @sz, align 16, !tbaa !7
  store i32 0, ptr @ans, align 16, !tbaa !11
  %5 = load i32, ptr @m, align 4, !tbaa !11
  %.not15 = icmp slt i32 %5, 1
  br i1 %.not15, label %.loopexit, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  %.not1417 = icmp slt i32 %22, 1
  br i1 %.not1417, label %.loopexit, label %.lr.ph19

.lr.ph:                                           ; preds = %.lr.ph20, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph20 ]
  %6 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %7 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv
  %8 = getelementptr inbounds i64, ptr @c, i64 %indvars.iv
  %9 = getelementptr inbounds i64, ptr @d, i64 %indvars.iv
  %10 = getelementptr inbounds i32, ptr @l, i64 %indvars.iv
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %10)
  %12 = load i32, ptr %6, align 4, !tbaa !11
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !7
  %16 = load i32, ptr %7, align 4, !tbaa !11
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !7
  %20 = add nsw i64 %19, %15
  %21 = getelementptr inbounds [61 x i64], ptr @sz, i64 0, i64 %indvars.iv
  store i64 %20, ptr %21, align 8, !tbaa !7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = load i32, ptr @m, align 4, !tbaa !11
  %23 = sext i32 %22 to i64
  %.not.not = icmp slt i64 %indvars.iv, %23
  br i1 %.not.not, label %.lr.ph, label %.preheader, !llvm.loop !13

.lr.ph19:                                         ; preds = %.preheader, %.lr.ph19
  %.018 = phi i32 [ %26, %.lr.ph19 ], [ 1, %.preheader ]
  %24 = tail call noundef i32 @_Z3Ansi(i32 noundef %.018)
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %24)
  %26 = add nuw nsw i32 %.018, 1
  %27 = load i32, ptr @m, align 4, !tbaa !11
  %.not14.not = icmp slt i32 %.018, %27
  br i1 %.not14.not, label %.lr.ph19, label %.loopexit, !llvm.loop !14

._crit_edge:                                      ; preds = %.loopexit, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIiS0_IxxEEiSt4lessIS2_ESaIS0_IKS2_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapISt4pairIixEiSt4lessIS1_ESaIS0_IKS1_iEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #4 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 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 #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}


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