; LLVM IR from tangjz/acm-icpc :: self_training/2015-05-01 (G)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@p = external dso_local global [100001 x i32], align 16
@bit = external dso_local global [100001 x i32], align 16
@l = external dso_local global [100001 x i32], align 16
@r = external dso_local global [100001 x i32], align 16
@id = external dso_local global [100001 x i32], align 16
@ans = external dso_local global [100001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z3sumi(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 nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %8

8:                                                ; preds = %176, %0
  %9 = load i32, ptr @t, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @t, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %177

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %31, %12
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %34

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr @a, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %22)
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %29
  store i32 %24, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %19
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

34:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %52, %34
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = load i32, ptr @m, align 4, !tbaa !5
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %40, label %39

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

40:                                               ; preds = %35
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr @l, i64 %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr @r, i64 %45
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %43, ptr noundef %46)
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %50
  store i32 %48, ptr %51, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %40
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %3, align 4, !tbaa !5
  br label %35, !llvm.loop !11

55:                                               ; preds = %39
  %56 = load i32, ptr @m, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr @id, i64 %57
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @id, ptr noundef %58, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.memset.p0.i64(ptr align 16 @bit, i8 0, i64 400004, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %158, %55
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = load i32, ptr @n, align 4, !tbaa !5
  %62 = icmp sle i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %161

64:                                               ; preds = %59
  %65 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %65, i32 noundef 1)
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp sgt i32 %69, 1
  br i1 %70, label %71, label %91

71:                                               ; preds = %64
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sub nsw i32 %75, 1
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = icmp sle i32 %79, %80
  br i1 %81, label %82, label %91

82:                                               ; preds = %71
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = sub nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %90, i32 noundef -1)
  br label %91

91:                                               ; preds = %82, %71, %64
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %98, label %118

98:                                               ; preds = %91
  %99 = load i32, ptr %4, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = load i32, ptr %4, align 4, !tbaa !5
  %108 = icmp sle i32 %106, %107
  br i1 %108, label %109, label %118

109:                                              ; preds = %98
  %110 = load i32, ptr %4, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  call void @_Z3addii(i32 noundef %117, i32 noundef -1)
  br label %118

118:                                              ; preds = %109, %98, %91
  br label %119

119:                                              ; preds = %154, %118
  %120 = load i32, ptr %5, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = load i32, ptr %4, align 4, !tbaa !5
  %128 = icmp eq i32 %126, %127
  br i1 %128, label %129, label %157

129:                                              ; preds = %119
  %130 = load i32, ptr %5, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !5
  %137 = call noundef i32 @_Z3sumi(i32 noundef %136)
  %138 = load i32, ptr %5, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %139
  %141 = load i32, ptr %140, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %142
  %144 = load i32, ptr %143, align 4, !tbaa !5
  %145 = sub nsw i32 %144, 1
  %146 = call noundef i32 @_Z3sumi(i32 noundef %145)
  %147 = sub nsw i32 %137, %146
  %148 = load i32, ptr %5, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %152
  store i32 %147, ptr %153, align 4, !tbaa !5
  br label %154

154:                                              ; preds = %129
  %155 = load i32, ptr %5, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %5, align 4, !tbaa !5
  br label %119, !llvm.loop !12

157:                                              ; preds = %119
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %4, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %4, align 4, !tbaa !5
  br label %59, !llvm.loop !13

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

162:                                              ; preds = %173, %161
  %163 = load i32, ptr %6, align 4, !tbaa !5
  %164 = load i32, ptr @m, align 4, !tbaa !5
  %165 = icmp slt i32 %163, %164
  br i1 %165, label %167, label %166

166:                                              ; preds = %162
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %176

167:                                              ; preds = %162
  %168 = load i32, ptr %6, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %171)
  br label %173

173:                                              ; preds = %167
  %174 = load i32, ptr %6, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %6, align 4, !tbaa !5
  br label %162, !llvm.loop !14

176:                                              ; preds = %166
  br label %8, !llvm.loop !15

177:                                              ; preds = %8
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #4

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

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

attributes #0 = { 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 #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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !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"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [100001 x i32], align 16
@p = external dso_local local_unnamed_addr global [100001 x i32], align 16
@bit = external dso_local local_unnamed_addr global [100001 x i32], align 16
@l = external dso_local global [100001 x i32], align 16
@r = external dso_local global [100001 x i32], align 16
@id = external dso_local global [100001 x i32], align 16
@ans = external dso_local local_unnamed_addr global [100001 x i32], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z3addii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #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 @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not62 = icmp eq i32 %2, 0
  br i1 %.not62, label %._crit_edge65, label %.lr.ph64

.loopexit:                                        ; preds = %.lr.ph61, %.preheader
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge65, label %.lr.ph64, !llvm.loop !9

.lr.ph64:                                         ; preds = %0, %.loopexit
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not4146 = icmp slt i32 %7, 1
  br i1 %.not4146, label %.preheader45, label %.lr.ph

.preheader45:                                     ; preds = %.lr.ph, %.lr.ph64
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph49, label %.preheader45.._crit_edge_crit_edge

.preheader45.._crit_edge_crit_edge:               ; preds = %.preheader45
  %.pre81 = sext i32 %8 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph64, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph64 ]
  %10 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %10)
  %12 = load i32, ptr %10, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %13
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %15, ptr %14, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %.not41.not = icmp slt i64 %indvars.iv, %17
  br i1 %.not41.not, label %.lr.ph, label %.preheader45, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph49, %.preheader45.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre81, %.preheader45.._crit_edge_crit_edge ], [ %26, %.lr.ph49 ]
  %18 = getelementptr inbounds i32, ptr @id, i64 %.pre-phi
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @id, ptr noundef nonnull %18, ptr noundef nonnull @_Z3cmpRKiS0_)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400004) @bit, i8 0, i64 400004, i1 false)
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %.not4255 = icmp slt i32 %19, 1
  br i1 %.not4255, label %.preheader, label %.lr.ph59

.lr.ph49:                                         ; preds = %.preheader45, %.lr.ph49
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %.lr.ph49 ], [ 0, %.preheader45 ]
  %20 = getelementptr inbounds i32, ptr @l, i64 %indvars.iv69
  %21 = getelementptr inbounds i32, ptr @r, i64 %indvars.iv69
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %20, ptr noundef nonnull %21)
  %23 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %indvars.iv69
  %24 = trunc nuw nsw i64 %indvars.iv69 to i32
  store i32 %24, ptr %23, align 4, !tbaa !5
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %25 = load i32, ptr @m, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = icmp slt i64 %indvars.iv.next70, %26
  br i1 %27, label %.lr.ph49, label %._crit_edge, !llvm.loop !12

.preheader:                                       ; preds = %._crit_edge53, %._crit_edge
  %28 = load i32, ptr @m, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph61, label %.loopexit

.lr.ph59:                                         ; preds = %._crit_edge, %._crit_edge53
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %._crit_edge53 ], [ 1, %._crit_edge ]
  %.03157 = phi i32 [ %.1.lcssa, %._crit_edge53 ], [ 0, %._crit_edge ]
  %30 = trunc nuw nsw i64 %indvars.iv75 to i32
  tail call void @_Z3addii(i32 noundef %30, i32 noundef 1)
  %31 = getelementptr inbounds [100001 x i32], ptr @a, i64 0, i64 %indvars.iv75
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = icmp sgt i32 %32, 1
  br i1 %33, label %34, label %41

34:                                               ; preds = %.lr.ph59
  %35 = add nsw i32 %32, -1
  %36 = zext nneg i32 %35 to i64
  %37 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %.not43 = icmp slt i64 %indvars.iv75, %39
  br i1 %.not43, label %41, label %40

40:                                               ; preds = %34
  tail call void @_Z3addii(i32 noundef %38, i32 noundef -1)
  %.pre = load i32, ptr %31, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %40, %34, %.lr.ph59
  %42 = phi i32 [ %.pre, %40 ], [ %32, %34 ], [ %32, %.lr.ph59 ]
  %43 = load i32, ptr @n, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %45, label %52

45:                                               ; preds = %41
  %46 = add nsw i32 %42, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100001 x i32], ptr @p, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %.not44 = icmp slt i64 %indvars.iv75, %50
  br i1 %.not44, label %52, label %51

51:                                               ; preds = %45
  tail call void @_Z3addii(i32 noundef %49, i32 noundef -1)
  br label %52

52:                                               ; preds = %51, %45, %41
  %53 = sext i32 %.03157 to i64
  %54 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = icmp eq i64 %indvars.iv75, %59
  br i1 %60, label %.lr.ph52, label %._crit_edge53

.lr.ph52:                                         ; preds = %52, %.lr.ph52
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %.lr.ph52 ], [ %53, %52 ]
  %61 = phi i32 [ %78, %.lr.ph52 ], [ %58, %52 ]
  %62 = phi ptr [ %74, %.lr.ph52 ], [ %54, %52 ]
  %63 = tail call noundef i32 @_Z3sumi(i32 noundef %61)
  %64 = load i32, ptr %62, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100001 x i32], ptr @l, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = add nsw i32 %67, -1
  %69 = tail call noundef i32 @_Z3sumi(i32 noundef %68)
  %70 = sub nsw i32 %63, %69
  %71 = load i32, ptr %62, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %72
  store i32 %70, ptr %73, align 4, !tbaa !5
  %indvars.iv.next73 = add nsw i64 %indvars.iv72, 1
  %74 = getelementptr inbounds [100001 x i32], ptr @id, i64 0, i64 %indvars.iv.next73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100001 x i32], ptr @r, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = zext i32 %78 to i64
  %80 = icmp eq i64 %indvars.iv75, %79
  br i1 %80, label %.lr.ph52, label %._crit_edge53.loopexit, !llvm.loop !13

._crit_edge53.loopexit:                           ; preds = %.lr.ph52
  %81 = trunc nsw i64 %indvars.iv.next73 to i32
  br label %._crit_edge53

._crit_edge53:                                    ; preds = %._crit_edge53.loopexit, %52
  %.1.lcssa = phi i32 [ %.03157, %52 ], [ %81, %._crit_edge53.loopexit ]
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %82 = load i32, ptr @n, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %.not42.not = icmp slt i64 %indvars.iv75, %83
  br i1 %.not42.not, label %.lr.ph59, label %.preheader, !llvm.loop !14

.lr.ph61:                                         ; preds = %.preheader, %.lr.ph61
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.lr.ph61 ], [ 0, %.preheader ]
  %84 = getelementptr inbounds [100001 x i32], ptr @ans, i64 0, i64 %indvars.iv78
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %85)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %87 = load i32, ptr @m, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = icmp slt i64 %indvars.iv.next79, %88
  br i1 %89, label %.lr.ph61, label %.loopexit, !llvm.loop !15

._crit_edge65:                                    ; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

attributes #0 = { 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 #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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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